March 28, 30
• Return exam• Analyses of covariance• 2-way ANOVA• Analyses of binary outcomes
Exam 1 ScoresN = 23
75% Q3 9550% Median 8325% Q1 74
Mean = 83.7SD = 11.1
90-100 A89-89 B70-79 C
30% of Grade30% Exam 230% Assignments10% Project
Analysis of Variance
ANOVA simultaneously tests for difference in k means
• Y - continuous• k samples from k normal distributions
• each size ni, not necessarily equal
• each with possibly different mean• each with constant variance 2
Analyses of Covariance
• Comparing k means adjusting for 1 or more other variables (covariates)
• Uses– Randomized students to adjust for an imbalance among
treatments in a baseline factor.– In observational studies controlling for a confounding
factor– To throw light on the nature of treatment effects in a
randomized study– Improve precision of estimated differences among
treatments
Analyses of Covariance
• Comparing k means adjusting for 1 or more other variables (covariates)
• Compute adjusted (or least square) means. • Sometimes called ANCOVA
Original Use
• Fisher (1941) the Y were yields of tea bushes in an experiment.
• But the luck of the draw, some treatments will have been allotted to a more productive set of bushes than other treatments
• Use as an adjustment variable the yields of the bushes in the previous year.
Adjusted Means Computation
YBARi = Mean of Y for group I
XBARi = Mean of X for group I
XBAR = Mean of X for all groups combined
= Regression slope of X with Y
YBAR(A)i = Adjusted mean for group I
YBAR(A)i = YBARi – XBARi – XBAR)
Adjustment
Adjusted Means ComputationObservations
YBAR(A)i = YBARi – XBARi – XBAR)
1) If then adjusted mean equals unadjusted mean
2) If mean of X is same for all group then adjusted mean equals unadjusted mean
Adjusted Mean Interpretation
The mean of Y for the group if the mean of X for the group was at the overall mean.
Uses a model to make the mean of X the same for all groups
What would the means have been if all groups had the same mean of X?
Example from TOMHS
Compare 12-month visit mean serum cholesterol between diuretic group and placebo group.
12-mo Avg. Baseline Avg.Diuretic 231.7 230.7Placebo 219.7 224.9
Diff: 12.0 5.8
Note: Diuretic group started out with higher cholesterols so may want to adjust for this difference.
Computing the Adjusted Means
12-mo Avg. Baseline Avg.Diuretic 231.7 230.7Placebo 219.7 224.9Total 227.0
=0.894 Regression slope of 12-month cholesterol onbaseline cholesterol
YBAR(A) (Diur) = 231.7 – 0.894 (230.7 – 227.0)= 231.7 – 0.894 (3.7) = 228.4
YBAR(A) (Plac) = 219.7 – 0.894 (224.9 – 227.0)= 219.7 – 0.894 (-3.7) = 221.6
6.8
SAS Code
PROC GLM; CLASS group; MODEL chol12 = group cholbl/SS3 SOLUTION; MEANS group; LSMEANS group; ESTIMATE ‘Adjusted Mean Dif' group 1 -1;RUN;
SAS GLM Output
Source DF Type III SS Mean Square F Value Pr > F
GROUP 1 3666.8314 3666.8314 6.29 0.0126cholbl 1 393014.2008 393014.2008 674.26 <.0001
StandardParameter Estimate Error t Value Pr > |t|
Intercept 18.77666226 B 7.90780076 2.37 0.0181GROUP 3 6.79524641 B 2.70925949 2.51 0.0126GROUP 6 0.00000000 B . . .cholbl 0.89351891 0.03441046 25.97 <.0001
Regression slope
SOLUTION
SAS GLM Output
Level of ------------CHOL12----------- ------------cholbl-----------GROUP N Mean Std Dev Mean Std Dev
3 125 231.696000 46.2561633 230.688000 38.96947036 221 219.737557 38.5904356 224.909502 37.1702588
Least Squares Means
CHOL12GROUP LSMEAN
3 228.3981206 221.602873
StandardParameter Estimate Error t Value Pr > |t|
dif 6.79524641 2.70925949 2.51 0.0126
LSMEANS group;
ESTIMATE 'dif' group 1 -1;
dif
Two-Way ANOVA
• Two categorical factors related to a continuous outcome (Factor A and factor B). If factors are allocated randomly to all combinations of A and B then design called factorial design
• Questions asked– Overall is A related to Y– Overall is B related to Y– Does the effect of A on Y depend on level of B
• Example– A = Race; B = BP drug; Y = BP response– A = Vitamin E (y/n); aspirin use (y/n)
Factorial Design Example
Aspirin +
Vitamin E
Aspirin +
Placebo forVitamin E
Placebo for Aspirin
+Vitamin E
Placebo for Aspirin
+Placebo forVitamin E
A = Aspirin use (yes or no)
B = Vitamin E use (yes or no)
Placebo for aspirin and placebo for Vitamin E
TOMHS Example
Question:Do certain BP medications differ in lowering blood pressure in blacks compared to whites?
Change in SBP (mm Hg)Diuretic Blocker
Blacks -23.6 -8.7Whites -21.4 -17.8Difference -2.2 +9.1
Is the difference –2.2 significantly different from +9.1
SAS Code
LIBNAME tomhs 'C:\my documents\ph5415\';
DATA temp; SET tomhs.bpstudy;* Choose diuretic and alpha blocker groups;* Variable black = 1 or 2; if group in(3,4); sbpdif = sbp12 - sbpbl;RUN;
PROC GLM DATA=temp; CLASS black group; MODEL sbpdif = black group black*group; MEANS black*group;RUN;
Tests for interaction
SAS OUTPUTThe GLM Procedure
Level of Level of ------------sbpdif-----------
GROUP BLACK N Mean Std Dev
3 1 27 -23.6296296 14.6442379
3 2 97 -21.3505155 14.4939220
4 1 24 -8.7291667 17.5802379
4 2 104 -17.8125000 12.5978091
SAS OUTPUTThe GLM Procedure
Dependent Variable: sbpdif
Sum ofSource DF Squares Mean Square F Value Pr > F
Model 3 3791.89107 1263.96369 6.37 0.0004
Error 248 49197.96210 198.37888
Corrected Total 251 52989.85317
Source DF Type III SS Mean Square F Value Pr > F
GROUP 1 3447.055834 3447.055834 17.38 <.0001
BLACK 1 469.412605 469.412605 2.37 0.1253
GROUP*BLACK 1 1309.006907 1309.006907 6.60 0.0108
Your Turn
• Using TOMHS data test