oneLRT {oneinfl} | R Documentation |
Likelihood Ratio Test for Nested Models
Description
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.
Usage
oneLRT(mod0, mod1)
Arguments
mod0 |
A model object (typically the simpler model) estimated using
|
mod1 |
A model object (typically the more complex model) estimated using
|
Details
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.
Value
A list with the following components:
LRTstat
The likelihood ratio test statistic.
pval
The p-value associated with the test statistic, based on a chi-squared distribution.
See Also
oneinfl
for fitting one-inflated models.
truncreg
for fitting zero-truncated models.
pchisq
for the chi-squared distribution.
Examples
# 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)