******************************************************* * Example of a regression with a moving window * * Create some dummy data sample 1 40 genr Y=time(0) genr X=uni(Y) * Specify number of regressions gen1 min=1 gen1 max=20 * Set the number of exogenous variables (X plus a constant = 2) gen1 vars = 2 * Dimension somewhere to store the coefficients dim allcoef max vars * Do max-min regressions with a moving window do(#=min,max) * Set our sample window range gen1 winmin=min+#-1 gen1 winmax=max+#-1 samp winmin winmax * Do a regression (or another SHAZAM technique) ols Y X / coef=olscoef * Transpose the coefficients and copy to storage matrix matrix tolscoef=olscoef' copy tolscoef allcoef / frow=1;1 trow=#;# endo * Print out the coefficients from the storage matrix print allcoef