Statalist The Stata Listserver


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

Re: st: How do I save fixed panel effects as a variable


From   "Ada Ma" <heu034@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How do I save fixed panel effects as a variable
Date   Fri, 31 Mar 2006 00:22:57 +0100

i have done something similar recently - i ran a model with roughly
400 dummies.  you said you're using fixed effects and used the -xtreg-
command.  but this isn't necessary as you already have i.permno.  if I
understand it correctly, running fixed effects is equivalent to having
a constant term for each of the group within permno.  therefore i
suggest that you use:

xi: reg btm i.permno r0ret r1ret r2ret r3ret r4ret r5ret r6ret i.yeara
matrix permno_coeff=e(b)'
svmat permno_coeff
outfile permno_coeff if _n<=499 using permno.out, c replace

i have no idea whether your permno variable is in sequence or not.  if
it is, then you might want to write:
gen count=_n
outfile count permno_coeff if _n<=499 using permno.out, c replace

note that i put the i.permno in front, so that the first 499
coefficients (500 - 1 for the ref group) would be the those that
corresponds to the permno's.  the OUT file can be easily read back
into Stata.  as long as you don't sort the data between you do the
-svmat- and the -outfile- commands, the coefficients will stay in
sequence.

hope this helps!


On 3/30/06, Amy Dunbar <Amy.Dunbar@business.uconn.edu> wrote:
> I have a balanced panel data set.  I estimate the model of book to
> market on the current year stock return and 6 lagged returns.
>
> tsset permno yeara
>         panel variable:  permno, 10051 to 92655
>         time variable:  yeara, 1993 to 1998
>
> xi: xtreg  btm r0ret r1ret r2ret r3ret r4ret r5ret r6ret i.yeara
> i.permno
>
> I would like to save the fixed effect for each group variable (the
> b[_Ipermno_90537] for all permnos) under a common variable name
> (conmkt), so I can use the effect in another regression.
>
> I then unsuccessfully tried
>
> statsby "xi: xtreg  btm r0ret r1ret r2ret r3ret r4ret r5ret r6ret
> i.yeara i.permno" _b, by(permno)
>
> rename b_[i.permno] conmkt
>
> The estimation results were as follows:
> command:      xi: xtreg btm r0ret r1ret r2ret r3ret r4ret r5ret r6ret
> i.yeara i.permno
> statistics:   b_r0ret    = _b[r0ret]
>               b_r1ret    = _b[r1ret]
>               b_r2ret    = _b[r2ret]
>               b_r3ret    = _b[r3ret]
>               b_r4ret    = _b[r4ret]
>               b_r5ret    = _b[r5ret]
>               b_r6ret    = _b[r6ret]
>               b__Iy~1994 = _b[_Iyeara_1994]
>
> And on and on for the remaining firms.
>               b__I~90537 = _b[_Ipermno_90537]
>               b__I~90879 = _b[_Ipermno_90879]
>
>               b__I~91380 = _b[_Ipermno_91380]
>               b__I~92655 = _b[_Ipermno_92655]
>               b_cons     = _b[_cons]
> by:           permno
> too many options
>
> Stata limits the options to 50 and I have more around 500.
>
> I also tried:
>
> xi: xtreg  btm r0ret r1ret r2ret r3ret r4ret r5ret r6ret i.yeara
> i.permno
> estimates store fixed_group
> gen conmkt = _b[i.permno]
>
> But that failed also.  Obviously I don't know what I am doing.  I had a
> PhD student who was able to do this in SAS, so I know I should be able
> to do it in Stata.  I am using Stata SE 8 for Windows.  Thank you.
>
> Amy Dunbar
> University of Connecticut
> School of Business
> Department of Accounting
> 2100 Hillside Road, Unit 1041
> Storrs, CT 06269
>
> amy.dunbar@business.uconn.edu
> cell: 860-208-2737
>
>
> *
> *   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/
>


--
Ada Ma
Research Fellow
Health Economics Research Unit
University of Aberdeen, UK.
http://www.abdn.ac.uk/heru/
Tel: +44 (0) 1224 553863
Fax: +44 (0) 1224 550926

*
*   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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index