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

Re: st: sorted rolling regresion

From   "Austin Nichols" <>
Subject   Re: st: sorted rolling regresion
Date   Mon, 4 Feb 2008 16:21:05 -0500

William Bishop <>:
Scott's code does not make my mistake of leaving a condition off -predict-:

webuse grunfeld, clear
su time, meanonly
loc Max=r(max)
levelsof com, local(is)
g p1=.
foreach i of local is {
 forval t = 3/`Max' {
 qui reg mval kst if com==`i'&time<`t'
 predict temp, xb
 qui replace p1=temp if com==`i'&time==`t'
 drop temp
li time p1 mval kst, sepby(com) noo

but note (still) that the predictions may make no sense.  You may
prefer a different flavor of  regression, depending on what you are
going to use this for...

On Feb 4, 2008 4:06 PM, Scott Merryman <> wrote:
> On Feb 2, 2008 1:47 PM, William Bishop <> wrote:
> > I'm trying to do a rolling regression by id that regresses on previous
> > dates and then gets the prediction for the current observation.
> No, but you can loop over the groups.  Perhaps, something like this will help:
*   For searches and help try:

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