* PS10.3, using DATA10-2, for the Breusch-Godfrey test for Example 10.4 * SAMPLE 1 744 * READ(data10-2) DAYHOUR LOAD TEMP * * The LAG function on the GENR command is used to generate a new variable * called LOAD1 which is the variable LOAD lagged back one time period. * GENR LOAD1=LAG(LOAD) * * The sample period now begins at observation 2 rather than 1 since an * observation is lost when the variable LOAD is lagged back one time * period. * SAMPLE 2 744 * * The RESID= option on the OLS command saves the regression residuals in * the vector called UHAT. * OLS LOAD LOAD1 TEMP / RESID=UHAT * * The LAG function on the GENR command is first used to generate the lagged * regression residual back one time period {UHAT1=LAG(UHAT)}, then back two * time periods {UHAT2=LAG(UHAT,2)}, then back three time periods {UHAT3= * LAG(UHAT,3)}, then back four time periods {UHAT4=LAG(UHAT,4)}, then back * five time periods {UHAT5=LAG(UHAT,5)}, and finally back six time periods * {UHAT6=LAG(UHAT,6)}. * GENR UHAT1=LAG(UHAT) GENR UHAT2=LAG(UHAT,2) GENR UHAT3=LAG(UHAT,3) GENR UHAT4=LAG(UHAT,4) GENR UHAT5=LAG(UHAT,5) GENR UHAT6=LAG(UHAT,6) * * The sample period now begins at observation 9 rather than 2 since 6 * observations are lost when the regression residuals, UHAT, were lagged * back 6 time periods. * SAMPLE 8 744 OLS UHAT LOAD1 TEMP UHAT1 UHAT2 UHAT3 UHAT4 UHAT5 UHAT6 * * The temporary variables for the regression R-Square, $R, and the number * of observations in the regression, $N, are automatically stored after * an OLS regression. The GEN1 command is used with the temporary variables * $N and $R2 to calculate the LM test statistic. The PRINT command prints * this statistic. * GEN1 LM=$N*$R2 DISTRIB LM / TYPE=CHI DF=6 * DELETE/ALL STOP