Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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 <[email protected]>
To   [email protected]
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
<[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index