| Type: | Package |
| Title: | Marginalized Count Regression Models |
| Version: | 1.0.1 |
| 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. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| LazyData: | true |
| Depends: | R (≥ 4.0.0) |
| Imports: | bbmle, boot, boot.pval, rootSolve, robustbase, stats |
| NeedsCompilation: | no |
| RoxygenNote: | 7.3.3 |
| Packaged: | 2026-04-10 19:17:29 UTC; bill_ |
| Author: | Zhengyang Zhou [aut, cre], Dateng Li [aut], David Huh [aut], Minge Xie [aut], Eun-Young Mun [aut] |
| Maintainer: | Zhengyang Zhou <zhengyang.zhou@unthsc.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-21 22:22:11 UTC |
Promoting Adherence for Life (PAL) study dataset
Description
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.
Usage
dat.pal
Format
A data frame with variables including:
- id
Participant identifier.
- tx
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.- doses0
Number of doses taken in the past 3 days, at baseline.
- doses3
Number of doses taken in the past 3 days, at post-intervention.
- totaldoses
Number of total prescribed doses.
Source
PAL study
References
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
Personalized Feedback Intervention (PFI) example dataset
Description
A dataset from White, Mun, and Morgan (2008), which is also described in Mun et al. (2015, 2022).
Usage
dat.pfi
Format
A data frame with 194 rows and 5 variables:
- m0
Number of standard alcohol drinks consumed at baseline.
- int_PF
Indicator for receiving personalized feedback intervention (PFI):
1= received PFI,0= did not receive PFI.- year_new
Indicator for first-year college student status:
1= first-year student,0= otherwise.- race_new
Indicator for race:
1= White,0= non-White.- y
Number of standard alcohol drinks consumed at post-intervention; the response variable.
Source
White et al. (2008)
References
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
Estimating Marginalized Zero-inflated Poisson Models
Description
Fit marginalized zero-inflated Poisson models for zero-inflated count data via maximum likelihood estimation.
Usage
mzip(formula, data)
Arguments
formula |
an object of class " |
data |
a data frame containing variables in the model. |
Details
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.
Value
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.
References
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.
Examples
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)
Estimating Marginalized Zero- and N-inflated Binomial (MZNIB) models
Description
Fit MZNIB regression models for fractional count data with boundary inflation at zero and the upper limit with bootstrapped standard errors.
Usage
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"
)
Arguments
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. |
Value
An object of class "mznib", which contains the fitted MZNIB model
and has the following components:
- coef
A data frame with the coefficient estimates and associated standard errors, confidence intervals, and p-values.
- alpha_estimates
A matrix with the coefficient estimates from each bootstrap replication.
- convergence
A logical value indicating whether the model fit for the original data converged.
- bootobj
The bootstrap object containing the bootstrap results.
- call
The original function call.
- formula
The original regression formula.
- R
A scalar indicating the number of bootstrap replications.
- test_method
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.
Examples
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)
Working estimator for alpha (internal)
Description
Internal working estimator used by mznib.
Usage
mznib_work_generic(
formula,
data,
N_i,
initial_value = 0,
initial_value_alpha = 0,
optim_method
)
Score function for alpha (internal)
Description
Internal score function used by mznib.
Usage
obtain_score_functions_generic(x_mat, beta, gamma, phi, N_i, alpha)
Print method for mzip objects
Description
Print method for mzip objects
Usage
## S3 method for class 'mzip'
print(x, ...)
Arguments
x |
A fitted |
... |
Additional arguments passed to |
Print method for summary.mznib objects
Description
Print method for summary.mznib objects
Usage
## S3 method for class 'summary.mznib'
print(x, ...)
Arguments
x |
A |
... |
Additional arguments (not used). |
Summary method for mzip objects
Description
Summary method for mzip objects
Usage
## S3 method for class 'mzip'
summary(object, ...)
Arguments
object |
A fitted |
... |
Additional arguments passed to |
Value
A summary object from bbmle::summary().
Summary method for mznib objects
Description
Summary method for mznib objects
Usage
## S3 method for class 'mznib'
summary(object, ...)
Arguments
object |
A fitted mznib object. |
... |
Additional arguments (not used). |
Value
An object of class "summary.mznib".
ZNIB working model (internal)
Description
Internal working-model fit used by mznib.
Usage
znib_generic(formula, data, N_i, initial_value = 0, optim_method = "BFGS")