* * Autocorrelations from page 38 * calendar(q) 1947:2 * open data ch02_usgnp_q(47-91).txt data(format=free,org=columns) 1947:2 1991:1 rgnp * spgraph(vfields=1,footer="Figure 2.5 Time Plot of US Quarterly Real GNP") graph(vlabel="growth") # rgnp spgraph(done) * linreg rgnp # constant rgnp{1 2 3} * * %EQNLAGPOLY extracts the lag polynomial from an equation or (if its first * argument is zero) from the last run regression. The second argument is the * variable whose lag polynomial is extracted. Because ggnp is the dependent * variable in the equation, you get the left side polynomial in the third-order * difference equation on page 34. %POLYCXROOTS then computes the roots of that * polynomial. Since we don't know which will be the complex roots (if there are * any), we need to display them before the next step. (The roots are ordered by * their absolute values) * compute croots=%polycxroots(%eqnlagpoly(0,rgnp)) disp croots * * The 2nd and 3rd roots are complex. The cycle length can be obtained by the * following - the %arg function returns the inverse tangent (in radians) of b/a * for the complex number a+bi. We'll work with the 2nd root, since it will give a * positive value for the cycle length. The 3rd root will give the negative of * this value. * disp "Average Length of Cycles" 2*%pi/%arg(croots(2))