* * Example BIGQTR.DAT from pp 179-186 * open data bigqtr.dat * * While not defined in the data set, we're going to give this a starting date of * 1995. * cal(q) 1995 data(format=free,org=columns) 1 16 bigqtr * * The four quarter centered MA can be done with FILTER with TYPE=CENTERED and * WIDTH=4, which results in exactly the computation shown in table 5-1. * filter(type=centered,width=4) bigqtr / tc set percentma = bigqtr/tc print(picture="*.###") / bigqtr tc percentma * * There's a procedure called ClassicalDecomp which does all this analysis, but * we'll show how the steps are done. * * SEASONAL creates a seasonal dummy series. Regressing the percentma series on a * full set of dummies (obtained by using lags 0 to -3 (that is, leads 0 to 3) of * it) gets the averages for each quarter. The regression coefficients are in the * vector %BETA which is defined by LINREG. We display the value for the sum of * these. * seasonal(span=4) sdummy linreg percentma # sdummy{0 to -3} disp "Sum of seasonal factors" %sum(%beta) * * This rescales %beta to have a sum of 4. * compute %beta=%beta*4.0/%sum(%beta) * * We get the seasonal by repeating the appropriate quarterly values in %BETA. The * quarter of period "t" (or month if this were monthly data) can be obtained with * the function %period(t). * set seasonal = %beta(%period(t)) set tce = bigqtr/seasonal * * We now do a linear regression of the TCE on 1 and t to get the updated trend * estimate, and take the fitted values from it. * set time = t linreg tce # constant time prj trend * * The last three columns don't quite match because RATS does all of these * calculations with higher precision. * print(picture="*.###") / bigqtr seasonal tce trend * * Figure 5-4 * graph(footer="Figure 5-4 Deseasonalized values and trend, Big City Bookstore",key=upleft) 3 # bigqtr # tce # trend * * Additive decomposition. Instead of dividing by the moving average to get the * raw seasonal factors, subtract. We repeat some of the instructions so the * analysis here will be able to stand alone. * filter(type=centered,width=4) bigqtr / tc set differ = bigqtr-tc * seasonal(span=4) sdummy linreg differ # sdummy{0 to -3} disp "Sum of seasonal factors" %sum(%beta) * * This time, we alter the additive seasonal factors so they sum to zero. * compute %beta=%beta-%sum(%beta)/4.0 * set seasonal = %beta(%period(t)) set tce = bigqtr-seasonal set time = t linreg tce # constant time prj trend * print(picture="*.###") / bigqtr seasonal tce trend