Docsity

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

Toggle sidebar
bg1
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
ii
i
a
=
=
∑
lμ
1
ˆt
ii
i
ay
=
=
∑
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,
123
1
1100() ( ) () ()
t
ii
i
a
=
=μ=μ+−μ+μ+μ
∑
l4
Example 2: Contrast for comparing the mean of one population with the average of two other
population means 12 3
2
μ+μ =μ . This can be written as a the contrast
1234 1 23
1
11
1120 10
22
() () () () ( ) ( ) () ()
t
ii
i
a
=
= μ=− μ+− μ+ μ+ μ =− μ+− μ+ μ+ μ
∑
l4
You can test hypotheses about contrasts.
H0:
1
0
t
ii
i
a
=
=μ=
∑
l
Ha:
1
0
t
ii
i
a
=
=μ≠
∑
l
TS: obs
SSC
FMSE
= where
2
2
1
ˆ
/
t
ii
i
SSC
an
=
=
∑
l with p-value =
1,
Pr( )
T
nt obs
FF
−>
Two contrasts: and
11
t
ii
i
a
=
=
∑
lμμ
21
t
ii
i
b
=
=
∑
l are ORTHOGONAL if
1
0
tii
ii
ab
n
=
=
∑
Treatment SS can be partitioned into t-1 mutually orthogonal contrasts
pf3
pf4
pf5
pf8
pf9
pfa
pfd

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!

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 H 0 : μ 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

=

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

1

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

= μ. This can be written as a the contrast

1 2 3 4 1 2 3 1

t i i i

a

=

l = ∑ μ = − μ + − μ + μ + μ = − μ + − μ + μ + μ 4

You can test hypotheses about contrasts.

H 0 :

1

t i i i

a

=

l= ∑ μ =

H a:

1

t i i i

a

=

l= ∑ μ ≠

TS: obs

SSC

F

MSE

= where

2

2 1

t i i i

SSC

a n

=

l

with p-value = Pr( F 1 , nT − t >Fobs)

Two contrasts: 1 and

1

t i i i

a

=

l = ∑ μ 2 μ

1

t i i i

b

=

l = ∑ are ORTHOGONAL if

1

t i i i (^) i

a b

= 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?

With MeatMeansANOVA the active model, using RCommander:

Models > Hypothesis tests > Linear hypothesis ...

For each of the four contrasts we just plug in the constants as follows.

The four contrasts of interest were:

1. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the

plastic condition.

this contrast was: l 1 = +1μCO2 + -1μplas + 0μmixed + 0μvac = 0.

> linear.hypothesis(MeatMeansANOVA, .Hypothesis,

rhs=.RHS)

Linear hypothesis test

Hypothesis:

ConditionCO2 - Conditionmixed = 0

Model 1: logCount ~ Condition - 1

Model 2: restricted model

Res.Df RSS Df Sum of Sq F Pr(>F)

2 9 23.7418 -1 -22.8150 196.94 6.451e-07 ***

Conclusion?

2. Compare the mean log Bacteria count for CO2 to the mean log Bacteria count for the

mixed condition.

this contrast was: l 2 = +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)

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: l 3 = +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)

2 9 7.7962 -1 -6.8694 59.296 5.742e-05 ***

Conclusion?

And a plot of these contrast estimates and CI’s is

> plot(glht(MeatMeansANOVA, linfct=matrix(c(1, -1, 0 , 0,

+ 1, -3, 1, 1), byrow=TRUE, ncol=4)))

95% family-wise confidence level

Linear Function

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.

vacuum 5.26 vacuum 5.44 vacuum 5.

mixed 7.41 mixed 7.33 mixed 7.

CO2 3.51 CO2 2.91 CO2 3.

* ORDER=DATA says plastic < vacuum < mixed < CO2 in Labels otherwise sorts

proc glm data=meat order=data;

class condition;

model logcount=condition;

output out=new p=yhat r=resid;

contrast 'plastic vs. rest' condition 3 -1 -1 -1;

estimate 'plastic vs. rest' condition 3 -1 -1 -1;

contrast 'CO2 vs. plastic' condition -1 0 0 1;

estimate 'CO2 vs. plastic' condition -1 0 0 1;

contrast 'CO2 vs. vacuum' condition 0 -1 0 1;

estimate 'CO2 vs. vacuum' condition 0 -1 0 1;

contrast 'CO2 vs. mixed' condition 0 0 -1 1;

estimate 'CO2 vs. mixed' condition 0 0 -1 1;

run;

* output (edited)

The GLM Procedure Dependent Variable: logcount Sum of Source DF Squares Mean Square F Value Pr > F Model 3 32.87280000 10.95760000 94.58 <. Error 8 0.92680000 0. Corrected Total 11 33.

R-Square Coeff Var Root MSE logcount Mean 0.972580 5.768940 0.340367 5.

Source DF Type I SS Mean Square F Value Pr > F condition 3 32.87280000 10.95760000 94.58 <.

Source DF Type III SS Mean Square F Value Pr > F condition 3 32.87280000 10.95760000 94.58 <.

Contrast DF Contrast SS Mean Square F Value Pr > F plastic vs. rest 1 9.98560000 9.98560000 86.19 <. CO2 vs. plastic 1 25.46160000 25.46160000 219.78 <. CO2 vs. vacuum 1 6.86940000 6.86940000 59.30 <. CO2 vs. mixed 1 22.81500000 22.81500000 196.94 <.

Dependent Variable: logcount

Standard Parameter Estimate Error t Value Pr > |t| plastic vs. rest 6.32000000 0.68073490 9.28 <. CO2 vs. plastic -4.12000000 0.27790886 -14.83 <. CO2 vs. vacuum -2.14000000 0.27790886 -7.70 <. CO2 vs. mixed -3.90000000 0.27790886 -14.03 <.

Example: The Meat study with using logCounts

Using R

> library(multcomp)

Loading required package: mvtnorm

> confint(MeatANOVA)

(Intercept) 2.906844 3.

Condition[T.mixed] 3.259141 4.

Condition[T.plastic] 3.479141 4.

Condition[T.vacuum] 1.499141 2.

> 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.

Linear Hypotheses:

Estimate lwr upr

mixed - CO2 == 0 3.9000 3.0100 4.

plastic - CO2 == 0 4.1200 3.2300 5.

vacuum - CO2 == 0 2.1400 1.2500 3.

plastic - mixed == 0 0.2200 -0.6700 1.

vacuum - mixed == 0 -1.7600 -2.6500 -0.

vacuum - plastic == 0 -1.9800 -2.8700 -1.

95% family-wise confidence level

> plot(print(confint(glht(MeatANOVA, linfct=mcp(Condition="Tukey")))))

-2 0 2 4

  • plastic
    • mixed
    • mixed

m - CO

c - CO

d - CO2 (

(

(

(

(

(

) ) ) ) ) )

95% family-wise confidence level

Linear Function

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.

vacuum 5.26 vacuum 5.44 vacuum 5.

mixed 7.41 mixed 7.33 mixed 7.

CO2 3.51 CO2 2.91 CO2 3.

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 <. 2 <.0001 0.0002 <. 3 0.4514 0.0002 <. 4 <.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. Error Degrees of Freedom 8 Error Mean Square 0. Critical Value of t 2. Half Width of Confidence Interval 0.

95% Confidence condition N Mean Limits plastic 3 7.4800 7.0268 7. mixed 3 7.2600 6.8068 7. vacuum 3 5.5000 5.0468 5. CO2 3 3.3600 2.9068 3.

B 5.5000 3 vacuum

C 3.3600 3 CO

means condition / bon tukey cldiff;

Tukey's Studentized Range (HSD) Test for logcount

NOTE: This test controls the Type I experimentwise error rate. Alpha 0. Error Degrees of Freedom 8 Error Mean Square 0. Critical Value of Studentized Range 4. Minimum Significant Difference 0.

Comparisons significant at the 0.05 level are indicated by ***.

Difference condition Between Simultaneous 95% Comparison Means Confidence Limits plastic - mixed 0.2200 -0.6700 1. plastic - vacuum 1.9800 1.0900 2.8700 *** plastic - CO2 4.1200 3.2300 5.0100 *** mixed - plastic -0.2200 -1.1100 0. mixed - vacuum 1.7600 0.8700 2.6500 *** mixed - CO2 3.9000 3.0100 4.7900 *** vacuum - plastic -1.9800 -2.8700 -1.0900 *** vacuum - mixed -1.7600 -2.6500 -0.8700 *** vacuum - CO2 2.1400 1.2500 3.0300 *** CO2 - plastic -4.1200 -5.0100 -3.2300 *** CO2 - mixed -3.9000 -4.7900 -3.0100 *** CO2 - vacuum -2.1400 -3.0300 -1.2500 **

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 Tukey's for all pairwise comparisons. Alpha 0. Error Degrees of Freedom 8 Error Mean Square 0. Critical Value of t 3. Minimum Significant Difference 0.

Comparisons significant at the 0.05 level are indicated by ***. Difference condition Between Simultaneous 95% Comparison Means Confidence Limits plastic - mixed 0.2200 -0.7468 1. plastic - vacuum 1.9800 1.0132 2.9468 *** plastic - CO2 4.1200 3.1532 5.0868 *** mixed - plastic -0.2200 -1.1868 0. mixed - vacuum 1.7600 0.7932 2.7268 *** mixed - CO2 3.9000 2.9332 4.8668 *** vacuum - plastic -1.9800 -2.9468 -1.0132 *** vacuum - mixed -1.7600 -2.7268 -0.7932 *** vacuum - CO2 2.1400 1.1732 3.1068 *** CO2 - plastic -4.1200 -5.0868 -3.1532 *** CO2 - mixed -3.9000 -4.8668 -2.9332 *** CO2 - vacuum -2.1400 -3.1068 -1.1732 ***