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

st: sorted rolling regresion

From   "William Bishop" <>
Subject   st: sorted rolling regresion
Date   Sat, 2 Feb 2008 11:47:56 -0800

I'm trying to do a rolling regression by id that regresses on previous
dates and then gets the prediction for the current observation.

The code below does the regressions but the predictions are not made
after each regression but only after the final regression.  So what
winds up happening is that all the predictions are based off the final

forval i = 3/`Max' {
			bys id (date) : regress varlist if _n < `i'
			predict temp, xb
			bys id (date) : replace p1 = temp if _n == `i'
			drop temp		

I'm looking to have the predictions made after each regression.  Can
this be done using bys?

*   For searches and help try:

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