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

Re: st: sorted rolling regresion

From   "Scott Merryman" <>
Subject   Re: st: sorted rolling regresion
Date   Mon, 4 Feb 2008 18:37:48 -0600

On Feb 4, 2008 5:50 PM, William Bishop <> wrote:
> Scott and Austin:
> Thank you both for your help with the rolling regression.  That did
> what I was hoping to accomplish.
> BTW, when I modified Scott's code to be time<`i' instead of time<=`i'
> it stopped making predictions.  I assume that has to do with the
> e(sample) line,  which I am unfamiliar with - will have to look into
> that.

It is tied to the -if e(sample)-.  This condition restricts the
predictions to the estimation sample.

In my example, it not generating the one-step ahead prediction, which
is what I think you want but the fitted value for the last observation
of the estimation sample.  It could modified to generate the one-step
ahead prediction as:

webuse grunfeld,clear
qui {
gen predict = .

levelsof com, loc(levels)
foreach l of local levels {
forv i =  5/20 {
       reg invest kstock if com == `l' & time <`i'
       predict foo if com == `l' & time <=`i'
       replace predict = foo if com == `l' & time == `i'
       drop foo

*   For searches and help try:

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