Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Collecting R2 results when running a do-file


From   Tim Wade <wadetj@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Collecting R2 results when running a do-file
Date   Fri, 14 Sep 2012 09:12:33 -0400

One way to do this is with -postfile- (see help postfile)

for example:

sysuse auto.dta, clear
tempname memhold
tempfile results
postfile `memhold' str10 model r2 using `results', replace
foreach var of varlist price  length mpg{
reg weight `var'
post `memhold' ("`var'" ) (e(r2))
}
postclose `memhold'
use `results', clear
list

. list

     +-------------------+
     |  model         r2 |
     |-------------------|
  1. |  price   .2901023 |
  2. | length   .8949323 |
  3. |    mpg   .6515313 |
     +-------------------+




Tim



On Fri, Sep 14, 2012 at 8:47 AM, Amanda Wilford
<awilford@rhsmith.umd.edu> wrote:
> I am running the following do file for over 200 different regressions with multiple years. What command should I use to collect all of the r2s associated with these regressions?
>
> use "/Users/amandawilford/Desktop/CR.dta"
> drop if fyear<2003
> drop if fyear>2003
> drop if ind48>1
> drop if ind48<1
> reg itotal lsl_gr l1leverage l1cash lAge l1size lstret litotal l1e_index wpeg
> predict rr1, res
> reg itotal lsl_gr l1leverage l1cash lAge l1size lstret litotal wpeg
> predict rr3, res
> reg itotal lsl_gr l1leverage l1cash lAge l1size lstret litotal
> predict rr5, res
> save "/Users/amandawilford/Desktop/Efficieny/e3/2003 ind1.dta"
>
>
> Amanda L. Wilford
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index