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

Re: st: multiple rolling regressions

From   "Austin Nichols" <>
Subject   Re: st: multiple rolling regressions
Date   Wed, 14 May 2008 10:15:56 -0400

Erasmo Giambona <>:

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

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:

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