oneinfl {oneinfl} | R Documentation |
One-Inflated Regression Model
Description
Fits a one-inflated positive Poisson (OIPP) or one-inflated zero-truncated negative binomial (OIZTNB) regression model.
Usage
oneinfl(formula, df, dist = "negbin", start = NULL, method = "BFGS")
Arguments
formula |
A symbolic description of the model to be fitted. Variables before the pipe '|' link to the usual Poisson rate parameter, after the pipe link to the one-inflation parameter. |
df |
A data frame containing the variables in the model. |
dist |
A character string specifying the distribution to use. Options are '"Poisson"' or '"negbin"'. |
start |
Optional. A numeric vector of starting values for the optimization process. Defaults to 'NULL', in which case starting values are attempted to be chosen automatically. |
method |
A character string specifying the optimization method to be passed to |
Details
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.
Value
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.
See Also
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.
Examples
# 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)