Statalist The Stata Listserver


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

st: RE: predicting (ui) after( xtivreg2) ?!


From   "Schaffer, Mark E" <[email protected]>
To   <[email protected]>
Subject   st: RE: predicting (ui) after( xtivreg2) ?!
Date   Fri, 13 Apr 2007 16:38:18 +0100

Ahmed,

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Al-Darwish, Ahmed
> Sent: Friday, April 13, 2007 3:44 PM
> To: [email protected]
> Subject: st: predicting (ui) after( xtivreg2) ?!
> 
> Dear Mark;
> Here is what I'm doing:
> 1- center y x1 x2 x3 iv1 iv2:=: c_y c_x1 c_x2 c_x3 c_iv1 c_iv2
>  
> 2- xtivreg2 c_y c_x1 c_x2 (c_x3=c_iv1 c_iv2), fe ro
>  
> 3- predict eps,e
>  
> 4- matrix beta=e(b)'
>  
> 5- matrix beta2=beta["c_x1" "c_x2" "c_x3",1]'
>  
> 6- matrix score yhat=beta2
>  
> 7- ui=c_y -yhat- eps  
>  
> I have tried to use c_eps or (y)-not centerlized too but the 
> same.,, results?!

I think I worked out a better way to do it than in my original posting.

Here's an example.  Try it with your data.

*******************************

* How to get the estimated u_i (fixed effects) from xtivreg2

sysuse abdata, clear

* Estimate and save coefficients
xtivreg2 n yr1980 (w=k ys), fe
mat b=e(b)

* Get v_it residual using a consistent sample
predict double v_it if e(sample), e

* Get "predicted values"
* Will be wrong by the unestimated constant
* so center it using Ben Jann's -center- command
mat score double yhat_it = b if e(sample)
center yhat_it if e(sample)

* Get u_i
gen double u_i = n - c_yhat_it - v_it

* Compare with official xtivreg

xtivreg n yr1980 (w = k ys), fe
predict double v_it2 if e(sample), e
predict double u_i2 if e(sample), u

pwcorr v_it v_it2
pwcorr u_i u_i2

*******************************

> Any comments will be appreciated it...
> Cheers;
> Ahmed
> 
> ________________________________
> 
> From: [email protected] on behalf of 
> Schaffer, Mark E
> Sent: Fri 4/13/2007 1:46 PM
> To: [email protected]
> Subject: st: RE: RE: RE: predicting (ui) after( xtivreg2) ?!
> 
> 
> 
> Ahmed,
> 
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of 
> Al-Darwish, 
> > Ahmed
> > Sent: Friday, April 13, 2007 1:26 PM
> > To: [email protected]
> > Subject: st: RE: RE: predicting (ui) after( xtivreg2) ?!
> >
> > Dear Mark,
> >   I did what you have suggested to predict (ui)..but I 
> couldn't get a 
> > fixed value over time  like what xtivreg does?!
> > Would there be any other way to make it obtaining an 
> individual effect 
> > that is constant over time period.?!
> 
> Can you show us the code and perhaps we can figure out why it 
> didn't generate what you wanted?
> 
> --Mark
> 
> > Any comments will be appreciated?!
> > Cheers;
> > Ahmed
> > ________________________________
> >
> > From: [email protected] on behalf of 
> Schaffer, Mark 
> > E
> > Sent: Wed 3/28/2007 4:59 PM
> > To: [email protected]
> > Subject: st: RE: predicting (ui) after( xtivreg2) ?!
> >
> >
> >
> > Ahmed,
> >
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf Of
> > Al-Darwish,
> > > Ahmed
> > > Sent: Wednesday, March 28, 2007 1:05 PM
> > > To: [email protected]
> > > Subject: st: predicting (ui) after( xtivreg2) ?!
> > >
> > > Dear StataListers;
> > > Is there a way to predict the values of (ai)s or(ui)s 
> after running
> > > (xtivreg2) in a fixed effect -panel model?
> >
> > Official -xtivreg- uses the terminology u_i and v_it, and the
> > -xtivreg2- help file refers to v_it.  -xtivreg2- will 
> predict a v_it 
> > but not a u_i.
> > I assume that your ai and ui mean the same thing as u_i.
> >
> > The problem is that -xtivreg2- doesn't estimate a 
> coefficient for the 
> > constant.
> >
> > Maybe this is easy?
> >
> > Put all your variables (including the IVs) into mean-deviation form 
> > using Ben Jann's -center- command.  Make sure you center using a 
> > consistent sample.  Estimating on mean-deviation data 
> should give you 
> > the same coefficients as estimating on the raw data (a 
> useful check to 
> > make sure you've got the centering done correctly).
> >
> > Use -predict- to get the v_it.
> >
> > Use -matrix score- to get the fitted values yhat_it of your 
> demeaned 
> > dependent variable.
> >
> > The u_i will be y_it - yhat_it - v_it.
> >
> > Or am I missing something here?
> >
> > --Mark
> >
> > > Many Thanks;
> > > Ahmed
> > >
> > >
> > >
> > >
> > >
> > > *
> > > *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index