Thanks Scott. You are correct, I was looking for the one-step ahead
prediction. Austin had provided it already, but I wanted to
understand your code also, so I appreciate the explanation for why it
wasn't making predictions when I made that adjustment.
William
On Feb 4, 2008 4:37 PM, Scott Merryman <[email protected]> wrote:
> On Feb 4, 2008 5:50 PM, William Bishop <[email protected]> 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
> }
> }
> }
>
>
> Scott
> *
>
> * 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/
>
*
* 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/