似然比检验(LR)、Wald检验、拉格朗日检验(LM)都基于最大似然估计(MLE),本文以logit模型为例讨论三类检验的Stata实现。不当之处,请各位指正。
1、似然比检验
use http://www.ats.ucla.edu/stat/stata/faq/nested_tests, clear
*Likelihood-ratio test
logit hiwrite
estimates store m1
logit hiwrite female read math science
estimates store m2
lrtest m1 m2
当然我们可以使用另外一种方法来实现上述同样的结果:
*another method to compute LR test
logit hiwrite female read math science
scalar c=2*(e(ll)-e(ll_0))
scalar p_c = chi2tail(1,c)
di as txt 'chi2(4)???? = ' as result %9.2g `=c'
di as txt 'Prob > chi2 = ' asresult %9.4g `=p_c'
两者的结果是一样的:
当然logit模型本身也汇报了LR统计量:
2、wald检验
*wald test
qui:logit hiwrite female read math science
test female read math science
3、拉格朗日检验
本来Stata里有一个user-written的命令叫做testomit,但是这个命令当前在Stata里并不能被找到。可能是作者移除了网页。如果您有这个命令的源程序,麻烦您联系我。
Statalist里很多人都在讨论如何进行LM检验,来自Universityof Konstanz的Maarten L. Buis给出的答案如下:
* Lagrange multiplier test
qui:logit hiwrite female read math science
// use the resulting gradient and var-covmatrix to compute the test statistics
matrix S = e(gradient)*e(V)*e(gradient)'
scalar a = el(S,1,1)
scalar p_s = chi2tail(1,a)
// display the result
di as txt 'chi2(1)???? = ' as result %9.2g `=a'
di as txt 'Prob > chi2 = ' asresult %9.4g `=p_s'
但是由于这种方法得到的结果和前述两种检验得到的结果差别真的太大,我对这个方法持谨慎态度。如果您有别的想法,欢迎在留言里讨论。
39538025