SHAZAM Community
Ask Your Question

How do you create a moving window with a constant width?

asked 2011-03-12 09:03:23 +0000

updated 2011-03-22 17:17:22 +0000

David gravatar image

A SHAZAM User asked:

I wonder whether it is possible to do a series of estimations in SHAZAM in the following way (an example describes the problem).

Example: Let say you have a total of 40 observations, and want to use a MOVING SUB-SAMPLE with a fixed size (moving window with constant width), let say 20 observations, in each estimation.

The first sample includes observation 1 to 20. The next sub-sample consists of observation 2 to 21, the third from 3 to 22 etc., and the last includes observation 20 to 40. Then you can do 20 regressions by using this moving window of fix sample size. Is it possible to do this kind of estimation without doing 20 separate regressions manually 20-times?

And output: Is it possible to store (save) the estimated 20 coefficients in a file, and to print them? Let say you want to estimate an AR(1)-model: y(t+1) = constant + (coefficient)y(t) + residual(t), and you want a file with two columns which stores 20 estimated constants and coefficients.

It is of great help if you could look at the problem. I look forward to hearing from you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2011-03-16 11:37:36 +0000

ken gravatar image

updated 2011-03-16 11:46:58 +0000

* Moving Sample Size, 20 Observations at a time
* Save coefs in separate variables
sample 1 40
* create some fake data
genr x=time(0)
genr y=nor(1)
* start moving window
do #=1,21
gen1 end=#+19
sample # end
print y x
ols y x / coef=c#
print c1-c21
edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2011-03-12 09:03:23 +0000

Seen: 389 times

Last updated: Mar 16 '11