| oneLRT | R Documentation |
Performs a likelihood ratio test (LRT) to compare two nested models estimated by
oneinfl or truncreg. It calculates the LRT statistic
and its associated p-value, testing whether the more complex model provides
a significantly better fit to the data than the simpler model.
oneLRT(mod0, mod1)
mod0 |
A model object (typically the simpler model) estimated using
|
mod1 |
A model object (typically the more complex model) estimated using
|
The function extracts the log-likelihoods and number of parameters from the two models. It then calculates the LRT statistic:
-2 \cdot (\ell_0 - \ell_1)
where \ell_0 and \ell_1 are the log-likelihoods of the simpler and
more complex models, respectively. The degrees of freedom for the test are
equal to the difference in the number of parameters between the models.
The likelihood ratio test is commonly used to test for: - Overdispersion: Comparing a Poisson model to a negative binomial model. - One-inflation: Comparing a one-inflated model to a non-one-inflated model.
A list with the following components:
LRTstatThe likelihood ratio test statistic.
pvalThe p-value associated with the test statistic, based on a chi-squared distribution.
oneinfl for fitting one-inflated models.
truncreg for fitting zero-truncated models.
pchisq for the chi-squared distribution.
# Example: One-inflation test
df <- data.frame(y = rpois(100, lambda = 5), x = rnorm(100), z = rnorm(100))
OIZTNB <- oneinfl(y ~ x | z, df = df, dist = "negbin")
ZTNB <- truncreg(y ~ x, df = df, dist = "negbin")
oneLRT(OIZTNB, ZTNB)
# Example: Overdispersion test
OIPP <- oneinfl(y ~ x | z, df = df, dist = "Poisson")
oneLRT(OIZTNB, OIPP)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.