2 way anova

download 2 way anova

of 20

description

Anova Testing- Stats

Transcript of 2 way anova

  • 4.5. Two-way ANOVA

    Example. (Moore/McCabe Example 13.34)

    Red palm oil, due to its high content of vi-

    tamin A, is thought to reduce the occurence

    and severity of malarity for young children.

    To investigate whether this is indeed the case,

    a supplement will be prepared that contains

    either a placebo, a low dose, or a high dose

    of red palm oil. Because boys and girls may

    differ in exposure to malaria and the response

    to the red palm oil supplement, we consider a

    two-way ANOVA, that takes also gender into

    account. Suppose we recruit 75 boys and 75

    girls to the study. We will then randomly as-

    sign 25 of each gender to each of the red

    palm oil levels:

    GenderRed palm oil Girls Boys TotalPlacebo 25 25 50Low dose 25 25 50High dose 25 25 50Total 75 75 150

    165

  • This example illustrates several advantagesof two-way designs. The first is efficiency.With a two-way design, we can use the sametool to answer two questions: 1. Does redpalm oil/ 2. Does gender have an impactupon prevalence of malaria? That is, we gettwo one-way ANOVAs for the price of one.

    The second and more important advantage isthat we may investigate interactions betweenfactors. Suppose that boys and girls reactindeed differently to the red palm oil supple-ment. That piece of information would notcome out in one-way ANOVAs neither for redpalm oil nor for gender.

    The final advantage is increased power of thetests. Suppose we would run a one-way de-sign and there are indeed differences betweenboys and girls. The one-way ANOVA wouldassign this variation to the residual (withingroups) part of the model. In the two-wayANOVA, gender is included in the fit (be-tween groups) part of the model, which in-creases the power of the tests.

    166

  • Assumptions for Two-Way ANOVA

    The assumptions for two-way ANOVA arethe same as for one-way ANOVA, just thatwe have now 2 instead of only 1 factor:

    We have independent random samples of sizenij from each of I J normal populations.The population means ij may differ, but allpopulations have the same variance 2.

    Let xijk represent the kth observation fromthe population having factor A at level i andfactor B at level j. The statistical model is

    Xijk = ij + ijk, where

    i = 1, . . . , I; j = 1, . . . , J; k = 1, . . . , nij; andijk N(0, 2).

    We estimate ij by xij =1

    nij

    nijk=1

    xijk,

    and 2 by (using s2ij =nij

    k=1(xijkxij)2/(nij1)):

    s2 =

    ij(nij 1)s2ijN IJ =

    SSE

    DFE= MSE,

    where DFE = observationsgroups = NIJ.167

  • Main effects and interactions

    We shall now explore in detail the FIT part of themodel, represented by the population means ij.

    Because we have independent samples from each group,

    we can think of the problem initially as a one-way

    ANOVA with IJ groups, that is SST = SSM + SSE,

    where

    SSM =I

    i=1

    Jj=1

    nijk=1

    (xij x)2

    with DFM = groups1 = IJ 1.In two-way ANOVA, the terms SSM and DFM are

    broken down into a main effect for A, a main effect

    for B, and an AB interaction as follows:

    SSM = SSA + SSB + SSABDFM = DFA + DFB + DFAB

    SSA represents variation among the means for the

    different levels of A. Because there are I such means,

    SSA has DFA= I 1 degress of freedom. Similarly,DFB= J 1. For DFAB we obtain by subtraction:

    DFAB = DFMDFADFB= (IJ 1) (I 1) (J 1)= (I 1)(J 1).

    168

  • The two-way ANOVA model

    Taking the split up of the population meansij into main effects and an interaction effectinto account, the two-way ANOVA modelmay be restated as

    Xijk=

    ij +i+j+()ij +ijk, ijkN(0, 2),

    where is the overall mean; i is the effectof level i (i = 1, . . . , I) of factor A; j is theeffect of level j (j = 1, . . . , J) of factor B;()ij is the interaction effect of levels i andj; and ijk is the error associated with thekth data point from level i of factor A andlevel j of factor B.

    Note that since i, j and ()ij are devi-ations from the overall mean , in the fixedeffects model the sums of all these deviationsare zero:

    i

    i =j

    j =i,j

    ()ij = 0.

    169

  • The Hypothesis Tests in Two-Way ANOVA

    Factor A main-effects test:

    H0 : i = 0 for all i = 1, . . . , IH1 : Not all i are zero

    F = MSA/MSE F (I 1, N IJ).

    Factor B main-effects test:

    H0 : j = 0 for all j = 1, . . . , JH1 : Not all j are zero

    F = MSB/MSE F (J 1, N IJ).

    Test for AB interactions:

    H0 : ()ij = 0 i=1,. . .,I; j=1,. . .,JH1 : Not all ()ij are zero

    F = MSAB/MSE F ((I1)(J1), NIJ).

    Note: Finding a significant interaction effectsubstantially reduces the usefulness of factorA/B main effects, because then they applyonly on average, but not individually for eachlevel of the other factor.

    170

  • Example: (Azcel, 4th edition.)

    The brightness of films produced by 3 differ-ent manufacturers has been compared using3 different development processes:

    All p-values are below 0.01%, so both man-ufacturer and development method have animpact.

    There is also an interaction effect:

    F = 61.756/5.811 = 10.627Degrees of freedom:(3 1)(3 1) = 4 and 45 3 3 = 36Critical value: F0.05(4,36) = 2.63

    This implies that main effects must be checkedfor each level of the other factor separately.

    171

  • Analyze => ANOVA => Linear Models ...

    Model: Process, Film => Factorial

  • Model Options => Sum of Squares to show: Type III

    Plots => Custom list of Plots => Interaction Plot

  • Linear Models Dependent Variable: Brightness Brightness

    Source DF Sum of

    Squares Mean Square F Value Pr > F

    Model 8 1776.044444 222.005556 38.20 F

    Process 2 165.644444 82.822222 14.25

  • Two-Way ANOVA with 1 Observation/Cell

    The case of one data point in every cell presentsa problem in two-way ANOVA because then

    DFE = observations groups = 0.However, if we may assume that there are nointeractions, then SSAB is only due to errorand contains no other information. In thatcase we may use SSAB and its associateddegrees of freedom DFAB= (I 1)(J 1) inplace of SSE and its degrees of freedom.

    We can thus conduct the tests for the maineffects by dividing MSA (MSB) by MSABwhen testing for factor A (factor B) maineffects. The resulting F -statistics has I 1and (I1)(J1) degrees of freedom for fac-tor A, and J 1 and (I 1)(J 1) degreesof freedom for factor B.

    The fixed effects two-way ANOVA model withone observation per cell reduces then to:

    Xijk = + i + j + ijk, ijk N(0, 2).175

  • Randomized Complete Block Design

    When we want to compare the means of kpopulation means while controlling extrane-ous variables, a procedure known as blockingis used. A block (lohko) is a collection of kexperimental units that are as nearly alike aspossible with respect to the extraneous vari-ables. (A block could be the same persontrying k different products.)

    Each treatment is randomly assigned to 1unit within each block (random order in try-ing the products). Since the effect of theextraneous variables is controlled by match-ing like experimental units, any differences inresponse are attributed to treatment effects.

    This randomized complete block design (alsocalled one-way ANOVA with repetition) maybe regarded as a two-way ANOVA with oneitem per cell because the blocks may be viewedas one factor and the treatment levels as theother. In the randomized block design, how-ever, we are only interested in the treatmentlevels and not in the blocks.

    176

  • Because the randomized complete block de-

    sign is just a two-way ANOVA with one ob-

    servation per cell, we may test the null hy-

    pothesis

    H0 : 1 = 2 = = k.with an F -test of the form

    F =MSTR

    MSE F (k 1, (k 1)(b 1)),

    where k denotes the number of treatments

    and b denotes the number of blocks.

    Note that the randomized complete block de-

    sign assumes that there is no interaction be-

    tween treatments and blocks!

    177

  • Example: (Cochran & Snedecor)

    Below are percentages of soya beans fail-

    ing to sprout, planted under 5 individually

    identical conditions (blocks) under 5 differ-

    ent treatments, with ANOVA output from

    Excel:

    Degrees of freedom:

    Treatment: 5 1 = 4Block: 5 1 = 4Error: (5 1)(5 1) = 16

    There is a significant main effect for treat-

    ments, but not for blocks.

    178

  • Further Two-Way Analysis

    Post hoc tests and contrasts work in muchthe same way as in one-way ANOVA. We onlyneed to replace MSE from one-way ANOVAwith the new MSE for two-way ANOVA asthe new estimator s2 for the variance 2.

    Example: (soya beans continued.)Consider using the Bonferroni method to com-pare all

    (52

    )= 542 = 10 pairs of treatment.

    The combined significance level at 5% is

    = 0.05/10 = 0.005.

    The standard error for differences in treat-ment means is

    SEB =

    s2( 1ni

    +1

    nj

    )=

    5.41 2

    5= 1.471.

    The degrees of freedom are

    df = (k 1)(b 1) = 4 4 = 16,so the smallest significant difference becomes

    t0.005/2(16) SEB = 3.252 1.471 = 4.78.Only the difference of the pair FermateNoneexceeds this value and is therefore significant.

    179

  • Analyze => ANOVA => Mixed Models... Dependent variable: Failures Classification variables: Treatment, Block => Fixed Effect Model: Treatment, Block => Main => Fixed Effect Model Options:

    => Least Squares Post Hoc Tests => Add:

  • Mixed Models Analysis of: Failures

    Covariance Parameter Estimates

    Cov Parm Estimate

    Residual 5.4100

    Type 3 Tests of Fixed Effects

    Effect Num

    DFDen DF F Value Pr > F

    Treatment 4 16 3.87 0.0219

    Block 4 16 2.30 0.1032

    Least Squares Means

    Effect Treatment EstimateStandard

    Error DF t Value Pr > |t|

    Treatment 1 6.2000 1.0402 16 5.96

  • Example: (film processing continued.)

    Consider testing the following two contrasts:

    H0(1): A =12(B + C), H0(2): B = C.

    A B C2i

    Xi 33.867 30.733 29.267i(1) 1 -0.5 -0.5 1.5i(2) 0 1 -1 2

    The contrast values and standard errors are:

    L1 = 3.867, s(L1) =

    5.811 1.5/15 = 0.762L2 = 1.467, s(L2) =

    5.811 2/15 = 0.880

    after inserting MSW=5.811 and n=15 into

    s(L) =

    MSE

    2i /n.

    The t-statistics for the two contrasts are:

    t1 =L1

    s(L1)= 5.07 and t2 =

    L2s(L2)

    = 1.67

    with df = N IJ = 453 3 = 36, such thatt0.025(36) = 2.03; p1 = 0.000, p2 = 0.104.

    So we reject H0(1) and accept H0(2).

    182

  • Analyze => ANOVA => Linear Models ... Post Hoc Tests => Add Class effects to use: Process: True Show p-values for differences: All pairwise differences Preview Code => Insert Code

    OK => OK => Run

  • Linear Models

    Least Squares Means

    ProcessBrightness

    LSMEANLSMEAN Number

    1 33.8666667 1

    2 30.7333333 2

    3 29.2666667 3

    Least Squares Means for effect Process Pr > |t| for H0: LSMean(i)=LSMean(j)

    Dependent Variable: Brightness

    i/j 1 2 3

    1 0.0011