Assumptions: (1) The null model is nested within the alternative model. (2) The likelihood values are computed from the same data set.

lrt(null_loglik, alt_loglik, dof)

Arguments

null_loglik

the likelihood value from a simpler likelihood model nested within the alternative model

alt_loglik

the likelihood value from the more complicated model

dof

degrees of freedom

Value

likelihood ratio test

Details

The degrees of freedom are conceptualized in the context of vector spaces. Thus, by (1), the parameter space of the null model is a subspace of the parameter space of the alternative model, both of which are vector spaces. The degrees of freedom is the difference in the dimension of the null model and the alternative model. Normally, this boils down to the difference in the number of parameters between the two models, e.g., fixing some of the components in the null model to some constant value.

The likelihood ratio test statistic is defined as:

LRT = -2 (null_loglik - alt_loglik)

which, under the null hypothesis, is asymptotically chi-squared distributed with degrees of freedom equal to the dof previously defined. Thus, we can ask whether the observed likelihood ratio test statistic is significantly different from the expected value under the null hypothesis. The p-value is the probability of observing an LRT statistic as extreme as the one observed under the null hypothesis.

Examples

# create a likelihood ratio test
lrt <- lrt(null_loglik = -100, alt_loglik = -90, dof = 1)
# print the test
test_stat(lrt)
#> [1] 20
pval(lrt)
#> [1] 7.744216e-06
dof(lrt)
#> [1] 1
# check if the test is significant at the 5% level
is_significant_at(lrt, 0.05)
#> [1] TRUE