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

Re: st: Re: how to create "R2" as a variable


From   Ulrich Kohler <kohler@wz-berlin.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: how to create "R2" as a variable
Date   Wed, 16 Nov 2005 08:59:04 +0100

mindy.nitkin@simmons.edu 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

-- 
kohler@wz-berlin.de
+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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index