oneinfl | R Documentation |
Fits a one-inflated positive Poisson (OIPP) or one-inflated zero-truncated negative binomial (OIZTNB) regression model.
oneinfl(formula, df, dist = "negbin", start = NULL, method = "BFGS")
formula |
A symbolic description of the model to be fitted. Variables before the pipe |
df |
A data frame containing the variables in the model. |
dist |
A character string specifying the distribution to use. Options are |
start |
Optional. A numeric vector of starting values for the optimization process. Defaults to |
method |
A character string specifying the optimization method to be passed to |
This function fits a regression model for one-inflated counts. One-inflated models are used when there are an excess number of ones, relative to a Poisson or negative binomial process.
The function supports two distributions:
"Poisson"
: One-inflated Poisson regression.
"negbin"
: One-inflated negative binomial regression.
The function uses numerical optimization via optim
to estimate the parameters.
An object of class "oneinflmodel"
containing the following components:
beta
Estimated coefficients for the rate component of the model.
gamma
Estimated coefficients for the one-inflation component of the model.
alpha
Dispersion parameter (only for negative binomial distribution).
vc
Variance-covariance matrix of the estimated parameters.
logl
Log-likelihood of the fitted model.
avgw
Average one-inflation probability.
absw
Mean absolute one-inflation probability.
dist
The distribution used for the model ("Poisson" or "negbin").
formula
The formula used for the model.
summary
for summarizing the fitted model.
margins
for calculating the marginal effects of regressors.
oneWald
to test for no one-inflation.
signifWald
for testing the joint significance of a single regressor that appears before and after the pipe |
.
oneplot
for plotting actual and predicted counts.
predict
for expected response/dependent variable at each observation.
truncreg
for fitting positive Poisson (PP) and zero-truncated negative binomial (ZTNB) models.
oneLRT
to test for no one-inflation or no overdispersion using a nested PP, OIPP, or ZTNB model.
# Example usage
df <- data.frame(x = rnorm(100), z = rnorm(100), y = rpois(100, lambda = 1) + 1)
model <- oneinfl(y ~ x | z, df = df, dist = "Poisson")
summary(model)
margins(model, df)
oneWald(model)
predict(model, df=df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.