***************************************************************************** * CHAPTER 10 - STATISTICS FOR BUSINESS & ECONOMICS, 5th Edition * ***************************************************************************** * Example 10.1, p. 373 * * The mean political risk score for each country is defined as N and the * sample correlation between political risk score and inflation for these * countries is defined as R. * GEN1 N=49 GEN1 R=0.43 * * The Null Hypothesis is that no population correlation between political * risk score and inflation. The Alternative Hypothesis is there is a * positive correlation. The GEN1 command is used to calculate the test * statistic. * GEN1 T=R*SQRT(N-2)/(SQRT(1-R**2)) PRINT T * * The GEN1 and DISTRIB command is used to print out critical values in lieu * of referring to a statistical table. The GEN1 command is used to generate * a constant, X. The format of the DISTRIB command is: * * DISTRIB vars / options * * where: vars = list of variables * options = list of desired options * TYPE= - specifies the type of distribution * * In the textbook, the critical value for the Student's t Table is based on * degrees of freedom (DF=) of N-2=40. * GEN1 S=0.005 DISTRIB S / TYPE=T DF=40 INVERSE * * If the true degrees of freedom, DF=47, is used, the critical value is: * DISTRIB S / TYPE=T DF=47 INVERSE * DELETE / ALL *---------------------------------------------------------------------------- * Example 10.2, p. 375 * SAMPLE 1 22 * * The data from a national sampling survey of households defines retail sales * as Y and income as X per household. * READ(RETAILS.DIF) / DIF * * Replicate Table 10.1 using the PRINT command, p. 376. * PRINT YEAR X Y * * The PLOT command is used to replicate Figure 10.1., p. 375. * PLOT Y X * * The OLS command performs the Ordinary Least Squares Regressions and produce * standard regression diagnostics. The format of the OLS command is: * * OLS depvar indeps / options * * where: * depvar = is the dependent variable * indeps = is a list of independent variables * option = is a list of desired options * * The COEF= option on the OLS command stores the coefficients from the * regression in the variable called COEF. When there is an intercept in * the regression, SHAZAM will store the intercept as the last coefficient. * OLS Y X / COEF=COEF * * The forecasted family retail sales can be estimated using the GEN1 command * given that the family income level is equal to $10,000. * GEN1 SALES=COEF:2+COEF:1*10000 PRINT SALES * * Alternatively, the Least Squares Procedure can be used to estimate the * regression coefficients for this example. The GENR command is used to * calculate XY and X2. * GEN1 N=22 GENR XY=X*Y GENR X2=X**2 * * The MEAN= option on the STAT command is used to stored the mean of * the variable specified in a constant. The SUM= option stores the sum of * the variable specified in a constant. * STAT X / MEAN=XBAR SUM=SUMX STAT Y / MEAN=YBAR SUM=SUMY STAT XY / SUM=SUMXY STAT X2 / SUM=SUMX2 PRINT SUMX SUMY SUMXY SUMX2 PRINT XBAR YBAR * * The slope coefficient estimator is defined as B and the intercept * estimator is defined as A using the GEN1 command. * GEN1 B=(SUMXY-(N*XBAR*YBAR))/(SUMX2-(N*XBAR**2)) GEN1 A=YBAR-(B*XBAR) PRINT B A * *---------------------------------------------------------------------------- * 10.4 The Explanatory Power of a Linear Regression Equation, p. 384 * GENR YHAT=A+B*X GENR RESID=Y-YHAT GENR OBSDEV=Y-YBAR GENR PREDEV=YHAT-YBAR * * The Error Sum of Squares (SSE), Total Sum of Squares (SST) and Coefficient * of Determination (R2) can be calculated in using a combination of the * GENR and GEN1 commands. * GENR RES2=RESID**2 STAT RES2 / SUMS=SSE GENR OBSDEV2=OBSDEV**2 STAT OBSDEV2 / SUMS=SST GENR PREDEV2=PREDEV**2 STAT PREDEV2 / SUMS=SSR * * Replicate Table 10.2, p. 386 * PRINT YEAR X Y YHAT PRINT RESID OBSDEV PREDEV PRINT SSR SSE SST * * The coefficient of Determination R2 is calculated with the GEN1 command. * GEN1 R2=1-(SSE/SST) PRINT R2 * * The SSE, SST and R2 values are automatically calculated in SHAZAM when * an Ordinary Least Squares regression is estimated. The "?" preceeding * the OLS command suppress the OLS output. The SSE, SST and R2 are stored * in the temporary variables $SSE, $SST and $R2 after an OLS regression. * The PRINT command is used to print out these temporary variables. * * The COEF= and STDEV= options saves the regression coefficients and standard * deviations in the vector, COEF and STD respectively. * ?OLS Y X / COEF=COEF STDERR=STD PRINT $SSR $SSE $SST $R2 * *---------------------------------------------------------------------------- * Basis for Inference About the Population Regression Slope, p. 393 * * The Null Hypothesis is that there is not a strong relationship between * retail sales and disposable income. The Alternative Hypothesis is that * there is a strong relationship between retail sales and disposable income. * The Student's statistic is calculated with the GEN1 command. * * Recall that the COEF= option on the OLS command saved the regression * coefficients in the vector COEF. In Row 1 of this vector the estimate * for the slope coefficient is stored and Row 2 stores the estimate for the * constant. The same holds true for the vector STD. * GEN1 B=COEF:1 GEN1 SB=STD:1 GEN1 B0=0 GEN1 T=(B-B0)/SB PRINT T * * Recall in Example 10.2, an OLS regression was estimated. The T-ratio * for the independent variable, X, is automatically printed out in the * SHAZAM output. To suppress this output the "?" preceeds the SHAZAM * OLS command. The T-ratios from the estimated are saved with the TRATIO= * option in a vector called TRATIO. To print out the T-ratio for variable * X, the PRINT TRATIO:1 is used. * ?OLS Y X / TRATIO=TRATIO PRINT TRATIO:1 * GEN1 ALPHA=0.005 DISTRIB ALPHA / TYPE=T DF=20 INVERSE * * The 99% Confidence Interval for the retail sales on disposable income * regression is: * GEN1 B=COEF:1 GEN1 LOWER=B-2.845*SB GEN1 UPPER=B+2.845*SB PRINT LOWER UPPER * * SHAZAM automatically computes the Confidence Interval with the CONFID * command. The format is: * * estimation command * CONFID var1 var2 / options * * where: var1 = variable name * var2 = variable name * options = list of desired options * TCRIT= - specifies the t-distribution critical value for * calculating the confidence interval. If this option * is not specified, SHAZAM computes the critical values * for the 90% and 95% confidence intervals. * OLS Y X * * 99% Confidence Interval * CONFID X / TCRIT=2.8450 * * 90% and 95% Confidence Interval * CONFID X * * --------------------------------------------------------------------------- * Hypothesis Test for Population Slope Coefficient Using the F Distribution, * p. 396 * * The Mean Square for Error can be calculated using the GEN1 command. As * defined in the textbook, MSE=ESS/(n-2). After an OLS estimation, SHAZAM * has many temporary variables available for manipulation. In this example, * the Error Sum of Squares is stored as $SSE in SHAZAM. The F ratio is * calculated using the Mean Square for Regression, MSR, and Error Sum of * Squares, MSE. * GEN1 MSE=$SSE/(N-2) GEN1 F=$SSR/MSE PRINT MSE F * * In SHAZAM, the TEST command is used for linear and nonlinear hypothesis * testing on regression coefficients after a model estimation. The format * of the TEST command is: * * estimation command * TEST equation * * where: equation = an equation made up of combinations of variables * involved in the estimation and represents the * hypothesis to be tested. * OLS Y X TEST X=0 * * The critical value is calculated using the DISTRIB command. * GEN1 ALPHA=0.01 DISTRIB ALPHA / TYPE=F DF1=1 DF2=20 INVERSE * *----------------------------------------------------------------------------- * Example 10.3, p. 400 * * The results for Equations 10.25 and 10.26 can be calculated using the * GEN1 commands in SHAZAM. This is a long and tedious process but it is done * to illustrate the procedure to achieve the end results. * GEN1 EXPECT=12000 GEN1 B0=1923 GEN1 B1=0.3815 GEN1 YHAT=B0+B1*EXPECT GEN1 N=22 GEN1 XBAR=10799 GEN1 SUMXXBAR=34110178 GEN1 SE2=21789.95 * * Standard Error for a Predicted Single Observation Y, FCSE, is: * GEN1 FCSE=SQRT((1+(1/N)+((EXPECT-XBAR)**2)/(SUMXXBAR))*SE2) * * Standard Error for the Expected Value of Y, EXPSE, is: * GEN1 EXPSE=SQRT(((1/N)+(EXPECT-XBAR)**2/(SUMXXBAR))*SE2) PRINT FCSE EXPSE * * The 95% Confidence Interval in this case has a critical value of 2.086. * * Therefore, 95% Confidence Interval for the prediction of the actual value * for retail sales in a year when disposable income equals $12000 is: * GEN1 PLOWER=YHAT-2.086*FCSE GEN1 PUPPER=YHAT+2.086*FCSE PRINT PLOWER PUPPER * * The 95% Confidence Interval for the Expected Value of retail sales when * disposable income equals $12000 is: * GEN1 ELOWER=YHAT-2.086*EXPSE GEN1 EUPPER=YHAT+2.086*EXPSE PRINT ELOWER EUPPER * DELETE / ALL * * Alternatively, a short method in SHAZAM is available in estimating the * confidence intervals. The FC command in SHAZAM can be used. * * The FC command is used following a regression to forecast into the future. * The format of the FC command is: * * estimation command * FC / options * * where: estimation command = AUTO, BOX, LOGIT, OLS, POOL, PROBIT or TOBIT. * options = list of desired options. * * The contents under the Square Root sign in Equations 10.25 and 10.26 * represent 2 types of forecast error. Under the Square Root sign of * Equation 10.25 is the Individual Predicted Error and under the Square * Root sign of Equation 10.26 is the Mean or Conditional Predicted Error. * * The data provided for this forecast is that the disposable income per * household (X) is equal to $12000 for observation N+1. The retail sales * per household (Y) in the year N+1 variable is the observation to be * predicted. * * The DIM command is used to dimension a vector or matrix before any data is * defined. This command is required since the predicted value of the * dependent variable, Y, is saved in the vector FC and the forecasted * standard errors are to be saved in the vector SE. * * The format of the DIM command is: * * DIM var size var size ... * * where: var = the name of the vector or matrix * size = the size of the vector or matrix * SAMPLE 1 23 DIM FC1 23 SE1 23 DIM FC2 23 SE2 23 READ(RETAILS2.DIF) / DIF * * SHAZAM automatically calculates the Individual Predicted Error on the FC * command. The FCSE= option on the FC command saves these forecasted * standard errors in the specified vector which are then used to calculate * the Confidence Interval. The predicted values (Yhat) in Equation 12.9.3 * are saved with the PREDICT= option in the regression preceding the FC * command. The critical values for the Confidence Intervals are found in * the t-tables. Now all the required data to estimate Equation 12.9.3 * is defined. * * Note, the sample range must be changed from 1 23 to 1 22 before the OLS * regression is estimated. * SAMPLE 1 22 OLS Y X FC / LIST BEG=23 END=23 PREDICT=FC1 FCSE=SE1 * * The 95% Confidence Interval for retail sales in a year when a disposable * income, X=12000 is calculated with the GENR command. The SAMPLE 23 23 * command extracts only the 23rd observation for the predicted values of * Yhat and the forecasted standard errors. * * Note: If the GEN1 command is used the confidence interval will be equal * to zero since the GEN1 command is equal to the SAMPLE 1 1 command * and the GENR command to generate a variable with only one * observation. * SAMPLE 23 23 GENR LOWER1=FC1-2.086*SE1 GENR UPPER1=FC1+2.086*SE1 * * The predicted Yhat (FC1), forecasted standard error (SE1), lower bound of * the 95% Confidence Interval (LOWER1), upper bound of the 95% Confidence * Interval (UPPER1) are printed with the SHAZAM PRINT command. * PRINT FC1 SE1 LOWER1 UPPER1 * * Equation 10.26 can be calculated similarly as Equation 10.25. In this * case, the Mean Predicted Error is printed with the MEANPRED option on * the FC command. The predicted values (Yhat) and the critical values for * the Confidence Intervals is determined as in the previous equation. * * First the sample range must be reset to 1 22 since the previous sample * range was set to 23 23. * SAMPLE 1 22 OLS Y X FC / LIST MEANPRED BEG=23 END=23 PREDICT=FC2 FCSE=SE2 SAMPLE 23 23 GENR LOWER2=FC2-2.086*SE2 GENR UPPER2=FC2+2.086*SE2 * * The predicted Yhat (FC1), forecasted standard error (SE1), lower bound of * the 95% Confidence Interval (LOWER1), upper bound of the 95% Confidence * Interval (UPPER1) are printed with the SHAZAM PRINT command. * PRINT FC2 SE2 LOWER2 UPPER2 * DELETE / ALL *----------------------------------------------------------------------------- * Example 10.4, p. 404 * * Read this example carefully. Be sure you understand the methodology. * *---------------------------------------------------------------------------- * Example 10.5, p. 406 * * Read this example carefully. Be sure you understand the methodology. * *---------------------------------------------------------------------------- * STOP