Description Usage Arguments Details Value See Also Examples
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).
1 2 3 4 5 6 7 
object 
an object. See below for details. 
... 
further object specifications passed to methods. See below for details. 
name 
a function for extracting a suitable name/description from
a fitted model object. By default the name is queried by calling

data 
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 loglikelihoods (as derived by the logLik
methods)
is compared with a Chisquared distribution.
The "formula"
method fits a lm
first and then calls the default
method.
An object of class "anova"
which contains the loglikelihood, degrees of freedom,
the difference in degrees of freedom, likelihood ratio Chisquared statistic and corresponding p value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14  ## with data from Greene (1993):
## load data and compute lags
data("USDistLag")
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)

Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Likelihood ratio test
Model 1: con ~ gnp + con1 + gnp1
Model 2: con ~ gnp + gnp1
#Df LogLik Df Chisq Pr(>Chisq)
1 5 56.069
2 4 65.871 1 19.605 9.524e06 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Likelihood ratio test
Model 1: con ~ gnp + con1 + gnp1
Model 2: con ~ gnp + gnp1
#Df LogLik Df Chisq Pr(>Chisq)
1 5 56.069
2 4 65.871 1 19.605 9.524e06 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Likelihood ratio test
Model 1: con ~ gnp + con1 + gnp1
Model 2: con ~ gnp + gnp1
#Df LogLik Df Chisq Pr(>Chisq)
1 5 56.069
2 4 65.871 1 19.605 9.524e06 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Likelihood ratio test
Model 1: con ~ gnp + con1 + gnp1
Model 2: con ~ gnp + gnp1
#Df LogLik Df Chisq Pr(>Chisq)
1 5 56.069
2 4 65.871 1 19.605 9.524e06 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.