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: Finding the biggest R squared when estimating market-betas


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: Finding the biggest R squared when estimating market-betas
Date   Wed, 18 Aug 2010 03:44:42 +0000

<>

Here's a method to write the R2s to a text file, read them back into Stata, take the mean of r2 by DV, and compare them:

**************!
**1. setup**
sysuse auto, clear
	**DVs**
	rename turn nasdaq
	rename length sp500
	rename price nasdaq2
local dvs nasdaq sp500 nasdaq2


**2. run regressions, save r2 to file**
cap file close myfile
file open myfile using myfile.txt, replace text write
file write myfile "DV"  _tab  "MODEL" _tab "R2" _n
foreach d in  `dvs'  {
**use tuples to run many regressions**
cap which tuples
if _rc ssc install tuples, replace
tuples  mpg rep78 headroom trunk weight displacement gear_ratio foreign
forval i = 1/`ntuples'{
   qui  regress `d'  `tuple`i''
	file write myfile "`d'" _tab "`e(cmdline)'" _tab "`e(r2)'" _n
	}
}
file close myfile

**3. read file back into Stata**
clear
insheet using myfile.txt, tab names

**4. compare avg r2 across dvs**

bys dv: su r2  

**5. graphically**
bys dv: egen avgr2 = mean(r2)
foreach dv in `dvs' {
	qui su r2 if dv=="`dv'", d
	local mean:di %06.4f `r(mean)'
hist r2 if dv=="`dv'", xmtick(##2, labels)  note(Model:  `dv') ///
xline(`mean', lwidth(thick) lpattern(dash) lcolor(green))   name(g_`dv', replace) ///
text(5 `=`mean'-.1'  "Mean=`mean'",  orient(horizontal) si(medsmall) justification(center) box ) 
	local g g_`dv' `g'
}
gr combine `g' , rows(3)

**6. collapse & compare**
collapse (mean) AVG_R2 = r2, by(dv)
li
**************!

Alternatively, you could probably get -estout- or -outreg2- from SSC to create a table of your r2 values for comparison.

~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754


On Aug 17, 2010, at 2:24 PM, Mihai-Andrei Popescu-Greaca wrote:

> Dear all,
> 
> I'm carrying out an event study and when regressing the stock return against
> the market return (for 85 different stocks) I want to choose the market
> return that yields the greatest R sqaured (best estimator).
> How can make Stata show me the "mean" or "median" R squared for the 85
> regressions.
> 
> Example:
> I regress the 85 stocks against the NASDAQ Compostite and for each
> regression I get an R squared.
> I regress the 85 stocks againgst the S&P 500 and for each regression I get
> an R squared.
> How do I build the "mean" or "median" R squared from the regression against
> the NASDAQ and compare it with the "mean" or "median" R squared from the
> regression against the S&P 500?
> 
> I would appreciate your help!
> Best regards,
> Mihai
> 
> *
> *   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