[email protected] wrote:
> I am trying to construct an earnings quality metric based on the R2 from
> firm specific regressions of returns on accounting values. I know how to
> run the firm specific regressions. I am wondering if it possible to create
> a variable from the R2 values that result from the regressions.
Some variant of the following might work:
. gen r2 = .
. local i 1
. levelsof firm, local(K)
. foreach k of local K {
. regress yvar xvarlist if firm == `k'
. replace r2 = e(r2) in `i++'
. }
Or see -help post-, if you want to store the R2-values in a separate file.
Regards
Uli
--
[email protected]
+49 (030) 25491-361
*
* 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/