Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Contrasts and Multiple Comparisons in One-Way ANOVA - Prof. A. John Bailer, Study notes of Environmental Science

An example of how to perform contrasts and multiple comparisons in a one-way analysis of variance (anova) using sas and r software. It includes the calculation of simultaneous confidence intervals and the comparison of means using various methods such as bonferroni, tukey, and scheffe. The example uses a dataset of bacteria counts in meat under different conditions.

Typology: Study notes

Pre 2010

Uploaded on 08/17/2009

koofers-user-ldr-1
koofers-user-ldr-1 🇺🇸

10 documents

1 / 13

Toggle sidebar

Related documents


Partial preview of the text

Download Contrasts and Multiple Comparisons in One-Way ANOVA - Prof. A. John Bailer and more Study notes Environmental Science in PDF only on Docsity! C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 1 Week 7.2--IES 612-STA 4-573-STA 4-576.doc IES 612/STA 4-573/STA 4-576 Winter 2009 Multiple Comparisons Suppose you reject the overall hypothesis H0: μ1 = μ2= μ3= … = μt What next? Which means differ? Linear combination: which is estimated by 1 t i i i a = = ∑l μ 1 ˆ t i i i a y = = ∑l . This linear combination is called a CONTRAST if ∑ 1 t i i a = 0= Suppose t=4 populations Example 1: The contrast for comparing two means, μ1 = μ2, is the contrast of the difference of the two means, μ1 - μ2, 1 2 3 1 1 1 0 0( ) ( ) ( ) ( ) t i i i a = = μ = μ + − μ + μ + μ∑l 4 Example 2: Contrast for comparing the mean of one population with the average of two other population means 1 2 32 μ + μ = μ . This can be written as a the contrast 1 2 3 4 1 2 3 1 1 11 1 2 0 1 0 2 2 ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) t i i i a = = μ = − μ + − μ + μ + μ = − μ + − μ + μ + μ∑l 4 You can test hypotheses about contrasts. H0: 1 0 t i i i a = = μ =∑l Ha: 1 0 t i i i a = = μ ≠∑l TS: obs SSCF MSE = where 2 2 1 ˆ / t i i i SSC a n = = ∑ l with p-value = 1,Pr( )Tn t obsF F− > Two contrasts: and 1 1 t i i i a = = ∑l μ μ2 1 t i i i b = = ∑l are ORTHOGONAL if 1 0 t i i i i ab n= =∑ Treatment SS can be partitioned into t-1 mutually orthogonal contrasts Example: The Meat study with using logCounts Using R Consider the following contrasts: 1. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the plastic condition. What would this contrast look like? 2. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the mixed condition. What would this contrast look like? 3. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the vacuum condition. What would this contrast look like? C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 2 2. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the mixed condition. this contrast was: l2 = +1*μCO2 + 0*μplas + -1*μmixed + 0*μvac = 0. > linear.hypothesis(MeatMeansANOVA, .Hypothesis, rhs=.RHS) Linear hypothesis test Hypothesis: ConditionCO2 - Conditionplastic = 0 Model 1: logCount ~ Condition - 1 Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 8 0.9268 2 9 26.3884 -1 -25.4616 219.78 4.22e-07 *** Conclusion? 3. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the vacuum condition. this contrast was: l3 = +1*μCO2 + 0*μplas + 0*μmixed + -1*μvac = 0. > linear.hypothesis(MeatMeansANOVA, .Hypothesis, rhs=.RHS) Linear hypothesis test Hypothesis: ConditionCO2 - Conditionvacuum = 0 Model 1: logCount ~ Condition - 1 Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 8 0.9268 2 9 7.7962 -1 -6.8694 59.296 5.742e-05 *** --- Conclusion? C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 5 4. Compare the mean log Bacteria count for plastic to the average mean log Bacteria count for the other three conditions. this contrast was: l4 = +1*μCO2 + -3*μplas + 1*μmixed + 1*μvac = 0. > linear.hypothesis(MeatMeansANOVA, .Hypothesis, rhs=.RHS) Linear hypothesis test Hypothesis: ConditionCO2 - 3 Conditionmixed + Conditionplastic + Conditionvacuum = 0 Model 1: logCount ~ Condition - 1 Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 8 0.9268 2 9 8.3252 -1 -7.3984 63.862 4.401e-05 *** Conclusion? Can we obtain estimates and CI’s for these contrasts using R? > library(multcomp) Loading required package: mvtnorm > glht(MeatMeansANOVA, linfct=matrix(c(1, -1, 0 , 0, + 1, 0, -1, 0, + 1, 0, 0, -1, + 1, -3, 1, 1), byrow=TRUE, ncol=4)) General Linear Hypotheses Linear Hypotheses: Estimate 1 == 0 -3.90 2 == 0 -4.12 3 == 0 -2.14 4 == 0 -5.44 > summary(glht(MeatMeansANOVA, linfct=matrix(c(1, -1, 0 , 0, + 1, 0, -1, 0, + 1, 0, 0, -1, + 1, -3, 1, 1), byrow=TRUE, ncol=4))) Simultaneous Tests for General Linear Hypotheses Fit: lm(formula = logCount ~ Condition - 1, data = MeatBacteria) Linear Hypotheses: Estimate Std. Error t value p value 1 == 0 -3.9000 0.2779 -14.033 <0.001 *** 2 == 0 -4.1200 0.2779 -14.825 <0.001 *** 3 == 0 -2.1400 0.2779 -7.700 <0.001 *** 4 == 0 -5.4400 0.6807 -7.991 <0.001 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Adjusted p values reported) C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 6 And a plot of these contrast estimates and CI’s is > plot(glht(MeatMeansANOVA, linfct=matrix(c(1, -1, 0 , 0, + 1, 0, -1, 0, + 1, 0, 0, -1, + 1, -3, 1, 1), byrow=TRUE, ncol=4))) -7 -6 -5 -4 -3 -2 4 3 2 1 ( ( ( ( ) ) ) ) 95% family-wise confidence level Linear Function C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 7 Example: The Meat study with using logCounts Using R > library(multcomp) Loading required package: mvtnorm > confint(MeatANOVA) 2.5 % 97.5 % (Intercept) 2.906844 3.813156 Condition[T.mixed] 3.259141 4.540859 Condition[T.plastic] 3.479141 4.760859 Condition[T.vacuum] 1.499141 2.780859 > print(confint(glht(MeatANOVA, linfct=mcp(Condition="Tukey")))) Simultaneous Confidence Intervals for General Linear Hypotheses Multiple Comparisons of Means: Tukey Contrasts Fit: lm(formula = logCount ~ Condition, data = MeatData) Estimated Quantile = 3.2024 Linear Hypotheses: Estimate lwr upr mixed - CO2 == 0 3.9000 3.0100 4.7900 plastic - CO2 == 0 4.1200 3.2300 5.0100 vacuum - CO2 == 0 2.1400 1.2500 3.0300 plastic - mixed == 0 0.2200 -0.6700 1.1100 vacuum - mixed == 0 -1.7600 -2.6500 -0.8700 vacuum - plastic == 0 -1.9800 -2.8700 -1.0900 95% family-wise confidence level > plot(print(confint(glht(MeatANOVA, linfct=mcp(Condition="Tukey"))))) -2 0 2 4 - plastic - mixed - mixed m - CO2 c - CO2 d - CO2 ( ( ( ( ( ( ) ) ) ) ) ) 95% family-wise confidence level Linear Function C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 10 Using SAS title “One-way ANOVA/ CRD example + contrasts”; title2 “Bacteria in meat data”; data meat; input condition $ logcount @@; datalines; plastic 7.66 plastic 6.98 plastic 7.80 vacuum 5.26 vacuum 5.44 vacuum 5.80 mixed 7.41 mixed 7.33 mixed 7.04 CO2 3.51 CO2 2.91 CO2 3.66 ; /* ORDER=DATA says plastic < vacuum < mixed < CO2 in Labels otherwise sorts */ proc glm data=meat order=data; class condition; model logcount=condition; lsmeans condition / stderr pdiff; means condition / lsd clm; * Fisher LSD; means condition / bon scheffe tukey; * Bonferroni, Scheffe, Tukey; means condition / bon tukey cldiff; * pairwise CIs generated; run; The GLM Procedure Least Squares Means logcount Standard LSMEAN condition LSMEAN Error Pr > |t| Number plastic 7.48000000 0.19651124 <.0001 1 vacuum 5.50000000 0.19651124 <.0001 2 mixed 7.26000000 0.19651124 <.0001 3 CO2 3.36000000 0.19651124 <.0001 4 Least Squares Means for effect condition Pr > |t| for H0: LSMean(i)=LSMean(j) Dependent Variable: logcount i/j 1 2 3 4 1 <.0001 0.4514 <.0001 2 <.0001 0.0002 <.0001 3 0.4514 0.0002 <.0001 4 <.0001 <.0001 <.0001 NOTE: To ensure overall protection level, only probabilities associated with pre-planned comparisons should be used t Confidence Intervals for logcount Alpha 0.05 Error Degrees of Freedom 8 Error Mean Square 0.11585 Critical Value of t 2.30600 Half Width of Confidence Interval 0.453156 95% Confidence condition N Mean Limits plastic 3 7.4800 7.0268 7.9332 mixed 3 7.2600 6.8068 7.7132 vacuum 3 5.5000 5.0468 5.9532 CO2 3 3.3600 2.9068 3.8132 C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 11 means condition / bon scheffe tukey; Tukey's Studentized Range (HSD) Test for logcount NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than REGWQ. Alpha 0.05 Error Degrees of Freedom 8 Error Mean Square 0.11585 Critical Value of Studentized Range 4.52880 Minimum Significant Difference 0.89 Means with the same letter are not significantly different. Mean N condition A 7.4800 3 plastic A A 7.2600 3 mixed B 5.5000 3 vacuum C 3.3600 3 CO2 Bonferroni (Dunn) t Tests for logcount NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than REGWQ. Alpha 0.05 Error Degrees of Freedom 8 Error Mean Square 0.11585 Critical Value of t 3.47888 Minimum Significant Difference 0.9668 Means with the same letter are not significantly different. Mean N condition A 7.4800 3 plastic A A 7.2600 3 mixed B 5.5000 3 vacuum C 3.3600 3 CO2 Scheffe's Test for logcount NOTE: This test controls the Type I experimentwise error rate. Alpha 0.05 Error Degrees of Freedom 8 Error Mean Square 0.11585 Critical Value of F 4.06618 Minimum Significant Difference 0.9706 Means with the same letter are not significantly different. Mean N condition A 7.4800 3 plastic A A 7.2600 3 mixed C:\Users\baileraj\BAILERAJ\Classes\Web-CLASSES\ies-612\lectures\Week 7.2--IES 612-STA 4-576-22feb09.doc 2/22/2009 12
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved