# st: Re: Beginner needs help trying to run rolling regressions in STATA 8 (in windows)

 From "Michael Blasnik" <[email protected]> To <[email protected]> Subject st: Re: Beginner needs help trying to run rolling regressions in STATA 8 (in windows) Date Wed, 2 Jun 2004 12:26:03 -0400

```I wrote an ado back in 1999 (Stata v6) that does rolling regressions and
fills in the predicted value for each point.

program define rollpred
version 6.0
syntax varlist , [begin(int 200) end(int 10)] gen(str)
confirm new var `gen'
gen `gen'=.
tempvar pred
local obs=_N
local i=1
local j=`i'+(`begin'-`end')
local n=`i'+`begin'
quietly {
while `j'<`obs' {
reg `varlist' in `i'/`j'
cap drop `pred'
predict `pred' in `n'
replace `gen'=`pred' in `n'
local i=`i'+1
local j=`j'+1
local n=`n'+1
}
}
end

For each datapoint, it does a regression on the points starting "begin"
points before it and ending "end" points before it.  It then uses predict to
get a prediction for the current point.  You could use this as a start for
what you want to do.

Michael Blasnik
[email protected]

----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Wednesday, June 02, 2004 11:08 AM
Subject: st: Beginner needs help trying to run rolling regressions in STATA
8 (in windows)

> I am trying to run rolling regressions with quarterly GDP.  I am trying to
> use a ten year window to start then add and drop one year, etc.  I have
> been all over the manuals and internet and have not had any success
finding
> commands/code/ado files to assist me.  Thanks in advance for any direction
> you can offer.
>

*
*   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/
```

• References: