* ch22eg1.sas, using data of Table 22.1; title 'Sec 22.3. Example of Single-Factor Covariance Analysis'; options ls=78 nodate; ; data promo; input y x A; case=1; * for merging, below; lines; 38 21 1 39 26 1 36 22 1 45 28 1 33 19 1 43 34 2 38 26 2 38 29 2 27 18 2 34 25 2 24 23 3 32 29 3 31 30 3 21 16 3 28 29 3 ; * compute average x value for centering; proc means; var x; by case; output out=xmean mean=xmean; ; * merge data sets; data promo2; merge promo xmean; by case; drop case; xc=x-xmean; proc print; var y x xc xmean A; title2 'Raw data, including centered covariate xc'; ; * Plot the data; proc plot; plot y*x=A; title1 'Analysis of Covariance: Cracker Promotion Example'; title2 'Plot of raw data'; ; * ANCOVA and comparison of treatment effects; proc glm; class A; model y = x A / solution; estimate 'A1-A2' A 1 -1 0; estimate 'A1-A3' A 1 0 -1; estimate 'A2-A3' A 0 1 -1; lsmeans A / CL pdiff adjust=bonf; title2 'ANCOVA and comparison of treatment effects'; ; * ANCOVA with centered covariate; proc glm; class A; model y = xc A / solution; estimate 'A1-A2' A 1 -1 0; estimate 'A1-A3' A 1 0 -1; estimate 'A2-A3' A 0 1 -1; title2 'ANCOVA with centered covariate'; ; * LOF Test for unequal slopes; proc glm; class A; model y = x A x*A; title2 'Lack-of-Fit test for unequal slopes'; Sec 22.3. Example of Single-Factor Covariance Analysis 1 ----------------------------------- case=1 ----------------------------------- The MEANS Procedure Analysis Variable : x N Mean Std Dev Minimum Maximum ------------------------------------------------------------------ 15 25.0000000 5.0709255 16.0000000 34.0000000 ------------------------------------------------------------------ Sec 22.3. Example of Single-Factor Covariance Analysis 2 Raw data, including centered covariate xc Obs y x xc xmean A 1 38 21 -4 25 1 2 39 26 1 25 1 3 36 22 -3 25 1 4 45 28 3 25 1 5 33 19 -6 25 1 6 43 34 9 25 2 7 38 26 1 25 2 8 38 29 4 25 2 9 27 18 -7 25 2 10 34 25 0 25 2 11 24 23 -2 25 3 12 32 29 4 25 3 13 31 30 5 25 3 14 21 16 -9 25 3 15 28 29 4 25 3 Analysis of Covariance: Cracker Promotion Example 3 Plot of raw data Plot of y*x. Symbol is value of A. y 45 + 1 | 44 + | 43 + 2 | 42 + | 41 + | 40 + | 39 + 1 | 38 + 1 2 2 | 37 + | 36 + 1 | 35 + | 34 + 2 | 33 + 1 | 32 + 3 | 31 + 3 | 30 + | 29 + | 28 + 3 | 27 + 2 | 26 + | 25 + | 24 + 3 | 23 + | 22 + | 21 +3 -+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 x Analysis of Covariance: Cracker Promotion Example 4 ANCOVA and comparison of treatment effects The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 Number of Observations Read 15 Number of Observations Used 15 Analysis of Covariance: Cracker Promotion Example 5 ANCOVA and comparison of treatment effects The GLM Procedure Dependent Variable: y Sum of Source DF Squares Mean Square F Value Pr > F Model 3 607.8286915 202.6095638 57.78 <.0001 Error 11 38.5713085 3.5064826 Corrected Total 14 646.4000000 R-Square Coeff Var Root MSE y Mean 0.940329 5.540120 1.872560 33.80000 Source DF Type I SS Mean Square F Value Pr > F x 1 190.6777778 190.6777778 54.38 <.0001 A 2 417.1509137 208.5754568 59.48 <.0001 Source DF Type III SS Mean Square F Value Pr > F x 1 269.0286915 269.0286915 76.72 <.0001 A 2 417.1509137 208.5754568 59.48 <.0001 Standard Parameter Estimate Error t Value Pr > |t| A1-A2 5.0753902 1.22896513 4.13 0.0017 A1-A3 12.9768307 1.20562330 10.76 <.0001 A2-A3 7.9014406 1.18874585 6.65 <.0001 Standard Parameter Estimate Error t Value Pr > |t| Intercept 4.37659064 B 2.73692149 1.60 0.1381 x 0.89855942 0.10258488 8.76 <.0001 A 1 12.97683073 B 1.20562330 10.76 <.0001 A 2 7.90144058 B 1.18874585 6.65 <.0001 A 3 0.00000000 B . . . NOTE: The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable. Analysis of Covariance: Cracker Promotion Example 6 ANCOVA and comparison of treatment effects The GLM Procedure Least Squares Means Adjustment for Multiple Comparisons: Bonferroni LSMEAN A y LSMEAN Number 1 39.8174070 1 2 34.7420168 2 3 26.8405762 3 Least Squares Means for effect A Pr > |t| for H0: LSMean(i)=LSMean(j) Dependent Variable: y i/j 1 2 3 1 0.0050 <.0001 2 0.0050 0.0001 3 <.0001 0.0001 A y LSMEAN 95% Confidence Limits 1 39.817407 37.929951 41.704863 2 34.742017 32.871927 36.612107 3 26.840576 24.995184 28.685968 Least Squares Means for Effect A Difference Simultaneous 95% Between Confidence Limits for i j Means LSMean(i)-LSMean(j) 1 2 5.075390 1.609667 8.541113 1 3 12.976831 9.576932 16.376729 2 3 7.901441 4.549137 11.253744 Analysis of Covariance: Cracker Promotion Example 7 ANCOVA with centered covariate The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 Number of Observations Read 15 Number of Observations Used 15 Analysis of Covariance: Cracker Promotion Example 8 ANCOVA with centered covariate The GLM Procedure Dependent Variable: y Sum of Source DF Squares Mean Square F Value Pr > F Model 3 607.8286915 202.6095638 57.78 <.0001 Error 11 38.5713085 3.5064826 Corrected Total 14 646.4000000 R-Square Coeff Var Root MSE y Mean 0.940329 5.540120 1.872560 33.80000 Source DF Type I SS Mean Square F Value Pr > F xc 1 190.6777778 190.6777778 54.38 <.0001 A 2 417.1509137 208.5754568 59.48 <.0001 Source DF Type III SS Mean Square F Value Pr > F xc 1 269.0286915 269.0286915 76.72 <.0001 A 2 417.1509137 208.5754568 59.48 <.0001 Standard Parameter Estimate Error t Value Pr > |t| A1-A2 5.0753902 1.22896513 4.13 0.0017 A1-A3 12.9768307 1.20562330 10.76 <.0001 A2-A3 7.9014406 1.18874585 6.65 <.0001 Standard Parameter Estimate Error t Value Pr > |t| Intercept 26.84057623 B 0.83843921 32.01 <.0001 xc 0.89855942 0.10258488 8.76 <.0001 A 1 12.97683073 B 1.20562330 10.76 <.0001 A 2 7.90144058 B 1.18874585 6.65 <.0001 A 3 0.00000000 B . . . NOTE: The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable. Analysis of Covariance: Cracker Promotion Example 9 Lack-of-Fit test for unequal slopes The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 Number of Observations Read 15 Number of Observations Used 15 Analysis of Covariance: Cracker Promotion Example 10 Lack-of-Fit test for unequal slopes The GLM Procedure Dependent Variable: y Sum of Source DF Squares Mean Square F Value Pr > F Model 5 614.8791646 122.9758329 35.11 <.0001 Error 9 31.5208354 3.5023150 Corrected Total 14 646.4000000 R-Square Coeff Var Root MSE y Mean 0.951236 5.536826 1.871447 33.80000 Source DF Type I SS Mean Square F Value Pr > F x 1 190.6777778 190.6777778 54.44 <.0001 A 2 417.1509137 208.5754568 59.55 <.0001 x*A 2 7.0504731 3.5252366 1.01 0.4032 Source DF Type III SS Mean Square F Value Pr > F x 1 243.1412380 243.1412380 69.42 <.0001 A 2 1.2632832 0.6316416 0.18 0.8379 x*A 2 7.0504731 3.5252366 1.01 0.4032