| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: obtaining coefficient after using the regress command
Simo wrote:
I have a dataset that have 5 year observations for 100 firms: hence I have
a panel data. I want to run a OLS regression with dummy variabler for 100
firms. After doing that, I want to obtain the coefficients of dummy
variables and use them in the other regression model as a dependent
variable. How can I retrieve these dummy varaible coefficients after running
OLS?
This is like a fixed effects model where the firms are the units for
which fixed effects are computed.
Instead of explicitly including the firm dummies as regressors you could
also run a fixed effects model:
xtreg y x1..xn, fe i(firmid)
where "firmid" is your firm identificator variable.
And then you can recover the firm effects by
predict firmeffect, u
And that gives you your variable to use in further regressions.
The alternative with OLS and explicit firm dummies, is possible, too.
You can recover the coefficients in the following way.
Code your firm ID in integers from 1 to 100 if it is not yet coded like this
This can be done by:
sort firmid
egen newfirmid=group(firmid)
(Do this on the sample of firms that are included in the regression.)
Then
tab newfirmid, gen(f)
gives you firm dummies called f1, f2, ... f100.
Then you can try:
regress y x1 ... xn f1 .. f100, noc
gen firmeffect=0 if e(sample)
foreach i of numlist 1/100{
replace firmeffect=_b[f`i'] if newfirmid==`i'
}
The variable firmeffect now includes the values of the coefficients on
your firm dummies.
It will be essentially the same than the one predicted after xtreg. The
two will be perfectly correlated and have the same standard deviation,
they will just be differ by an constant because xtreg normalises the
effects to a mean of zero.
Hope that helps.
Thomas
*
* 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/