cp_LRT {gspcr} | R Documentation |
Compute likelihood ratio test
Description
Computes the likelihood ratio expressed as a difference between the log-likelihoods of observed data under two nested competing models.
Usage
cp_LRT(ll_restricted, ll_full)
Arguments
ll_restricted |
numeric vector of length 1 (or an object of class 'logLik') storing the log-likelihood of the observed data under the restricted model |
ll_full |
numeric vector of length 1 (or an object of class 'logLik') storing the log-likelihood of the observed data under the full model |
Details
Note that:
The full model is always the model with more estimated parameters, the model with more predictor variables.
The restricted model is the model with fewer estimated parameters.
The restricted model must be nested within the full model.
Value
numeric vector of length 1 storing the likelihood ratio test statistic
Author(s)
Edoardo Costantini, 2023
Examples
# Fit a nested model
nested <- glm(mpg ~ cyl + disp, data = mtcars)
# Fit a complex model
complex <- glm(mpg ~ cyl + disp + hp + am, data = mtcars)
# Compute log-likelihood statistic with your function
LRT_M <- cp_LRT(
ll_restricted = logLik(nested),
ll_full = logLik(complex)
)
[Package gspcr version 0.9.5 Index]