truncreg | R Documentation |
Fits a positive Poisson (PP) or zero-truncated negative binomial (ZTNB) regression model.
truncreg(formula, df, dist = "negbin", start = NULL, method = "BFGS")
formula |
A symbolic description of the model to be fitted. |
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 zero-truncated counts. Zero-truncated models are used when the count data does not include zeros, such as in cases where only positive counts are observed.
The function supports two distributions:
"Poisson"
: Zero-truncated Poisson regression.
"negbin"
: Zero-truncated negative binomial regression.
The function uses numerical optimization via optim
to estimate the parameters.
An object of class "truncmodel"
containing the following components:
beta
Estimated coefficients for the regression model.
alpha
Dispersion parameter (only for negative binomial distribution).
vc
Variance-covariance matrix of the estimated parameters.
logl
Log-likelihood of the fitted model.
dist
The distribution used for the model ("Poisson" or "negbin").
formula
The formula used for the model.
summary
for summarizing the fitted model.
# Example usage
df <- data.frame(x = rnorm(100), y = rpois(100, lambda = 1) + 1)
model <- truncreg(y ~ x, df = df, dist = "Poisson")
summary(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.