/* ------------------------------------------------------- file: three_stooges.sas study design: college frechmen were asked to specify their favorite member of the three stooges, they also completed two questionniares, one measuring the amount of brain damage and the other, the amount of stupidity purpose: this program illustrates the mathematical logic of ANOVA and MANOVA. it shows how one can compute an ANOVA using only means and variances ------------------------------------------------------- */ TITLE Three Stooges; FOOTNOTE1 Supported in part by grants MH-091748 and MH-080450; DATA three_stooges; LENGTH favorite $5.; INPUT favorite $ brain_damage stupidity_index; DATALINES; Moe 27 21 Moe 29 41 Moe 47 48 Moe 28 15 Moe 22 26 Moe 42 31 Moe 25 15 Moe 27 30 Moe 23 26 Moe 24 31 Moe 21 23 Moe 50 47 Moe 22 26 Moe 39 22 Moe 9 28 Moe 30 17 Moe 22 33 Moe 45 43 Moe 34 39 Moe 30 32 Moe 19 20 Moe 36 27 Moe 32 19 Moe 32 25 Moe 27 19 Larry 31 21 Larry 48 42 Larry 25 43 Larry 23 11 Larry 10 8 Larry 26 27 Larry 18 20 Larry 32 39 Larry 13 0 Larry 39 24 Larry 22 15 Larry 28 27 Larry 29 35 Larry 13 23 Larry 32 31 Larry 21 28 Larry 10 9 Larry 41 36 Larry 13 15 Larry 40 37 Larry 37 37 Larry 9 14 Larry 24 7 Larry 32 8 Larry 21 12 Curly 39 43 Curly 28 36 Curly 26 31 Curly 16 18 Curly 23 29 Curly 40 37 Curly 38 38 Curly 42 46 Curly 23 28 Curly 22 21 Curly 38 35 Curly 31 26 Curly 29 43 Curly 45 51 Curly 44 47 Curly 26 18 Curly 30 30 Curly 31 35 Curly 20 26 Curly 27 44 Curly 34 34 Curly 38 28 Curly 23 32 Curly 28 26 Curly 47 64 ; RUN; /* --- get summary statistics --- */ PROC SORT; BY favorite; RUN; PROC MEANS DATA=three_stooges NOPRINT; BY favorite; VAR brain_damage stupidity_index; OUTPUT OUT=stats MEAN=mean_bd mean_si VAR=var_bd var_si; RUN; TITLE2 Summary Statistics; PROC PRINT; RUN; /* -- within group estimates of the population variance --- */ PROC MEANS DATA=stats NOPRINT; VAR var_bd var_si; OUTPUT OUT=within MEAN=s2_within_bd s2_within_si; RUN; TITLE2 Within-group estimates of the population variance; PROC PRINT; RUN; /* -- between group estimates of the population variance --- */ PROC MEANS DATA=stats NOPRINT; VAR mean_bd mean_si; OUTPUT OUT=between VAR=s2_between_bd s2_between_si; RUN; /* --- multiply by n to get the variance estimate --- */ DATA between; SET between; s2_between_bd = 25 * s2_between_bd; s2_between_si = 25 * s2_between_si; RUN; TITLE2 Between-group estimates of the population variance; PROC PRINT; RUN; /* --- merge the data sets and compute the statistics --- */ DATA variance_estimates; MERGE between within; a_bd = s2_between_bd / s2_within_bd; a_si = s2_between_si / s2_within_si; RUN; TITLE2 The ''a'' statistic (see the handout on ANOVA); PROC PRINT; RUN; TITLE2 ANOVA Results; TITLE3 Compare the F statistics here to the ''a'' statistics above; PROC GLM DATA=three_stooges; CLASS favorite; MODEL brain_damage stupidity_index = favorite; RUN; QUIT;