似然比檢驗(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'
但是由於這種方法得到的結果和前述兩種檢驗得到的結果差別真的太大,我對這個方法持謹慎態度。如果您有別的想法,歡迎在留言裡討論。