two-way anova introduction to factorial designs and their analysis

41
Two-way ANOVA Two-way ANOVA Introduction to Factorial Introduction to Factorial Designs Designs and their Analysis and their Analysis

Upload: dominic-allen

Post on 31-Dec-2015

226 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Two-way ANOVATwo-way ANOVA

Introduction to Factorial Introduction to Factorial Designs Designs

and their Analysisand their Analysis

Page 2: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Two-Way ANOVA Data LayoutTwo-Way ANOVA Data Layout

Xijk

Level i Factor

A

Level j Factor

B

Observation k in each cell

Factor Factor BA 1 2 ... b

1 X111 X121 ... X1b1

X11n X12n ... X1bn

2 X211 X221 ... X2b1

X21n X22n ... X2bn

: : : : :

a Xa11 Xa21 ... Xab1

Xa1n Xa2n ... Xabn

i = 1,…,aj = 1,…,bk = 1,…,n

There are a X b treatment combinations

Page 3: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Motivating Example: Motivating Example: Capsule Dissolve TimeCapsule Dissolve Time

Suppose are looking at two capsule types Suppose are looking at two capsule types (C or V) & two digestive fluids (Gastric (C or V) & two digestive fluids (Gastric or Duodenal)or Duodenal) Randomly assign 5

capsules of each type to each of type of digestive juice and observe dissolve time.

Xijk = measured dissolve time for capsule k in digestive juice i and capsule type j.

i = 1 or 2 (i.e. G and D)j = 1 or 2 (i.e. C and V)k = 1,2,3,4,5

Page 4: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Questions of InterestQuestions of Interest

What effect does What effect does capsule typecapsule type have on the time to dissolve?have on the time to dissolve?

What effect does What effect does fluid typefluid type have on the time to dissolve?have on the time to dissolve?

Do both capsule types dissolve Do both capsule types dissolve in the same manner in the in the same manner in the two different fluid types?two different fluid types?

Page 5: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Plotting the Results ~ Capsule Effect

seconds 42.85 dissolve tocapsules V for type mean time

seconds 05.43 dissolve tocapsules C for type mean time

2

1

X

X

Tim

e U

nti

l B

ub

ble

s (s

eco

nd

s)

Capsule Type

There appears to be very little difference between the capsule types in terms of the time it takes them to dissolve.

Page 6: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Plotting the Results ~ Fluid Effect

seconds 40.2 juice duodenalin dissolve tocapsulesfor mean time

seconds 7.45 juice gastricin dissolve tocapsulesfor mean time

2

1

X

X

Fluid Type

Capsules take 5.5 seconds longer on average to dissolve in gastric juice compared to duodenal juice.

Page 7: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Preliminary ConclusionPreliminary Conclusion

There is very little difference between the There is very little difference between the capsule types in terms of the length it time capsule types in terms of the length it time it takes them to dissolve. it takes them to dissolve.

Capsules take about 5 seconds longer on Capsules take about 5 seconds longer on average to dissolve in gastric juice than in average to dissolve in gastric juice than in duodenal juice. duodenal juice.

THESE CONCLUSIONS ARE THESE CONCLUSIONS ARE COMPLETELY WRONG!! COMPLETELY WRONG!! WHY ?!?WHY ?!?

Page 8: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Plotting the Results ~ Capsule Effect Separately

seconds 44.1 juice duodenalin dissolve tocapsules Vfor mean time

seconds 36.3 juice duodenalin dissolve tocapsules Cfor mean time

seconds 41.6 juice gastricin dissolve tocapsules Vfor mean time

seconds 8.49 juice gastricin dissolve tocapsules Cfor mean time

22

21

12

11

X

X

X

X

Clearly the time to dissolve depends on what capsule is being used and which juice it is being dissolved in.

Type C capsules dissolve faster in duodenal juice than do type V capsules where for gastric juice the opposite is true.

Page 9: Two-way ANOVA Introduction to Factorial Designs and their Analysis

InteractionsInteractionsThe capsule study is an example of The capsule study is an example of

situation where there is an situation where there is an interactioninteraction between the two factors being studied between the two factors being studied in terms of their effect on the numeric in terms of their effect on the numeric response.response.

An An interactioninteraction occurs when the effect of occurs when the effect of one factor depends on the level of one factor depends on the level of another factor. Here the effect of another factor. Here the effect of capsule depends on the type of digestive capsule depends on the type of digestive juice used to dissolve it and vise versa. juice used to dissolve it and vise versa.

Type C capsules dissolve faster than Type V in duodenal juice, where opposite is true when gastric juice is used to dissolve the capsules.

Page 10: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Interactions can “mask” Interactions can “mask” main effectsmain effects

The apparent lack of a capsule effect is caused by the interaction of capsule type and fluid type.

We say the interaction masks the main effect of capsule type.

Page 11: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Types of Interactions and Types of Interactions and Interpreting Interaction PlotsInterpreting Interaction Plots

Here the mean response is the same for both levels of both factors.

Here both effects are masked by the interaction. This type of interaction is called a “difference in direction” of the effects.

Page 12: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Types of Interactions and Types of Interactions and Interpreting Interaction PlotsInterpreting Interaction Plots

Here the mean response differs depending on the level of B but not A.

Here the A main effect is “masked” by the interaction. The B main effect is significant, although cannot be talked about independently of the level of A.

Page 13: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Types of Interactions and Types of Interactions and Interpreting Interaction PlotsInterpreting Interaction Plots

Here the effect of A is the same for both levels of B. There is minimal separation between the two profiles for the levels of B, thus B is not significant

Here the A main effect is differs depending on the level of B. The B main effect is masked by the interaction as the means for B1 and B2 are the same.

Page 14: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Types of Interactions and Types of Interactions and Interpreting Interaction PlotsInterpreting Interaction Plots

Here the effect of A is the same for both levels of B and vise versa. The response differs across the level of both factors and both differences suggest significant A & B effects.

Here the A main effect is differs depending on the level of B. Neither the A or B main effects are masked by the interaction.

This type of interaction is a difference in magnitude the effect. The direction of A main effect is the same for both levels of B, however the A effect is larger when B is at the 1st level.

Page 15: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Types of InteractionsTypes of Interactions

In summary there are types of In summary there are types of interactions:interactions:

Differences in Direction Differences Differences in Direction Differences in Magnitudein Magnitude

Always construct an interaction plot to visualize the interaction or lack thereof !

Page 16: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Questions of InterestQuestions of InterestGenerally, the questions of interest here Generally, the questions of interest here

(i.e. hypotheses to be tested) concern (i.e. hypotheses to be tested) concern three questions regarding the potential three questions regarding the potential effects of the factors on the response effects of the factors on the response variable.variable.

Question 1:Question 1: Do the effects that factors Do the effects that factors A A and and BB have on the response variable have on the response variable interactinteract, i.e. is there a significant , i.e. is there a significant interactioninteraction between factors between factors AA and and BB ??

Page 17: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Questions of InterestQuestions of Interest

If we conclude there is a significant If we conclude there is a significant interaction then we conclude interaction then we conclude the the effects of both factors effects of both factors A and B are significant!A and B are significant!

When we have an interaction we When we have an interaction we cannot consider the effect of either cannot consider the effect of either factor independently of the other, factor independently of the other, therefore both factors matter.therefore both factors matter.

Page 18: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Questions of Interest Questions of Interest

If there is If there is not a significant not a significant interactioninteraction effect then we can effect then we can consider the main effects consider the main effects separately, i.e. we ask the separately, i.e. we ask the following:following:

Question 2:Question 2: Does factor Does factor AA alonealone have a significant effect?have a significant effect?

Question 3:Question 3: Does factor Does factor BB alonealone have a significant effect?have a significant effect?

Page 19: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Tests of HypothesesTests of Hypotheses

Just as we had Sums of Squares and Just as we had Sums of Squares and Mean Squares in Mean Squares in One-wayOne-way ANOVAANOVA, we , we have the same in have the same in Two-way ANOVA:Two-way ANOVA:

Recall, Mean Squares are measures of Recall, Mean Squares are measures of variability across the levels of the relevant variability across the levels of the relevant factor of interest.factor of interest.

In balanced In balanced Two-way ANOVATwo-way ANOVA, we , we measure the overall variability in the data measure the overall variability in the data by: by: 1 )(

1 1 1

2

NdfXXSSa

i

b

j

n

kijkT

Page 20: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Tests of HypothesesTests of Hypotheses

1 )()(1

2

1 1 1

2

adfXXbnXXSSa

ii

a

i

b

j

n

kiA

a

i

b

j

n

k

b

jjjB bdfXXanXXSS

1 1 1 1

22 1 )()(

Sum of Squares for factor A

Sum of Squares for factor B

Measures variation in the response due to the fact that different levels of factor A were used.

Measures variation in the response due to the fact that different levels of factor B were used.

Page 21: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Test of HypothesesTest of HypothesesInteraction Sum of SquaresInteraction Sum of Squares

a

i

b

j

n

kjiijAB badfXXXXSS

1 1 1

2 )1)(1( )(

Error or Residual Sum of SquaresError or Residual Sum of Squares

a

i

b

j

n

kijijkE nabdfXXSS

1 1 1

2 )1( )(

Measures the variation in the response due to the interaction between factors A and B. If the interaction plot is perfectly parallel this will be 0!

Measures the variation in the response within the a x b factor combinations.

Page 22: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Tests of HypothesesTests of Hypotheses

So the Two-way ANOVA Identity is:

This partitions the Total Sum of Squares into four pieces of interest for our hypotheses to be tested.

EABBAT SSSSSSSSSS

Page 23: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Tests of HypothesesTests of HypothesesAs in One-way As in One-way ANOVAANOVA, we obtain , we obtain mean mean

squaressquares for the different effects by dividing for the different effects by dividing the sums of squares by their respective the sums of squares by their respective degrees of freedomdegrees of freedom

i.e. i.e.

These are our measures of variance for the These are our measures of variance for the analysis. analysis.

If an effect is not significant we expectIf an effect is not significant we expect

and if it is we expect and if it is we expect

effect

effecteffect df

SSMS

Eeffect MSMS

Eeffect MSMS

Page 24: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Test of HypothesesTest of Hypotheses

F-Statistic for Testing an Effect

ondistributiFMS

MSF

E

effecto ~

Numerator df = dfeffect

Denominator df = dferror

If the F-statistic is large we reject that the effect is “zero” in favor of the alternative that the effect of the factor is non-zero.

Page 25: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Two-way ANOVA TableTwo-way ANOVA TableSource ofSource of

VariationVariation

Degrees ofDegrees of

FreedomFreedom

Sum ofSum of

SquaresSquares

MeanMean

SquareSquare FF-ratio-ratio

P-valueP-value

Factor Factor AA aa 1 1 SSSSAA MSMSAA FFA A = = MSMSA A / / MSMSEE Tail areaTail area

Factor Factor BB bb 1 1 SSSSBB MSMSBB FFB B = = MSMSB B / / MSMSEE Tail areaTail area

InteractionInteraction ((aa – 1)( – 1)(bb – 1) – 1) SSSSABAB MSMSABAB FFAB AB = = MSMSAB AB / / MSMSEE Tail areaTail area

ErrorError abab((n n – 1)– 1) SSSSEE MSMSEE

TotalTotal abnabn 1 1 SSSSTT

This is our initial focus which is the p-value for Question 1: Is there an interaction effect?

Page 26: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Tests of HypothesesTests of HypothesesIf the interaction If the interaction is notis not statistically significant statistically significant

(i.e. (i.e. p-valuep-value > 0.05) then we conclude the > 0.05) then we conclude the main effects (if present) are independent of main effects (if present) are independent of one another.one another.

We can then test for significance of the main We can then test for significance of the main effects separately, again using an F-test.effects separately, again using an F-test.

If a main effect is significant we can then use If a main effect is significant we can then use multiple comparison procedures as usual to multiple comparison procedures as usual to compare the mean response for different compare the mean response for different levels of the factor while holding the other levels of the factor while holding the other factor fixed.factor fixed.

Page 27: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Tests of HypothesesTests of HypothesesIf an interaction is significant (p-value < .05) we If an interaction is significant (p-value < .05) we

conclude the main effects are not independent of conclude the main effects are not independent of one another and that both effects are important!one another and that both effects are important!

In this case (i.e. the interaction is significant) the In this case (i.e. the interaction is significant) the tests for main effects in the tests for main effects in the Two-way ANOVATwo-way ANOVA table table areare MEANINGLESSMEANINGLESS!!

We must compare levels of factor A within each level of factor B (and vise versa).

Page 28: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 1: Capsule Example 1: Capsule Dissolve Time Dissolve Time

Enter the n = 5 replicates for each treatment combination: Gastric, CGastric, VDuodenal, CDuodenal, V

Page 29: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 1: Capsule Example 1: Capsule Dissolve TimeDissolve Time

1st Highlight both factors in this list.

Next highlight Full Factorial from the Macros pull-down menu.

Then click Run Model leaving everything else unchanged.

Page 30: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 1: Capsule Example 1: Capsule Dissolve TimeDissolve Time

Lots of extra CRAP we don’t need. Turn off the plots as they are unnecessary when considering two-way ANOVA. Also we really only need to consider the Effect Tests portion of the numeric output initially.

Page 31: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 1: Capsule Example 1: Capsule Dissolve TimeDissolve Time

Interaction effect is statistically significant (p = .0049). Therefore we conclude that both the capsule and fluid type effects are significant, however we cannot talk about their effects in term of the mean time until bubbles are observed independently. We can compare capsule effects for the same fluid type or fluid effects for the same capsule type.

Page 32: Two-way ANOVA Introduction to Factorial Designs and their Analysis

CapsuleCapsule x x Fluid TypeFluid Type InteractionInteraction

Treatment combination means.

Interaction Plot

Because the interaction is statistically significant we are interested in comparing fluid types for a given capsule type or comparing capsules for a given fluid type.

The table on the right contains the results of all pair-wise treatment mean comparisons, however we are only interested in those as described above.

Here we find that there is a significant difference in the fluid types for the type C capsules however there are no significant differences between the capsules themselves for given fluid type, nor is there a fluid effect when dissolving type V capsules.

We estimate that the mean time to dissolve type C capsules in gastric fluid is between 3.57 and 23.43 minutes larger than the mean for duodenal.

Page 33: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Checking AssumptionsChecking Assumptions

To check the assumptions of normality To check the assumptions of normality of the response and equality of of the response and equality of variance for the difference treatment variance for the difference treatment combinations we can examine the combinations we can examine the residualsresiduals. For a two-way ANOVA . For a two-way ANOVA the residuals are the deviations of the residuals are the deviations of the observations from their the observations from their respective treatment combination respective treatment combination sample means, i.e.sample means, i.e. ijijkijk xxe

Page 34: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Checking AssumptionsChecking Assumptions

To check the assumption of normality, To check the assumption of normality, assess the normality of the residualsassess the normality of the residualsijijkijk xxe

The residuals from the capsule experiment look approximately normal with the exception of two outliers, but neither are extreme enough to warrant any concerns.

Page 35: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Checking AssumptionsChecking Assumptions

To check the equality of variance for To check the equality of variance for the difference treatment the difference treatment combinations we can examine the combinations we can examine the residuals plotted vs. the different residuals plotted vs. the different treatment combination meanstreatment combination means

ijijkijk xxe There appears to be more variation for the dissolve times for type C capsules being dissolved in gastric fluid. These combination produced the two mild outliers seen in the normal quantile plot. Generally we worry when the variation increases with the treatment combination mean.

Page 36: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 2:Example 2: Comparing the Effectiveness of Comparing the Effectiveness of Three Forms of Three Forms of

Psychotherapy for Alleviating Depression Psychotherapy for Alleviating Depression

Suppose that a clinical psychologist is Suppose that a clinical psychologist is interested in comparing the relative interested in comparing the relative effectiveness of three forms of psychotherapy for effectiveness of three forms of psychotherapy for alleviating depression. Fifteen individuals are alleviating depression. Fifteen individuals are randomly assigned to each of three treatment randomly assigned to each of three treatment groups: cognitive-behavioral, Rogerian, and groups: cognitive-behavioral, Rogerian, and assertiveness training. The Depression Scale of assertiveness training. The Depression Scale of MMPI serves as the response. The psychologist MMPI serves as the response. The psychologist also wished to incorporate information about the also wished to incorporate information about the patient’s severity of depression, so all subjects in patient’s severity of depression, so all subjects in the study were classified as having mild, the study were classified as having mild, moderate, or severe depression. Thus we have moderate, or severe depression. Thus we have two factor of interest in this study: the two factor of interest in this study: the treatment they received and the initial severity treatment they received and the initial severity of their depression. of their depression.

Page 37: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 2:Example 2: Comparing the Effectiveness of Comparing the Effectiveness of Three Forms of Three Forms of

Psychotherapy for Alleviating Depression Psychotherapy for Alleviating DepressionInteraction Plot

Therapy Effect Plot

Degree of Severity Effect Plot

Page 38: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 2:Example 2: Comparing the Effectiveness of Comparing the Effectiveness of Three Forms of Three Forms of

Psychotherapy for Alleviating Depression Psychotherapy for Alleviating Depression

Is there a significant interaction effect ? NO, p = .9717

Is there a significant therapy effect ?

Is there a significant degree of severity of effect ?

YES, p = .0356

YES, p < .0001

Now we can conduct multiple comparisons on each factor separately.

Page 39: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 2:Example 2: Comparing the Effectiveness of Comparing the Effectiveness of Three Forms of Three Forms of

Psychotherapy for Alleviating Depression Psychotherapy for Alleviating Depression

We see that Rogerian therapy differs significantly from Cognitive-Behavioral therapy, with Rogerian having larger mean by between .8 and 9.87 units.We see that the initial severity of

depression levels significantly differ from each other in terms of mean depression score. In particular we see that those with a severe classification have a mean depression score exceeding that for those with mild depression by between 8 and 18 points and those with moderate depression by between 2 and 11.5 points.

Page 40: Two-way ANOVA Introduction to Factorial Designs and their Analysis

Example 2:Example 2: Comparing the Effectiveness of Comparing the Effectiveness of Three Forms of Three Forms of

Psychotherapy for Alleviating Depression Psychotherapy for Alleviating Depression

Residuals look approximately normal.

Residuals indicate constant variation within each treatment combination.

Page 41: Two-way ANOVA Introduction to Factorial Designs and their Analysis

SummarySummary

• These ideas can be extended to more than two factors.

• When interactions exist, the main effects are involved are important, but cannot discussed separately.

• Multiple comparisons can still be conductedto compare different treatment level means.