lrtest: Likelihood Ratio Test of Nested Models

View source: R/lrtest.R

lrtestR Documentation

Likelihood Ratio Test of Nested Models


lrtest is a generic function for carrying out likelihood ratio tests. The default method can be employed for comparing nested (generalized) linear models (see details below).


 lrtest(object, ...)

 ## Default S3 method:
lrtest(object, ..., name = NULL) 

 ## S3 method for class 'formula'
lrtest(object, ..., data = list())



an object. See below for details.


further object specifications passed to methods. See below for details.


a function for extracting a suitable name/description from a fitted model object. By default the name is queried by calling formula.


a data frame containing the variables in the model.


lrtest is intended to be a generic function for comparisons of models via asymptotic likelihood ratio tests. The default method consecutively compares the fitted model object object with the models passed in .... Instead of passing the fitted model objects in ..., several other specifications are possible. The updating mechanism is the same as for waldtest: the models in ... can be specified as integers, characters (both for terms that should be eliminated from the previous model), update formulas or fitted model objects. Except for the last case, the existence of an update method is assumed. See waldtest for details.

Subsequently, an asymptotic likelihood ratio test for each two consecutive models is carried out: Twice the difference in log-likelihoods (as derived by the logLik methods) is compared with a Chi-squared distribution.

The "formula" method fits a lm first and then calls the default method.


An object of class "anova" which contains the log-likelihood, degrees of freedom, the difference in degrees of freedom, likelihood ratio Chi-squared statistic and corresponding p value.

See Also



## with data from Greene (1993):
## load data and compute lags
usdl <- na.contiguous(cbind(USDistLag, lag(USDistLag, k = -1)))
colnames(usdl) <- c("con", "gnp", "con1", "gnp1")

fm1 <- lm(con ~ gnp + gnp1, data = usdl)
fm2 <- lm(con ~ gnp + con1 + gnp1, data = usdl)

## various equivalent specifications of the LR test
lrtest(fm2, fm1)
lrtest(fm2, 2)
lrtest(fm2, "con1")
lrtest(fm2, . ~ . - con1)

lmtest documentation built on March 22, 2022, 1:06 a.m.