/* --- file: rm.sphericity.sas * This SAS code demonstrates the test for sphericity * in a repeated measures design. It uses simulated * data for six test scores over time. The independent * variables are SEX (1=male, 2=female) and INSTRUCT * (1 = massed practice, 2 = distributed practice). * * There are two REPEATED statements. The first one * does a CONTRAST transformation on the six test * scores (i.e., compares each test score to the * first test score. This transformation is * nonorthogonal in the sense that the transformed * variables may be correlated. With a nonorthogonal * transformation, SAS will print TWO sphericity tests. * The first is for the raw transformed data. This * tests whether the correlation matrix for these * transformed variables is orthogonal. If this test * is successful (i.e., chi square is small and the * correlations of the transformed variables are close * to 0, then the univariate tests (i.e., the output * from the SUMMARY option) are independent and may be * interpreted so. * The second sphericity test is for the orthogonal * components of the original variables, labeled in the * output as the spericity test * 'Applied to Orthogonal Components' * It is THIS test that checks whether the original * correlation matrix has the properties that * satisfy the repeated measures design. If this test is * passed (i.e., chi square is small), then you can * interprete the repeated measures tests that appear * later in the output under the heading * 'Univariate Tests of Hypotheses for Within Subjects Effects' * * The second REPEATED statement uses a POLYNOMIAL * transformation. This is an orthogonal transformation * in the sense that it will generate an orthogonal * matrix of correlations. Because this is an * orthogonal transformation, the sphericity test for * the transformed variables will always equal the * sphericity test for the orthogonal components. You * should verify this in the output. * You should verify in the output that this sphericity * test is the SAME as that for the orthogonal components when * we used the CONTRAST transformation. (Effectively, the same * data are subjected to a transformation to orthogonal * components). */ DATA spheric; INPUT sex group test1-test6; DATALINES; 1 1 21 40 23 41 63 61 1 1 40 39 46 60 75 82 1 1 65 57 74 69 83 67 1 1 0 38 45 79 63 90 1 1 37 51 53 90 85 89 1 1 42 36 66 77 71 83 1 1 15 19 38 52 76 78 1 1 19 23 51 51 43 88 1 1 1 9 37 26 39 68 1 1 49 31 38 56 74 83 1 1 18 49 53 47 70 72 1 1 48 44 45 68 69 88 1 1 23 43 54 59 38 57 1 1 26 22 49 57 57 49 1 1 56 38 61 45 107 92 2 1 49 36 51 70 54 75 2 1 54 78 84 82 109 101 2 1 57 44 70 67 76 80 2 1 35 31 44 59 86 81 2 1 47 56 81 70 96 89 2 1 24 61 51 60 75 69 2 1 49 55 53 77 95 101 2 1 50 48 53 59 79 102 2 1 48 46 63 85 67 84 2 1 43 37 65 54 82 98 2 1 49 63 64 85 82 90 2 1 55 63 46 67 75 83 2 1 32 33 51 75 71 89 2 1 7 5 48 17 52 63 2 1 27 25 19 55 55 48 1 2 48 37 80 73 78 86 1 2 49 51 72 105 103 102 1 2 24 54 67 33 47 81 1 2 27 60 47 58 45 57 1 2 55 59 72 111 111 71 1 2 45 73 88 90 83 108 1 2 48 67 75 99 105 108 1 2 19 31 62 64 52 71 1 2 58 65 79 60 97 80 1 2 12 50 28 20 51 37 1 2 46 50 70 94 76 88 1 2 56 52 98 94 103 112 1 2 80 83 96 98 105 109 1 2 41 79 114 77 92 86 1 2 44 76 96 77 64 78 2 2 15 45 58 76 78 59 2 2 44 59 69 77 103 99 2 2 28 51 79 50 61 56 2 2 50 60 80 79 72 86 2 2 1 19 46 62 75 76 2 2 14 52 63 49 69 51 2 2 18 34 59 81 79 58 2 2 41 67 84 98 87 101 2 2 26 54 69 67 66 73 2 2 44 50 71 64 91 75 2 2 8 55 52 58 67 66 2 2 57 74 87 84 115 82 2 2 29 55 76 103 68 96 2 2 32 48 78 68 71 74 2 2 73 53 120 103 120 99 ; RUN; TITLE 'Example of sphericity tests in repeated measures'; PROC GLM DATA=spheric; CLASS sex group; * --- the NOUNI option suppresses printing of the univariate ANOVAS; MODEL test1-test6 = sex | group / NOUNI; TITLE2 'Contrast Transformation'; REPEATED Time CONTRAST / PRINTE PRINTM SUMMARY; RUN; TITLE2 'Polynomial Transformation'; REPEATED Time POLYNOMIAL / PRINTE PRINTM SUMMARY; RUN; QUIT;