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: Storing regression coefficient estimates


From   "Roger B. Newson" <[email protected]>
To   [email protected]
Subject   Re: st: Storing regression coefficient estimates
Date   Fri, 20 Jul 2012 11:44:32 +0100

This looks like a job for the -parmest- package, which is downloadable from SSC, and which stores regression coefficients in output datasets (or resultssets). These resultssets can then be concatenated, subsetted and plotted in whatever way the user needt to do.

I hope this helps.

Best wishes

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.

On 20/07/2012 11:21, Braunfels, Philipp (Stud. SBE / Alumni) wrote:
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/

*
*   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