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: Looping Regression with Estimates Extraction


From   Alberto Dorantes <[email protected]>
To   [email protected]
Subject   Re: st: Looping Regression with Estimates Extraction
Date   Wed, 25 Apr 2012 08:19:19 -0500

Hi Rohit:
   You might solve your problem using the rolling prefix before the
regress command. Check "help rolling".

Another way is doing something like:

summarize company_id
forvalues i=1/`r(max)' {
   capture reg ret_company ret_market if company_id==`i'
   if _rc!=0 {
     display "Error when regressing company "`i'
   }
else {
   estimates store result`i'
}
}
su company_id
local results ""
forvalues i=1/`r(max)' {
    local results `results' result`i'
}
xml_tab `results' "C:\Results\Results.xls", replace pvalues below
stars(0.02 0.05 0.10) sheet("REsults...") stats(N r2_a) title (My
results)

The xml_tab command sends your results to an Excel file, where you can
manipulate later.
I'm  not sure whether xml_tab is a Stata or a user command. If you do
not have it, just type "findit xml_tab" and install it.

Regards... Alberto.


2012/4/25  <[email protected]>:
> Hello StataList,
>
> I am unfamiliar with programming in Stata, hence the need for assistance. I have a long panel dataset of daily prices of different companies from 1990 to 2010. I am trying to understand how I can run a regression of the daily stock return (y) on, say, stock index return (x) on a daily basis using only the last 1000 observations or so? I would like to loop this regression daily, while also able to extract, to a column in the data file, some estimates like the R-squared, Root MSE, etc.
>
> Any help on this would be greatly appreciated.
>
> Thanks!
> Rohit
> *
> *   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