Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: a question on testing for random effect model against fixed effect model


From   "Jian Zhang" <jzh@ucdavis.edu>
To   "Schaffer, Mark E" <M.E.Schaffer@hw.ac.uk>, statalist@hsphsun2.harvard.edu
Subject   RE: st: RE: a question on testing for random effect model against fixed effect model
Date   Thu, 27 Jul 2006 12:35:19 -0700 (PDT)

Dear  Mark, 

Thanks for your comments!  

Sorry for my late response.  Here are the results reported by Stata:

First I run: xtreg earned_inc t1 t2 t3 t4 t5 cadre membership edu2 edu3 edu4, re i(xhn)

Then I store the results of the random effect model: estimates store random

Then I run fixed effect model: xtreg earned_inc t3 t4 t5 t6 t7 cadre membership edu2 edu3 
edu4, fe i(xhn)

Finally I do the hausman test: hausman . random, sigmaless

The results reported by Stata are as follows:

	---- Coefficients ----
	(b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
	.          random       Difference          S.E.
	
t3	-27.42538    -26.08845       -1.336927               .
t4	-28.17475    -31.47857        3.303822               .
t5	-64.7231    -63.43336       -1.289746        .4918778
cadre	44.64596     57.50894       -12.86298        7.411722
membership	-10.44655     2.795032       -13.24158        8.840997
edu2	24.21366     57.38761       -33.17395        6.615227
edu3	83.88996     129.8966       -46.00666        7.334445
edu4	132.2866     207.6196       -75.33295        11.79708
	
	b = consistent under Ho and Ha; obtained from xtreg
B =	inconsistent under Ha, efficient under Ho; obtained from xtreg

Test:  Ho:	difference in coefficients not systematic

	chi2(8) = (b-B)'[(V_b-V_B)^(-1)](b-B)
	=      256.13
	Prob>chi2 =      0.0000
	(V_b-V_B is not positive definite)

It says that V_b-V_B is not positive definite, although chi2 is positive.   

I pretty much figure out what is going on.  In my re model i use dummies t1 t2 t3 t4 and t5 while 
in my fe model i use dummies t3 t4 t5 t6 t7.  This means that the two models have different sets 
of left-hand variables.  I did this on purpose to figure out why stata reported a postive chi2 but 
states that V_b-V_B is not positive .  

What I found is that   When stata states V_b-V_B are not positve definite, the variance-covariance 
matrix (V_b-V_B) that stata refers to is the varaiance-covariance matrix for ALL coefficients (in 
my case: t1 t2 t3 t4 t5 t6 t7 cadre membership  edu2 edu3 edu4).  Since in the re model, there 
are no variables t6 and t7; in the fe model there are no  t1 and t2.   This leads to v(b)-v(B) for ALL 
coefficients not positive definite.   However the variance-covariance matrix v(b)-v(B) that stata 
used for calculating chi2 is the one for the coefficients that appear in BOTH models (in my case: 
t3 t4 t5 cadre membership edu2 edu3 edu4).  This one is in fact positive definite.  I calculated 
the chi2 by hand using this variance-covariance matrix.  I got the exactly same chi2 as stata 
reported.  

In my real case, since I have so many dummies( about 400 ), when I do re regression or fe 
regressions, due to collinearity or other reasons,  some variables are droped.  This leads to that 
the two regressions do not have  a same set of left-hand variables.  Thus v(b)-v(B) for ALL 
coefficients  is not positive definite.  However, the v(b)-v(B) that stata uses for calculating Chi 
square is the variance covariance matrix of the coefficients that exist in both re and fe model.

Best regards, 
Jian 









> Jian Zhang,
> 
> Can you post the output of -hausman- to the list?  I think I know what
> might be going on, but it's easiest to see by looking at the output.
> 
> Cheers,
> Mark
> 
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu 
> > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of 
> > Rodrigo A. Alfaro
> > Sent: 19 July 2006 04:06
> > To: statalist@hsphsun2.harvard.edu
> > Subject: Re: st: RE: a question on testing for random effect 
> > model against fixed effect model
> > 
> > Is the Hayashi proof valid for unbalanced-panel?
> > R
> > 
> > ----- Original Message -----
> > From: "Jian Zhang" <jzh@ucdavis.edu>
> > To: "Schaffer, Mark E" <M.E.Schaffer@hw.ac.uk>; 
> > <statalist@hsphsun2.harvard.edu>;
> <statalist@hsphsun2.harvard.edu>
> > Sent: Monday, July 17, 2006 8:44 PM
> > Subject: RE: st: RE: a question on testing for random effect 
> > model against fixed effect model
> > 
> > 
> > Thanks, Mark!  It seems that the CALCULATED standard hausman 
> > test statistic is always positive even in FINITE samples 
> > (i.e., calculated V(b)-v(B) is positive definite) as long as 
> > one uses same variance estimates  (mathematically this is 
> > proved by Hayashi, 2000, as you
> > mentioned:
> > 
> > "This appendix proves that the Avar(q_hat) in (5.2.21) is 
> > positive definite and the Hausman statistic (5.2.22) is 
> > guaranteed to be nonnegative in any finite samples."
> > (Hayashi, Econometrics (2000), Appendix 5.A, pp. 346-349 and 334-335.)
> > 
> > So by adding option -sigmamore- or -sigmaless-, I did get a 
> > positive standard hausman test (Chi square).
> > 
> > However, confusing to me is that at the end of the results of 
> > implementing hausman test in stata there is one line saying  
> > (V(b)-V(B) is not positive definite) despite that I added option
> > -sigmamore- and got a positive Chi square.  Any thoughts why 
> > stata said that?  From what I understand, calculated 
> > V(b)-V(B) should be ALWAYS positive definite as long as one 
> > uses option
> > -sigmamore- or -sigmaless-.   The statement made by stata 
> > results seems to 
> > contradict the
> > mathematical argument made by Hayoshi.
> > 
> > Best regards,
> > Jian Zhang
> > 
> > > Jian,
> > >
> > > > -----Original Message-----
> > > > From: owner-statalist@hsphsun2.harvard.edu
> > > > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Jian 
> > > > Zhang
> > > > Sent: 16 July 2006 08:36
> > > > To: statalist@hsphsun2.harvard.edu
> > > > Subject: st: a question on testing for random effect 
> > model against 
> > > > fixed effect model
> > > >
> > > > Thanks, Clive and Rodrigo!
> > > >
> > > > I wonder if there is an alternative test for random 
> > effect against 
> > > > fixed effect or a robust form of hausman test if the assumptions 
> > > > made for Hausman test do not hold (one of the assumptions for 
> > > > hausman test is the homoskedasticity and uncorrelation of the 
> > > > idiosyncratic errors.
> > > > But this is often invalid.)
> > >
> > > Sorry to come in late on this, but I have three suggestions 
> > relating 
> > > to your original question.
> > >
> > > First, in a standard (i.e., non-robust) Hausman test, you can 
> > > guarantee a positive test statistic by using the -sigmamore- or 
> > > -sigmaless- options; the former is more traditional.  Second, 
> > > including the constant isn't traditional in a fixed vs. 
> > random effects 
> > > hausman test.  Third, if you want to do a heteroskedastic- or 
> > > cluster-robust version of the test, you can use the artificial 
> > > regression version of the test described in Wooldridge's 2002 book 
> > > (and I believe discussed in Statalist last year by Vince 
> > Wiggins, if 
> > > I'm not mistaken) and use robust or cluster-robust standard 
> > errors in 
> > > the artificial regression.  The artificial regression 
> > version will also guarantee a positive test statistic (of course!).
> > >
> > > Cheers,
> > > Mark
> > >
> > > Prof. Mark Schaffer
> > > Director, CERT
> > > Department of Economics
> > > School of Management & Languages
> > > Heriot-Watt University, Edinburgh EH14 4AS tel 
> > +44-131-451-3494 / fax 
> > > +44-131-451-3296
> > > email: m.e.schaffer@hw.ac.uk
> > > web: http://www.sml.hw.ac.uk/ecomes
> > >
> > >
> > > >
> > > > Jian
> > > >
> > > >
> > > > On Sat, 15 Jul 2006, Rodrigo A. Alfaro wrote:
> > > >
> > > > > Jian,
> > > > >
> > > > > Try -xtreg, re sa- instead of -xtreg, re- the additional
> > > > option takes
> > > > > care "more carefully" the unbalanced issue using 
> > Swamy-Arora method.
> > > > >
> > > > > Read Method and Formulas in the manual, for version 8:
> > > > > http://www.stata-press.com/manuals/stata8/xtreg.pdf and 
> > version 9:
> > > > > http://www.stata.com/bookstore/pdf/xtreg.pdf
> > > > >
> > > > > Rodrigo.
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Clive Nicholas" <Clive.Nicholas@newcastle.ac.uk>
> > > > > To: <statalist@hsphsun2.harvard.edu>
> > > > > Sent: Saturday, July 15, 2006 4:19 AM
> > > > > Subject: Re: st: a question on testing for random effect
> > > > model against
> > > > > fixed effect model
> > > > >
> > > > >
> > > > > Jian Zhang wrote:
> > > > >
> > > > > > I have a question on testing random effect model 
> > against fixed 
> > > > > > effect model. Hope that you can help me out. Here is the 
> > > > > > question;
> > > > > >
> > > > > > I am applying random effect model and fixed effect 
> > model to an 
> > > > > > unbanlanced panel data (use xtreg, re and xtreg, fe).  To
> > > > test which
> > > > > > model is more appropriate, I run a hausman test.
> > > > However, the test
> > > > > > statistics (the chi square) is negative. This makes
> > > > hausman testing
> > > > > > impossible, since chi square cann't be negative.  The reason 
> > > > > > that hausman test doesn't work is that the model's error
> > > > structure does
> > > > > > not meet the assumptions made for the hausman test.
> > > > >
> > > > > [...]
> > > > >
> > > > > Did you run the following:
> > > > >
> > > > >  xtreg ..., fe
> > > > >
> > > > >  est store fixed
> > > > >
> > > > >  xtreg ..., re
> > > > >
> > > > >  hausman fixed ., alleqs constant
> > > > >
> > > > > If not, see if that works. Works for me every time I 
> > have to use it.
> > > > >
> > > > > CLIVE NICHOLAS        |t: 0(044)7903 397793
> > > > > Politics              |e: clive.nicholas@ncl.ac.uk
> > > > > Newcastle University  |http://www.ncl.ac.uk/geps
> > > > >
> > > > > Whereever you go and whatever you do, just remember this. No 
> > > > > matter how many like you, admire you, love you or adore 
> > you, the 
> > > > > number of people turning up to your funeral will be largely
> > > > determined by local
> > > > > weather conditions.
> > > > >
> > > > > *
> > > > > *   For searches and help try:
> > > > > *   http://www.stata.com/support/faqs/res/findit.html
> > > > > *   http://www.stata.com/support/statalist/faq
> > > > > *   http://www.ats.ucla.edu/stat/stata/
> > > > > *
> > > > > *   For searches and help try:
> > > > > *   http://www.stata.com/support/faqs/res/findit.html
> > > > > *   http://www.stata.com/support/statalist/faq
> > > > > *   http://www.ats.ucla.edu/stat/stata/
> > > > >
> > > > *
> > > > *   For searches and help try:
> > > > *   http://www.stata.com/support/faqs/res/findit.html
> > > > *   http://www.stata.com/support/statalist/faq
> > > > *   http://www.ats.ucla.edu/stat/stata/
> > > >
> > > >
> > >
> > > *
> > > *   For searches and help try:
> > > *   http://www.stata.com/support/faqs/res/findit.html
> > > *   http://www.stata.com/support/statalist/faq
> > > *   http://www.ats.ucla.edu/stat/stata/
> > >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> > 
> > 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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