Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Negative LR test statistic ?


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Negative LR test statistic ?
Date   Tue, 22 Dec 2009 08:56:17 +0000 (GMT)

--- On Tue, 22/12/09, Ekrem Kalkan wrote:
> Still, I think there should be a different
> reason rather than degrees of freedom. 

You can illustrate that this is a sample size 
related problem using the simulation below.
Here I am testing a true null hypothesis after 
logistic regression with a likelihood ratio test 
on a dataset with 25, 50, 75, 100 observations. 

In the simulation that uses only 25 observations 
102 out of 1000 samples produced a negative Chi^2 
statistic, this reduced to only 6 in the 
simulation with sample size 50, and 0 to the 
simulations with 75 and 100 observations. 

*---------------- begin example ---------------------
program drop _all
program define sim, rclass
	drop _all
	set obs `1'
	gen x1 = rnormal()
	gen x2 = rnormal()
	gen x3 = rnormal()
	gen y = runiform() < invlogit(-2 + x1)
	logit y x1 x2 x3
	est store a
	logit y x1
	est store b
	lrtest a b 
	return scalar chi2 = r(chi2)
end

set seed 12345
simulate chi2 = r(chi2), reps(1000) nodots : sim 25
count if chi2 < 0

simulate chi2 = r(chi2), reps(1000) nodots : sim 50
count if chi2 < 0

simulate chi2 = r(chi2), reps(1000) nodots : sim 75
count if chi2 < 0

simulate chi2 = r(chi2), reps(1000) nodots : sim 100
count if chi2 < 0
*--------------------- end example -------------------
( For more on how to use examples I sent to statalist see:
 http://www.maartenbuis.nl/stata/exampleFAQ.html )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index