The following objects are masked from 'package:base':
as.Date, as.Date.numeric
## with data from Greene (1993):## load data and compute lagsdata("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## 下面4种操作方法是等价的lrtest(fm2, fm1)
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.524e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Likelihood ratio test
Model 1: Surv(time, status) ~ age + sex * factor(ph.ecog)
Model 2: Surv(time, status) ~ age + sex + factor(ph.ecog)
#Df LogLik Df Chisq Pr(>Chisq)
1 7 -728.93
2 5 -729.05 -2 0.2263 0.893