| Title: | Marginalized Count Regression Models |
|---|---|
| Description: | Implementation of marginalized models for zero-inflated count data. The package provides tools to estimate marginalized count regression models for direct inference on the effect of covariates on the marginal mean of the outcome. The methods include the marginalized zero-inflated Poisson (MZIP) model described in Long et al. (2014) <doi:10.1002/sim.6293> and the marginalized zero- and N-inflated binomial (MZNIB) model, which extends marginalized modeling to fractional count outcomes with boundary inflation at zero and the upper limit. |
| Authors: | Zhengyang Zhou [aut, cre], Dateng Li [aut], David Huh [aut], Minge Xie [aut], Eun-Young Mun [aut] |
| Maintainer: | Zhengyang Zhou <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.1 |
| Built: | 2026-05-22 05:53:35 UTC |
| Source: | https://github.com/cran/mcount |
A dataset from the Promoting Adherence for Life (PAL) study, as reported in Huh, Flaherty, and Simoni (2012) and Simoni et al. (2009). The PAL study was a 2×2 factorial trial that evaluated peer support and text reminders for promoting HIV antiretroviral adherence.
dat.paldat.pal
A data frame with variables including:
Participant identifier.
A factor variable specifying the intervention group with the following categories:
"CTRL" = Control (Standard of Care),
"PEER" = Peer support only,
"TXTS" = Text messages only,
and "BOTH" = Peer support plus text messages.
Number of doses taken in the past 3 days, at baseline.
Number of doses taken in the past 3 days, at post-intervention.
Number of total prescribed doses.
PAL study
Huh, D., Flaherty, B. P., & Simoni, J. M. (2012). Optimizing the analysis of adherence interventions using logistic generalized estimating equations. AIDS and Behavior, 16(2), 422–431. doi:10.1007/s10461-011-9955-5
Simoni, J. M., Huh, D., Frick, P. A., Pearson, C. R., Andrasik, M. P., Dunbar, P. J., & Hooton, T. M. (2009). Peer support and pager messaging to promote antiretroviral modifying therapy in Seattle: A randomized controlled trial. Journal of Acquired Immune Deficiency Syndromes, 52(4), 465–473. doi:10.1097/QAI.0b013e3181b9300c
A dataset from White, Mun, and Morgan (2008), which is also described in Mun et al. (2015, 2022).
dat.pfidat.pfi
A data frame with 194 rows and 5 variables:
Number of standard alcohol drinks consumed at baseline.
Indicator for receiving personalized feedback intervention (PFI):
1 = received PFI, 0 = did not receive PFI.
Indicator for first-year college student status:
1 = first-year student, 0 = otherwise.
Indicator for race:
1 = White, 0 = non-White.
Number of standard alcohol drinks consumed at post-intervention; the response variable.
White et al. (2008)
White, H. R., Mun, E.-Y., & Morgan, T. J. (2008). Do brief personalized feedback interventions work for mandated students or is it just getting caught that works? Psychology of Addictive Behaviors, 22(1), 107–116. doi:10.1037/0893-164X.22.1.107
Mun, E. Y., De La Torre, J., Atkins, D. C., White, H. R., Ray, A. E., Kim, S. Y., ... & The Project INTEGRATE Team. (2015). Project INTEGRATE: An integrative study of brief alcohol interventions for college students. Psychology of Addictive Behaviors, 29(1), 34–48. doi:10.1037/adb0000047
Mun, E.-Y., Zhou, Z., Huh, D., Tan, L., Li, D., Tanner-Smith, E. E., Walters, S. T., & Larimer, M. E. (2022). Brief alcohol interventions are effective through six months: Findings from marginalized zero-inflated Poisson and negative binomial models in a two-step IPD meta-analysis. Prevention Science. doi:10.1007/s11121-022-01420-1
Fit marginalized zero-inflated Poisson models for zero-inflated count data via maximum likelihood estimation.
mzip(formula, data)mzip(formula, data)
formula |
an object of class " |
data |
a data frame containing variables in the model. |
Function returns an object of class "mle2" from bbmle R package. Apply summary function to the resulting object from the function to obtain more estimation information.
mzip returns an object of class "mzip".
The fitted model object contains the estimated coefficients and other
information about the fitted model.
The function summary (i.e., summary.mzip) can be used to
obtain or print a summary of the results.
Suffix _zero corresponds to the parameters associated with the structrual zero rate part of a model.
Suffix _mean corresponds to the parameters associated with the overall mean, which evaluate the effects of covariates on the overall mean.
Long, D. L., Preisser, J. S., Herring, A. H., & Golin, C. E. (2014). A marginalized zero‐inflated Poisson regression model with overall exposure effects. Statistics in Medicine, 33(29), 5151-5165.
head(dat.pfi) #Fit a marginalized zero-inflated Poisson model res = mzip(formula = y ~ m0 + int_PF + year_new + race_new, data = dat.pfi) #Obtain estimation results summary(res)head(dat.pfi) #Fit a marginalized zero-inflated Poisson model res = mzip(formula = y ~ m0 + int_PF + year_new + race_new, data = dat.pfi) #Obtain estimation results summary(res)
Fit MZNIB regression models for fractional count data with boundary inflation at zero and the upper limit with bootstrapped standard errors.
mznib( formula, data, N_i, initial_value = "auto", initial_value_alpha = "auto", R = 1000, ncpus = 1, optim_method = "L-BFGS-B", parallel = "no", seed = NULL, test_method = "perc" )mznib( formula, data, N_i, initial_value = "auto", initial_value_alpha = "auto", R = 1000, ncpus = 1, optim_method = "L-BFGS-B", parallel = "no", seed = NULL, test_method = "perc" )
formula |
A model formula. |
data |
A data frame containing variables in the model. |
N_i |
The maximum value that i-th subject can take (vector). |
initial_value |
Starting values for estimating the coefficients of the zero- and N-inflated binomial (ZNIB) model, which is used as the "working model" from which the marginalized coefficients are derived. The marginalized coefficients are derived from these initial working estimates from the ZINB. This can be specified manually (i.e., a vector whose length is the number of regression coefficients specified in "formula" (+1 for the intercept) and multiplied by 3). The starting values can also be estimated automatically using GLM by specifying "auto", which we recommend. |
initial_value_alpha |
Starting values for estimating the marginalized coefficients, with length equal to the number of regression coefficients specified in "formula" +1 for the intercept. The starting values can also be estimated automatically using GLM (="auto"), which we recommend. |
R |
The number of bootstrapped replications for estimating standard errors and confidence intervals. A higher number of replications improves precision. |
ncpus |
The number of CPUs to use (>1 for parallel processing) |
optim_method |
The maximum-likelihood optimizer used to estimate the initial ZINB estimates from which the marginalized MZNIB estimates are derived. We recommend specifying "L-BFGS-B". |
parallel |
The type of parallel processing used, if any. Options include "multicore" (MacOS and Unix-based systems), "snow" (Windows systems), or "no" for single-core processing. |
seed |
A numeric seed number so that the results are reproducible. The number of CPUs specified in the ncpus argument must also be kept the same for exact reproduction of results. |
test_method |
The method used to estimate confidence intervals and test statistical significance of the marginalized coefficients. The default is "perc" which uses the percentile-based confidence intervals and corresponding P-values. Robust, normal approximation confidence intervals and P-values can be specified using "MCD", which uses the minimum covariance determinant method. |
An object of class "mznib", which contains the fitted MZNIB model
and has the following components:
A data frame with the coefficient estimates and associated standard errors, confidence intervals, and p-values.
A matrix with the coefficient estimates from each bootstrap replication.
A logical value indicating whether the model fit for the original data converged.
The bootstrap object containing the bootstrap results.
The original function call.
The original regression formula.
A scalar indicating the number of bootstrap replications.
A character string indicating the method used to estimate the confidence intervals and test statistical significance.
The function summary (i.e., summary.mznib) can be used to
obtain or print a summary of the results.
data("dat.pal", package = "mcount") # Prepare covariates dat.pal$doses0z <- as.numeric(scale(dat.pal$doses0)) dat.pal$tx_peer <- as.integer(dat.pal$tx == "PEER") dat.pal$tx_txts <- as.integer(dat.pal$tx == "TXTS") dat.pal$tx_both <- as.integer(dat.pal$tx == "BOTH") # Fit the MZNIB model fit <- mznib( doses3 ~ doses0z + tx_peer + tx_txts + tx_both, data = dat.pal, N_i = dat.pal$totaldoses, initial_value = "auto", initial_value_alpha = "auto", R = 150, ncpus = 1, parallel = "no" ) summary(fit)data("dat.pal", package = "mcount") # Prepare covariates dat.pal$doses0z <- as.numeric(scale(dat.pal$doses0)) dat.pal$tx_peer <- as.integer(dat.pal$tx == "PEER") dat.pal$tx_txts <- as.integer(dat.pal$tx == "TXTS") dat.pal$tx_both <- as.integer(dat.pal$tx == "BOTH") # Fit the MZNIB model fit <- mznib( doses3 ~ doses0z + tx_peer + tx_txts + tx_both, data = dat.pal, N_i = dat.pal$totaldoses, initial_value = "auto", initial_value_alpha = "auto", R = 150, ncpus = 1, parallel = "no" ) summary(fit)
Print method for mzip objects
## S3 method for class 'mzip' print(x, ...)## S3 method for class 'mzip' print(x, ...)
x |
A fitted |
... |
Additional arguments passed to |
Print method for summary.mznib objects
## S3 method for class 'summary.mznib' print(x, ...)## S3 method for class 'summary.mznib' print(x, ...)
x |
A |
... |
Additional arguments (not used). |
Summary method for mzip objects
## S3 method for class 'mzip' summary(object, ...)## S3 method for class 'mzip' summary(object, ...)
object |
A fitted |
... |
Additional arguments passed to |
A summary object from bbmle::summary().
Summary method for mznib objects
## S3 method for class 'mznib' summary(object, ...)## S3 method for class 'mznib' summary(object, ...)
object |
A fitted mznib object. |
... |
Additional arguments (not used). |
An object of class "summary.mznib".