***************************************************************************** * CHAPTER 15 - STATISTICS FOR BUSINESS & ECONOMICS, 5th Edition * ***************************************************************************** * Sample Mean for A-cars, B-cars, and C-cars, p. 581 * * The sample range for ACARS and BCARS is 1 to 7. The last observation for * CCARS is missing so the sample range for this variable is 1 to 6. The * default missing observation value of -99999 has been included in Table 15.1 * so all three variables can be read in with 7 data points. * SAMPLE 1 7 READ(TABLE15.1) ACARS BCARS CCARS / SKIPLINES=9 LIST * * The SUM= option on the STAT command saves the sum of A-cars in the constant * SUMA. The MEAN= option saves the mean of A-cars in the constant MEANA. * STAT ACARS / SUM=SUMA MEAN=MEANA STAT BCARS / SUM=SUMB MEAN=MEANB * * The SET SKIPMISS command is used before the sum of CCARS is calculated. If * the missing observation was included in the calculation the sum for CCARS * would be incorrect. * SET SKIPMISS STAT CCARS / SUM=SUMC MEAN=MEANC PRINT MEANA SUMA MEANB SUMB PRINT MEANC SUMC * * The overall mean of A-cars, B-cars, and C-cars on page 599. First the GEN1 * command is used to generate the constant for the number of A-cars, B-cars, * and C-cars. * GEN1 NA=7 GEN1 NB=7 GEN1 NC=6 GEN1 XBAR=(NA*MEANA+NB*MEANB+NC*MEANC)/(NA+NB+NC) PRINT XBAR * * The variability of the first group, A-cars is defined as SS1. * GENR SSA=(ACARS-MEANA)**2 STAT SSA / SUM=SS1 PRINT SS1 * * The variability of the second group, B-cars is defined as SS2. * GENR SSB=(BCARS-MEANB)**2 STAT SSB / SUM=SS2 PRINT SS2 * * The variability of the third group, C-cars is defined as SS3. * GENR SSC=(CCARS-MEANC)**2 STAT SSC / SUM=SS3 PRINT SS3 * * The Total Within-Groups variability is defined as SSW with the GEN1 command. * GEN1 SSW=SS1+SS2+SS3 PRINT SSW * * The Total Between-Groups Sum of Squares is defined as SSG with the GEN1 * command. * GEN1 SSG=NA*((MEANA-XBAR)**2)+NB*((MEANB-XBAR)**2)+NC*((MEANC-XBAR)**2) PRINT SSG * * The Total Sum of Squares is defined as SST with the GEN1 command. * GEN1 SST=SSW+SSG PRINT SST * * The Within-Groups Mean Square is defined as MSW with the GEN1 command. * GEN1 N=NA+NB+NC GEN1 K=3 GEN1 MSW=SSW/(N-K) PRINT MSW * * The Between-Groups Mean Square is defined as MSG with the GEN1 command. * GEN1 MSG=SSG/(K-1) PRINT MSG * * The F-value is: * GEN1 F=MSG/MSW PRINT F * * The above method to calculate the One-Way Analysis of Variance is the long * way. In SHAZAM, the One-Way Analysis of Variance can be easily calculated * with the ANOVA option on the STAT command. The DISTRIB command is used * to print out the corresponding F value given the numerator degrees of * freedom is 2 and the denominator degrees of freedom is 17 with a 1% level * test. * STAT ACARS BCARS CCARS / ANOVA * * 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, at the 1% level of significance before the DISTRIB command * can be executed. 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 * DF1=,DF2= - specifies the degrees of freedom for the numerator * (DF1) and the denominator (DF2). Must be used when * TYPE=F. * INVERSE = computes the inverse survival function * * GEN1 X=0.01 DISTRIB X / TYPE=F DF1=2 DF2=17 INVERSE * *---------------------------------------------------------------------------- * Example 15.1, p. 588 * SAMPLE 1 6 READ SCIAMER FORTUNE NEWYORK / LIST 15.75 12.63 9.27 11.55 11.46 8.28 11.16 10.77 8.15 9.92 9.93 6.37 9.23 9.87 6.37 8.20 9.42 5.66 * STAT SCIAMER FORTUNE NEWYORK / ANOVA * * The GEN1 and DISTRIB commands are used to print out the F critical value * at the 1% level of significance. * GEN1 X=0.01 DISTRIB X / TYPE=F DF1=2 DF2=15 INVERSE * *----------------------------------------------------------------------------- * Two-Way Analysis of Variance: One Observation per Cell, Randomized Blocks, * p. 596 * SAMPLE 1 6 READ DRIVER ALPHA BETA GAMMA SUMS / LIST 1 25.1 23.9 26.0 75.0 2 24.7 23.7 25.4 73.8 3 26.0 24.4 25.8 76.2 4 24.3 23.3 24.4 72.0 5 23.9 23.6 24.2 71.7 6 24.2 24.5 25.4 74.1 * * The SUMS= option on the STAT command saves the respect sums of the * specified variables, ALPHA, BETA and GAMMA in a constant called SALPHA * SBETA and SGAMMA. These sums will be used to calculate the sample means * for the groups, ALPHA (XBAR1), BETA (XBAR2) and GAMMA (XBAR3). The number * of observations/sample size of the data set is automatically stored in the * temporary variable $N in SHAZAM. * STAT ALPHA / SUMS=SALPHA STAT BETA / SUMS=SBETA STAT GAMMA / SUMS=SGAMMA STAT SUMS / SUMS=TOTAL GEN1 XBAR1=SALPHA/$N GEN1 XBAR2=SBETA/$N GEN1 XBAR3=SGAMMA/$N PRINT XBAR1 XBAR2 XBAR3 * * The sample mean for each block (XBLOK1, XBLOK2, XBLOK3, XBLOK4, XBLOK5 and * XBLOK6) is calculated with the GEN1 command in a DO-loop. The DO-loop * provides repeat operations. The format of the command is: * * DO dovar=start,stop,inc * commands * ENDO * * where: dovar = loop variable, must be #, %, ! or ? * start = starting value * stop = number of iterations of the DO-loop * inc = increment value * * The overall mean of the sample observations is XMEAN. * DO #=1,6 GEN1 XBLOK#=SUMS:#/3 PRINT XBLOK# ENDO GEN1 XMEAN=TOTAL/18 PRINT XMEAN * * The ANOVA option on the STAT command prints the Analysis of Variance * table and an F-value that tests the null hypothesis that the means of all * variables (ALPHA, BETA and GAMMA) are the same. A two-way analysis of * variance table is constructed since the sample size is the same for all * variables listed. The Sum of Squares for the Two-Way Analysis figures * are found under the SS category and the Mean Squares are under the MS * category in the SHAZAM output. The first F-statistic (MSG/MSE) under the * Two-Way Analysis table tests the Null Hypothesis that the population mean * fuel consumption is the same for all three types of automobiles. The * second F-statistics (MSB/MSE) tests the Null Hypothesis that the population * values of mean fuel consumption are the same for each driver age class. * STAT ALPHA BETA GAMMA / ANOVA * * The GEN1 and DISTRIB commands are used to print out the F critical value * at the 1% level of significance. * GEN1 X=0.01 DISTRIB X / TYPE=F DF1=2 DF2=10 INVERSE * *---------------------------------------------------------------------------- * Example 15.3, p. 603 * SAMPLE 1 18 READ DRIVER2 CAR MILEAGE / LIST 1 1 25.1 1 2 23.9 1 3 26.0 2 1 24.7 2 2 23.7 2 3 25.4 3 1 26.0 3 2 24.4 3 3 25.8 4 1 24.3 4 2 23.3 4 3 24.4 5 1 23.9 5 2 23.6 5 3 24.2 6 1 24.2 6 2 24.5 6 3 25.4 * DO %=1,3 SET NOWARNSKIP SKIPIF(CAR.NE.%) STAT CAR MILEAGE DELETE SKIP$ ENDO * DO ?=1,6 SET NOWARNSKIP SKIPIF(DRIVER2.NE.?) STAT DRIVER2 MILEAGE DELETE SKIP$ ENDO * DELETE / ALL *----------------------------------------------------------------------------- * Two-Way Analysis of Variance: More Than One Observation per Cell, p. 606 * SAMPLE 1 15 * * X-Cars is defined as X1, Y-Cars is defined as X2, Z-Cars is defined as * X3. * READ X1 / BYVAR LIST 25.0 25.4 25.2 24.8 24.8 24.5 26.1 26.3 26.2 24.1 24.4 24.4 24.0 23.6 24.1 READ X2 / BYVAR LIST 24.0 24.4 23.9 23.5 23.8 23.8 24.6 24.9 24.9 23.9 24.0 23.8 24.4 24.4 24.1 READ X3 / BYVAR LIST 25.9 25.8 25.4 25.2 25.0 25.4 25.7 25.9 25.5 24.0 23.6 23.5 25.1 25.2 25.3 * * The Group Mean is calculated using the STAT command. The STAT command * automatically calculates the mean of the variable specified. The MEAN= * option stores the mean in a specified constant. MEANX1 stores the Car 1 * mean, MEANX2 stores the Car 2 mean, and MEANX3 stores the Car 3 mean. * STAT X1 / MEAN=MEANX1 STAT X2 / MEAN=MEANX2 STAT X3 / MEAN=MEANX3 PRINT MEANX1 MEANX2 MEANX3 * * The Block Mean is calculated using the GENR command with the SUM(x,n) * function. The GENR statement first sums the first 3 observations of * X1 and then the next three etc until all 15 observations are done. The * values for X2 and X3 are repeated with a similiar GENR command. The * DO-loop is then used next to complete the Block Means calculation. * SAMPLE 1 5 GENR XBAR1=SUM(X1,3) GENR XBAR2=SUM(X2,3) GENR XBAR3=SUM(X3,3) PRINT XBAR1 XBAR2 XBAR3 DO #=1,5 GEN1 NXBAR#=(XBAR1:#+XBAR2:#+XBAR3:#)/9 PRINT NXBAR# ENDO * * The Cell Mean is calculated in a similar fashion as the Block Mean. The * GENR command is used. Recall in the previous example of the Block Means * the sums were calculated and stored in the vectors XBAR1, XBAR2, and XBAR3. * The Cell Means for X11, X12, X13, X14, and X15 are stored in the vector * X11. The Cell Means for X21, X22, X23, X24, and X25 are stored in the * vector X22 and X31, X32, X33, X34, and X35 are stored in the vector X33. * All that needs to be done is to determine the average for each of the * sums. * SAMPLE 1 5 GENR X11=XBAR1/3 GENR X22=XBAR2/3 GENR X33=XBAR3/3 PRINT X11 X22 X33 * * The Overall Mean is calculated with the GEN1 command. Recall that the * mean of all sample observations was calculated in the Group Means example * above. * GEN1 OVERALL=(MEANX1+MEANX2+MEANX3)/3 PRINT OVERALL * * The following information is supplied on page 610 and 611 of the textbook. * The GEN1 command is used to generate the respective constants. * GEN1 K=3 GEN1 H=5 GEN1 L=3 GEN1 SSG=7.1565 GEN1 SSB=13.1517 GEN1 SSI=6.6045 GEN1 SSE=1.1600 GEN1 SST=28.0727 * * The Mean Squares in Figure 15.13 on page 611 are calculated using the * formulas in Table 15.12 on page 611 and the GEN1 command. The Mean * Square for the Car is MSG, Mean Square for the Driver is MSB, Mean Square * for Interaction is MSI, and Mean Square Error is MSE. * GEN1 MSG=SSG/(K-1) GEN1 MSB=SSB/(H-1) GEN1 MSI=SSI/((K-1)*(H-1)) GEN1 MSE=SSE/(K*H*(L-1)) PRINT MSG MSB MSI MSE * * The F-ratios in Figure 15.13 on page 611 are calculated using the formulas * in Table 15.12 on page 611 and the GEN1 command. The F-ratio for the * Car is FSSG, F-ratio for the Driver is FSSB, and F-ratio for Interaction is * FSSI. * GEN1 FSSG=MSG/MSE GEN1 FSSB=MSB/MSE GEN1 FSSI=MSI/MSE PRINT FSSG FSSB FSSI * * Null Hypothesis of no interaction between car and driver type tested at * the 1% level of significance with numerator and denominator degrees of * freedom of 8 and 30. * GEN1 X=0.01 DISTRIB X / TYPE=F DF1=8 DF2=30 INVERSE * * Null Hypothesis that the population mean fuel consumption is the same for * X-cars, Y-cars and Z-cars tested at the 1% level of significance with * numerator and denominator degrees of freedom of 2 and 30. * DISTRIB X / TYPE=F DF1=2 DF2=30 INVERSE * * With numerator and denominator degrees of freedom of 4 and 30. * DISTRIB X / TYPE=F DF1=4 DF2=30 INVERSE * *----------------------------------------------------------------------------- * Example 15.4, p. 612 * * The GEN1 command is used to generate the constants required to compute the * Mean Square found in the table on page 613. * GEN1 SSG=62.04 GEN1 SSB=0.06 GEN1 SSI=1.85 GEN1 SSE=23.31 GEN1 SST=82.26 * * The Degrees of Freedom for Tasks is equal to 1. We know that the Degrees * of Freedom Between Groups is defined as K-1. In this case K-1=1, therefore, * K=2. In the case of Worker Type, the Degrees of Freedom=1. The Degrees * of Freedom is defined as H-1 so H=2. The Degrees of Freedom for Error * is equal to 63 and the Degrees of Freedom is defined as KH(L-1)=63. * GEN1 K=2 GEN1 H=2 GEN1 L=(63+(K*H))/(K*H) PRINT L * * The GEN1 command is used to calculate the Mean Squares. Mean Squares of * Task is MSG, Mean Square of Worker Type is MSB, Mean Square of Interaction * is MSI, and Mean Square Error is MSE. * GEN1 MSG=SSG/(K-1) GEN1 MSB=SSB/(H-1) GEN1 MSI=SSI/((K-1)*(H-1)) GEN1 MSE=SSE/(K*H*(L-1)) PRINT MSG MSB MSI MSE * * The F-ratios are calculated using the formulas in Table 15.12 on page 611 * and the GEN1 command. The F-ratio for Task is FSSG, F-ratio for Worker * Type is FSSB, and F-ratio for Interaction is FSSI. * GEN1 FSSG=MSG/MSE GEN1 FSSB=MSB/MSE GEN1 FSSI=MSI/MSE PRINT FSSG FSSB FSSI * * The critical value at the 1% level of significance with a numerator and * denominator degrees of freedom of 1 and 63 is calculated with the GEN1 * and DISTRIB commands. * GEN1 X=0.01 DISTRIB X / TYPE=F DF1=1 DF2=63 INVERSE * * The critical value at the 5% level of significance with a numerator and * denominator degrees of freedom of 1 and 63 is calculated with the GEN1 * and DISTRIB commands. * GEN1 X=0.05 DISTRIB X / TYPE=F DF1=1 DF2=63 INVERSE * *----------------------------------------------------------------------------- * STOP