Three asymptotic tests in R
Three Asymptotic Tests: LR, Wald, LM test
LR test : restricted parameter vector and specify distribution(∵ likelihood function)
Wald test : unrestricted parameter vector only
LM test: restricted parameter vector only, the popular method in econometrics since restricted model is easy to get.
Method 1
#read data
hs1 <- read.table("http://www.ats.ucla.edu/stat/R/notes/hs1.csv", header=T, sep=",")
attach(hs1)
# classify variable
honcomp <- write >= 60
honcomp[1:20]
#LR test for logistic reg
lr <- glm(honcomp~female+read, family=binomial) lr2 <- glm(honcomp~female+read+science+math+as.factor(prog), binomial, na.action=na.exclude) drop1(lr2, test="Chisq")
Method 2
see http://cran.r-project.org/src/contrib/Descriptions/lmtest.html
#download the package lmtest
library(lmtest)
lrtest(lr,lr2)
waldtest(lr,lr2)
lmtest(lr,lr2)
沒有留言:
張貼留言