Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: multiple rolling regressions


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: multiple rolling regressions
Date   Wed, 14 May 2008 10:15:56 -0400

Erasmo Giambona <e.giambona@gmail.com>:

Is this the kind of setup you are talking about?  Firms with id number
higher than 5918 present no problem.

clear
range year 1980 2005 26
expand 6000
bys year: g firm=_n
g y=uniform()
g x=uniform()
tsset firm year
sort firm year
g double d=.
qui forv i=3/`=_N-2' {
 loc f=`i'-2
 loc l=`i'+2
 if firm[`f']==firm[`i'] & firm[`l']==firm[`i'] {
  cap reg y year in `f'/`l' if firm==firm[`i']
  if _rc==0 {
   if e(N)>2 {
    predict double ye if e(sample), resid
    reg x year in `f'/`l' if firm==firm[`i']
    predict double xe if e(sample), resid
    reg ye xe
    replace d=_b[xe] in `l'
    drop ye xe
   }
  }
 }
}
li, noo sepby(firm)
g ok=d<.
tab year ok
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index