* * AR model from pp 41 * calendar(m) 1926 * * The VW data are simple returns * open data ch02_vw_m(26-97).txt data(format=free,org=columns) 1926:1 1997:12 vwsmp * * The YuleLags procedure analyzes a set of AR(p) models using the Yule-Walker * equations to estimate the residual variances. This is a very efficient way to * analyze a whole series of such models. * @yulelags(max=10) vwsmp * linreg vwsmp # constant vwsmp{1 2 3} * * The 1-%beta(2)-%beta(3)-%beta(4) divisor can be obtained (more flexibly), by * using the %EQNLAGPOLY function to pull out the lag polynomial for the dependent * variable of the AR, and then evaluating it at 1.0. By using this, you can * change the number of lags in the AR without having to rewrite the code to do * this calculation. * compute meanret=%beta(1)/%polyvalue(%eqnlagpoly(0,vwsmp),1.0) disp "Mean Return" meanret * * The REGCORRS instruction is designed to do the diagnostic checking of a time * series model by examining the residual autocorrelations. The DFC option is for * correcting the degrees of freedom of the Q statistic - it should be equal to * the number of estimated AR (or AR+MA) parameters. * @RegCorrs(dfc=3,number=10,report,title="AR(3) Model") * * Try an AR(5) model * linreg vwsmp # constant vwsmp{1 to 5} compute meanret=%beta(1)/%polyvalue(%eqnlagpoly(0,vwsmp),1.0) disp "Mean Return" meanret @RegCorrs(dfc=5,number=10,report,title="AR(5) Model")