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]

From |
"Braunfels, Philipp (Stud. SBE / Alumni)" <P.Braunfels@student.maastrichtuniversity.nl> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: run regression IF certain condition is given |

Date |
Fri, 27 Jul 2012 10:58:49 +0200 |

Dear Statlisters, I have the following question: I want to run a regression for a company over a number of rolling windows (window=24 months e.g. :01/2000-12/2002, 02/2000-01/2003, 03/2000-02/2003 ...), ONLY IF the y variables (=return) of each observation (company) are available for the FULL regression window. The reason why I need all data for the 24 month is, that I have an unbalanced panel and for some companies, especially in the beginning years, data are missing and thus the regression does not work. My regression code for the 24-month window looks as follows (does not account for the fact that the data on x-variable have to be available for the respective 24-months, yet): forvalues k = 1/1000 { ///Defines ID of each company matrix E = (0,0,0) /// Matrix to safe regression coefficient estimates forvalues i=528/627{ /// define time-window (my sample period) quietly reg return x1 if (id==`k' & month>=`i'-24 & month<`i'), r ///regress return of comp "i" on x1 for a rolling window of 24 months matrix E = E\(`i',_b[msciwde], _se[msciwde]) ///save results to matrix } } [/code] Now I would like to achieve the following: For each ID check IF return <. for the time period wheremonth>=`i'-24 & month<`i' IF so, run the regression if not, check (for the same ID), whether for the next time window all data on -return- are available (i.e. month>=(`i'+1)-24 & month<(`i'+1)) ----do this for all time windows of an ID and then go to the next ID I am very thankful for any help!!! * * 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/

- Prev by Date:
**st: From: sabbas gidarokostas <sabbasgidarokostas@googlemail.com>** - Next by Date:
**st: scale axis in -cabiplot-** - Previous by thread:
**st: From: sabbas gidarokostas <sabbasgidarokostas@googlemail.com>** - Next by thread:
**st: scale axis in -cabiplot-** - Index(es):