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]

st: Storing regression coefficient estimates


From   "Braunfels, Philipp (Stud. SBE / Alumni)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Storing regression coefficient estimates
Date   Fri, 20 Jul 2012 12:21:00 +0200

Dear Statlisters,
I have an unbalanced panel dataset and want to do a two-stage regression.
I want to run individual (by panelvar) time series regressions (rolling time frame) and store the estimates of each coefficient in a new variable. With "rolling time frame" I mean that the coefficients in period t are estimated based on values from period t-24 to t (that is, on the prior 24 months of data).
 My set starts in month 476 and contains 120 months of data. My approach looks as follows but I just do not get how to store the estimates and define the correct time frame (according to "help reg" the coefficients are stored in a vector e(b)): 

[ID= panelvar, month=timevar] 

gen beta_x1=0
gen beta_x2=0
gen beta_x3=0
gen intercept=0

*define time frame
forvalues i=500/596{   

*define separate regressions for each firm in my panel
quietly levelsof ID ,l(lvls)
foreach l of loc lvls {
    quietly reg y x1 x2 x3, vce(robust) if (ID == "`l'" & month>`i'-24 & month<`i'+1), vce(robust)  **** -& month>`i'-24 & month<`i'+1- is intended to capture the rolling window of 24 months

*store coefficients
    replace beta_x1= "coefficient_x1" if (ID == "`l'" & month==`i'+1)
    replace beta_x2="coefficient_x2" if (ID == "`l'" & month==`i'+1)
    replace beta_x2="coefficient_x3" if (ID == "`l'" & month==`i'+1)
    replace intercept="_constant" if (ID == "`l'" & month==`i'+1)
}  
}

 Can someone help me 
(i) how do I correctly specify that the regression is estimated for a rolling window of 24 months (which I did above by writing -& month>`i'-24 & month<`i'+1-) , i.e. the coefficients for month 501 are estimated based on the values from months 476-500, the coefficients for 502 are estimated from months 477-501 and so on...
 (ii) how can I specify that only the coefficient of x1, x2 or x3 is stored (I just wrote "coefficient_x#")

I am very very thankful for any help and greatly appreciate your time!
*
*   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