Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: -xtdata- + retain untransformed variables?


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: -xtdata- + retain untransformed variables?
Date   Wed, 29 Jan 2003 18:21:31 -0600

----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Wednesday, January 29, 2003 2:56 AM
Subject: st: -xtdata- + retain untransformed variables?


> Thank you Scott,
>
> I found where my problem was. Another little question concerning xtdata,fe:
>
> When I use it on the panel data set I want to regress afterwards, the <year>
> variable is transformed, too. I can recover the old values using -int-, but
> this does not seem the safest way to me. Is there a way of applying -xtdata-
> to only a part of the dataset, and to retain some other variables (such as
> <year>) in it?

No.  However you could transform that data, save it as another data set and then
merge to obtain the year variable.

Or you could do the transformation by hand, such as:

clear
use "C:\Stata8\grunfeld.dta", clear
*Create group means
bysort comp:egen inv_m = mean(inv)
bysort comp:egen mva_m = mean(mva)

*Create overall mean
egen mva_m2 = mean(mval)
egen inv_m2 = mean(invest)

*Demean variables
gen de_inv = invest - inv_m + inv_m2
gen de_mva = mvalue - mva_m + mva_m2
reg de_inv de_mva

*Compare to xtreg, fe
xtreg invest mval,fe

Keep in mind, that your standard errors will be too small.  Is there a reason
you cannot use dummy variables?


Scott


*
*   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