V. Experiments With Two Crossed Treatment Factors

Similar documents
IX. Complete Block Designs (CBD s)

Two-factor studies. STAT 525 Chapter 19 and 20. Professor Olga Vitek

The legacy of Sir Ronald A. Fisher. Fisher s three fundamental principles: local control, replication, and randomization.

ANALYSIS OF VARIANCE OF BALANCED DAIRY SCIENCE DATA USING SAS

STAT 705 Chapter 19: Two-way ANOVA

3. Design Experiments and Variance Analysis

Ch 2: Simple Linear Regression

Two-Way Analysis of Variance - no interaction

STAT 705 Chapter 19: Two-way ANOVA

Allow the investigation of the effects of a number of variables on some response

Analysis of Variance and Design of Experiments-I

Outline Topic 21 - Two Factor ANOVA

1 Tomato yield example.

Topic 6. Two-way designs: Randomized Complete Block Design [ST&D Chapter 9 sections 9.1 to 9.7 (except 9.6) and section 15.8]

SAS Commands. General Plan. Output. Construct scatterplot / interaction plot. Run full model

Formal Statement of Simple Linear Regression Model

Lec 1: An Introduction to ANOVA

DESAIN EKSPERIMEN Analysis of Variances (ANOVA) Semester Genap 2017/2018 Jurusan Teknik Industri Universitas Brawijaya

Chapter 15: Analysis of Variance

Theorem A: Expectations of Sums of Squares Under the two-way ANOVA model, E(X i X) 2 = (µ i µ) 2 + n 1 n σ2

Analysis of Variance

STAT 115:Experimental Designs

Outline. Topic 19 - Inference. The Cell Means Model. Estimates. Inference for Means Differences in cell means Contrasts. STAT Fall 2013

Factorial and Unbalanced Analysis of Variance

COMPLETELY RANDOM DESIGN (CRD) -Design can be used when experimental units are essentially homogeneous.

Unit 27 One-Way Analysis of Variance

Lecture 5: Comparing Treatment Means Montgomery: Section 3-5

Estimating σ 2. We can do simple prediction of Y and estimation of the mean of Y at any value of X.

Statistics For Economics & Business

Laboratory Topics 4 & 5

Chapter 8 Heteroskedasticity

2 Hand-out 2. Dr. M. P. M. M. M c Loughlin Revised 2018

Unit 12: Analysis of Single Factor Experiments

Ch. 1: Data and Distributions

Linear Combinations. Comparison of treatment means. Bruce A Craig. Department of Statistics Purdue University. STAT 514 Topic 6 1

Unit 8: 2 k Factorial Designs, Single or Unequal Replications in Factorial Designs, and Incomplete Block Designs

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model

Incomplete Block Designs

Factorial designs. Experiments

WITHIN-PARTICIPANT EXPERIMENTAL DESIGNS

Inference for the Regression Coefficient

TWO OR MORE RANDOM EFFECTS. The two-way complete model for two random effects:

Group comparison test for independent samples

Fractional Factorial Designs

Review of Statistics 101

Topic 12. The Split-plot Design and its Relatives (continued) Repeated Measures

Analysis of Variance (ANOVA)

Topic 13. Analysis of Covariance (ANCOVA) [ST&D chapter 17] 13.1 Introduction Review of regression concepts

STAT 506: Randomized complete block designs

Lecture 3: Inference in SLR

Introduction to Design and Analysis of Experiments with the SAS System (Stat 7010 Lecture Notes)

Topic 9: Factorial treatment structures. Introduction. Terminology. Example of a 2x2 factorial

Two-Factor Full Factorial Design with Replications

W&M CSCI 688: Design of Experiments Homework 2. Megan Rose Bryant

Contrasts and Multiple Comparisons Supplement for Pages

Lecture 9: Factorial Design Montgomery: chapter 5

T-test: means of Spock's judge versus all other judges 1 12:10 Wednesday, January 5, judge1 N Mean Std Dev Std Err Minimum Maximum

Unit 7: Random Effects, Subsampling, Nested and Crossed Factor Designs

Introduction to Analysis of Variance (ANOVA) Part 2

Unbalanced Data in Factorials Types I, II, III SS Part 1

Chapter 10. Design of Experiments and Analysis of Variance

4.8 Alternate Analysis as a Oneway ANOVA

Assignment 6 Answer Keys

More about Single Factor Experiments

Analysis of Covariance

One-Way ANOVA. Some examples of when ANOVA would be appropriate include:

If we have many sets of populations, we may compare the means of populations in each set with one experiment.


STAT 705 Chapters 23 and 24: Two factors, unequal sample sizes; multi-factor ANOVA

Lecture 15 Topic 11: Unbalanced Designs (missing data)

Descriptions of post-hoc tests

Analysis of Variance

PLS205!! Lab 9!! March 6, Topic 13: Covariance Analysis

Design & Analysis of Experiments 7E 2009 Montgomery

Linear Combinations of Group Means

The Random Effects Model Introduction

Confidence Intervals, Testing and ANOVA Summary

PLS205 Lab 2 January 15, Laboratory Topic 3

Chap The McGraw-Hill Companies, Inc. All rights reserved.

STAT 401A - Statistical Methods for Research Workers

Two-Way Factorial Designs

Lecture 3. Experiments with a Single Factor: ANOVA Montgomery 3-1 through 3-3

Ch. 5 Two-way ANOVA: Fixed effect model Equal sample sizes

A posteriori multiple comparison tests

Chapter 8: Hypothesis Testing Lecture 9: Likelihood ratio tests

STAT 5200 Handout #7a Contrasts & Post hoc Means Comparisons (Ch. 4-5)

Lecture 7: Latin Square and Related Design

Statistical Analysis of Unreplicated Factorial Designs Using Contrasts

Lecture 7 Randomized Complete Block Design (RCBD) [ST&D sections (except 9.6) and section 15.8]

Chapter 20 : Two factor studies one case per treatment Chapter 21: Randomized complete block designs

These are all actually contrasts (the coef sum to zero). What are these contrasts representing? What would make them large?

Lecture 4. Random Effects in Completely Randomized Design

Diagnostics and Remedial Measures

In a one-way ANOVA, the total sums of squares among observations is partitioned into two components: Sums of squares represent:

df=degrees of freedom = n - 1

Multiple Regression Analysis

Psychology 282 Lecture #4 Outline Inferences in SLR

Multiple Linear Regression

Outline. Topic 22 - Interaction in Two Factor ANOVA. Interaction Not Significant. General Plan

Assessing Model Adequacy

Transcription:

V. Experiments With Two Crossed Treatment Factors A.The Experimental Design Completely Randomized Design (CRD) Let A be a factor with levels i = 1,,a B be a factor with levels j = 1,,b Y ijt = the response obtained on the t th observation of the i th level of treatment factor A and the j th level of treatment factor B ijt = the error variable (or variation attributable to randomness and nuisance) The basic (cell means) model is now Y ijt = µ + τ ij+ ijt We can rewrite this model by substituting which results in τ ij = α i + βj Y ijt = µ + α i + β j+ ijt Again, we need to make some assumptions about the error terms ijt in order to statistically analyze the results of a CRD experiment: - ijt ~ N(0, σ ) - ijt s are mutually independent, t = 1,,r ij, i = 1,,a, j = 1,,b These assumptions facilitate an Analysis Of Variance (ANOVA), which when applied to this CRD is called a Two-Way Additive or Main Effects Model.

Also note that: the assumptions imply that Y it ~ N(u i,σ ) for the means model or Y it ~ N(u + τ i,σ ) for the effects model This model implies that the two treatment factor effects are independent what if they are not? This would imply the change in the response Y ijt that corresponds to changes in one treatment factor (say A) differs across levels of the other treatment factor (say B). The treatment effect is now given by τ ij = α i + β j + ( αβ) ij which by substitution yields the Two-Way Complete or Two-Way ANOVA Model Y = µ + α + β + αβ + ijt i j ij ijt The Two-Way Complete or Two-Way ANOVA Model should be used unless the experimenter has explicit information about the lack of existence of an interaction. To do otherwise (i.e., ignore an existing interaction) can result in very misleading inferences on the main effects: Crunchiness Rating 100 80 Interaction Plot 60 40 10 M inutes 1 M inutes 0 0 350º 400º Baking Temperature

B. Checking Model Assumptions We check the model assumptions in the same manner as with a one-factor CRD: We calculate the standardized residuals where z = ijt y ijt - yˆ ijt sse n - 1 Y ˆ = µ ˆ + ˆτ = µ ˆ + α ˆ + β ˆ + αβ or Yˆ ijt ij i j ij ijt = µ ˆ + ˆτ = µ ˆ + α ˆ + βˆ ij i j depending on the model selected. We plot the standardized residuals z ijt against: - order of observation to check independence ^ - levels of each factor A and B and estimated responses y ijt to check for outliers and homogeneity of variances - normal scores to check for normality

We also - use a Durbin-Watson test if the plot of the standardized residuals against order of observation suggests a lack of independence - use the Hartley, Levine, Box, Breusch-Pagan, Cochran, or Bartlett test if plots of the standardized residuals against ^ levels of each factor A and B or estimated responses y ijt suggest heteroskedasticity - use Shapiro-Wilk test if the plot of standardized residuals against normal scores indicates lack of normality - use interaction plots to check the assumption of no interaction if using a main-effects model if sufficient observations are made to allow the corresponding calculations to be made. C. Contrasts The cell means model Y ijt = µ + τ ij+ ijt is equivalent to the one-way ANOVA model, so all contrasts in the treatment effects τ ij are estimable. This leads to three broad categories of contrasts for a two-way model: 1.Treatment Contrasts these are contrasts of the form a b i=1 j=1 d and are no different from contrasts encountered in the one-way model. All previously discussed approaches to inference are applicable. ij τ ij

.Interaction Contrasts used to test if interactions are significant (i.e., do the lines in an interaction plot differ significantly from being parallel?). These contrasts are of the form a b a b d ijτ ij = d ij ( αβ) ij i = 1 j= 1 i = 1 j= 1 where and a i=1 b j=1 d = 0 j ij d = 0 i ij The most common type of interaction contrast has coefficients d ij = c i k j where c s = k h = 1, c s+1 = k g = -1, and all other c i and k j are zero What is the purpose of such a contrast?

For example, an interaction contrast could look like this ( τsh - τ ) - τsg - τ s+1 h s+1 g To recognize this as an interaction contrast recall that τ ij = α i + β j + ( αβ) ij Simple substitution yields (( αβ) - ( αβ) ) - ( αβ) - ( αβ) sh s+1 h sg s+1 g NO MAIN EFFECTS! Again note that interaction contrasts test whether the lines in an interaction plot differ significantly from being parallel. If we find a significant interaction, a two-way complete model should be used Crunchiness Rating 100 80 Interaction Plot 60 40 10 Minutes 1 Minutes 0 0 350º 400º Baking Temperature The mean rating at 350º is 6.5, while the mean rating at 400º is 57.5 does this really tell the whole story?

3.The main effects contrasts for Treatment Factors A and B, respectively, are a c i τ i i=1 where we have averaged the effect of Treatment Factor A at each level of Factor B, and b k jτ j j=1 where we have averaged the effect of Treatment Factor B at each level of Factor A. If do not find a significant contrast, a two-way additive model is appropriate (note that the lines in the interaction plot do not differ significantly from being parallel): Crunchiness Rating 100 Interaction Plot 80 60 40 10 Minutes 1 Minutes 0 0 350º 400º Baking Temperature The mean rating at 350º is 3.5, while the mean rating at 400º is 8.5 this really does tell the whole story!

Under such conditions, the main effects contrasts for Treatment Factors A and B, respectively, reduce to a a a c τ = c α + αβ = c α ( ) i i i i i i i i=1 i=1 i=1 where we have averaged the effect of Treatment Factor A at each level of Factor B, and k τ = k β + αβ = k β ( j ) b b b j j j j j j j=1 j=1 j=1 where we have averaged the effect of Treatment Factor B at each level of Factor A. However, if an interaction effect exists, the main effects contrasts for Treatment Factors A and B, respectively, are a a c τ = c α + αβ ( ) i i i i i i=1 i=1 where we have averaged the effect of Treatment Factor A at each level of Factor B, and b b k τ = k β + αβ ( ) j j j j j j=1 j=1 where we have averaged the effect of Treatment Factor B at each level of Factor A. Such contrasts have very odd interpretations (i.e., they are generally meaningless)!

Example Again consider the Automobile Battery Life problem, with the addition of information regarding the class of auto in which the battery is installed (Mid-sized or Full-sized): Automobile Battery Life (in Months) Size New England Mid West South West Mid 48 51 39 Full 4 45 43 Mid 43 56 38 Full 47 5 36 We ll use Region as Factor A (i = 1 for New England, i = for Mid West, and i = 3 for South West) and Class of Auto as Factor B (j = 1 for Mid-sized and j = for Full-sized). Thus our treatments are: τ 11 is a Battery installed in New England on a Mid-sized auto τ 1 is a Battery installed in New England on a Full-sized auto τ 1 is a Battery installed in the Mid West on a Mid-sized auto τ is a Battery installed in the Mid West on a Full-sized auto τ 31 is a Battery installed in the South West on a Mid-sized auto τ 3 is a Battery installed in the South West on a Full-sized auto If we simply wished to test equality of means for the Battery installed in New England on a Mid-sized auto and the Battery installed in the South West on a Full-sized auto, we would have a simple contrast in the treatments with coefficients [1 0 0 0 0 1]

Recalling that τ ij = α i + β j + ( αβ) ij This means our contrast is the equivalent of τ - τ = 11 3 α 1 + β 1 + αβ 11 - α 3 + β + αβ 3 So we have an equivalent contrast in the effects with coefficients [1 0-1] in α, [1 1] in β, and [1 0 0 0 0 1] in αβ. If we wished to test for interaction between New England and the Southwest regions and class of auto, we would have a simple contrast in the treatments with coefficients [0.5-0.5 0 0-0.5 0.5] or we can see that τ11 - τ1 τ31 - τ3 - = 0.5 ( α ) ( ) 1 + β 1 + αβ - α 1 + β + αβ 11 1-0.5 ( α ) ( ) 3 + β 1 + αβ - α 3 + β + αβ 31 3 = 0.5 β1 - β + αβ - αβ 11 1-0.5 β1 - β + αβ - αβ 31 3 = 0.5 αβ - αβ - αβ + αβ 11 1 31 3

So we have a simple contrast in the effects with coefficients [0 0 0] in α, [0 0] in β, and [0.5-0.5 0 0-0.5 0.5] in αβ. Of course, both sets of contrast coefficients yield identical results. If we simply wished to test equality of means for New England and the South West, we would have a simple contrast in the treatments with coefficients [0.5 0.5 0 0-0.5 0.5] or we can see that τ 11 + τ1 τ 31 + τ3 - = 0.5 α + β + αβ + α + β + αβ - 0.5 α + β + αβ + α + β + αβ = α 1 + 0.5 αβ + 0.5 αβ 11 1 - α 3 + 0.5 αβ + 0.5 αβ 31 3 ( 1 1 ) ( 11 1 1 ) ( 3 1 ) ( 31 3 3 )

which simplifies to τ + τ τ + τ 11 1 31 3 - = α 1 - α 3 if there are no interaction effects. So we have a simple contrast in the effects with coefficients [1 0-1] in α and [0 0] in β Again, both sets of contrast coefficients yield identical results. Finally, note that these contrast coefficients are often written in tabular form: ij A B AB 11 1 0 0 1 0 0 0 1 1 0 0-1 0 0 31 0 0 0 3-1 0 0 Divisor 1 - - This also illustrates that the interaction coefficients are products of corresponding coefficients from the interacting factors (in this case A and B) this is frequently the case.

D.The Two Way Complete Model Analysis Here we may proceed in either of two equivalent ways: 1. Use the cell-means model Y ijt = µ + τ ij+ ijt and our previously developed techniques or.use the Two-Way Complete Model Y = µ + α + β + αβ + ijt i j ij ijt which allows us to easily isolate the separate contribution made to the response by each factor and by their interaction - The Least Squares Estimators We know the least squares estimators for the cell means model are ˆµ + ˆij τ = Y ij so by substitution the least squares estimator for the twoway complete model are ˆµ + α ˆ + β ˆ + αβ = µ ˆ + ˆτ = Y i j ij ij ij with corresponding variance σ r ij

Thus any interaction of the form where and a b a b d ijτ ij = d ij ( αβ) ij i = 1 j= 1 i = 1 j= 1 a i=1 b j=1 d = 0 j ij d = 0 i ij has least squares estimate and associated variance of a b a b d ijyij and σ i=1 j=1 i=1 j=1 ij d r ij More specifically, interaction contrast ( τsh - τuh ) - ( τsq - τuq ) has least squares estimate Ysh - Yuh - Y sq + Yuq and associated variance of a b 1 1 1 1 Var dijτ ij = σ + + + i=1 j=1 rsh ruh rsq ruq

Similarly, any main effects of the form have a least squares estimate of 1 c αˆ = c Y b a a b i i i ij i=1 i=1 j=1 or a b c iα i or k jβ j i=1 j=1 ˆ 1 k β = k Y a b b a j j j ij j=1 j=1 i=1 and associated variance a a b * c ˆ i Var ci α i = σ i=1 i=1 j=1 b rij or b a b ˆ* k i Var kjβ j = σ j=1 i=1 j=1 a rij

Note that for a balanced design, these least squares reduce to a a c ˆ iα i = ciyi i=1 i=1 or b b ˆ k jβ j = kjy j j=1 j=1 where Y = i b r j=1 t =1 Y ijt br and Y = j a r i=1 t=1 Y ijt ar - Estimation of σ Again, since the two-way complete model is equivalent to the cell means model Y = µ + τ + ijt ij ijt = µ + α + β + αβ + i j ij ijt an estimate of σ is the same as for a one-way ANOVA model (allowing for the extra subscript j). First calculate a b r ij ( ijt ij ) sse = y - y i=1 j=1 t=1 a b rij a b ijt ij ij i=1 j=1 t=1 i=1 j=1 a b rij a b y ij ijt i=1 j=1 t=1 i=1 j=1 rij = y - r y = y - sum of squared errors

The use the sse to calculate the mse, which is an unbiased estimate of σ sse mse = n - ν Furthermore, since sse ~ χ σ n-ab a 100(1 α)% confidence bound for σ is given by σ χ sse n-ab,1-α - Multiple Comparisons A researcher may wish to make comparisons of i) treatment combinations, ii) main effects of Factor A, and iii) main effects of Factor B. To ensure the overall experimentwise error rate α, one could take a Bonferonni approach and set error rates α 1, α, and α 3 for these three sets of inferences such that α 1 + α + α 3 = α Of course, there are many ways to establish desired values for α 1, α, and α 3, including: - number of inferences to be made in each set - relative importance of each set of inferences

Comparisons of Treatment Combinations Under such circumstances the cell-means model is used and each of the previously discussed approaches to multiple comparisons (Bonferroni, Scheffé, Tukey, Dunnett, Hsu, Fisher, SNK, Duncan) can be used with sse mse = = n - ν a b r ij i=1 j=1 t=1 ( y ijt - y ij ) n - ab Comparisons of Main Effects Here we are comparing the effects of levels of one factor averaged over the levels of the other factor. Again, this is likely not of interest in the presence of interaction between the two factors. We can use each of the previously discussed approaches to multiple comparisons (Bonferroni, Scheffé, Tukey, Dunnett, Hsu, Fisher, SNK, Duncan) can be used with c τ i i = c α c y w mse i i i i ± a a a a * i i=1 i=1 i=1 i=1 for Factor A, or c br

* k τ j = k β k y j j j j w mse j ± for Factor B, where k j ar b b b b j=1 j=1 j=1 j=1 w B = t n-ab, α m or w = a - 1 F b - 1 F S a-1,n-ab,α b-1,n-ab,α w = T q q or a,n-ab,α b,n-ab,α ( 0.5) ( 0.5) w = w = t or t D1 H a-1,n-ab,α b-1,n-ab,α ( 0.5) ( 0.5) w = t or t D a-1,n-ab,α b -1,n-ab,α for balanced designs. For unbalanced designs, we can still use either the Bonferonni or Scheffé methods, using least squares estimates a a b 1 c ˆ iα i = c i Yij i=1 i=1 b j=1 or b b a ˆ 1 k jβ j = k j Yij j=1 j=1 a i=1 and variance a a b * c ˆ i Var ci α i = σ i=1 i=1 j=1 b rij or b a b ˆ * k i Var kjβ j = σ j=1 i=1 j=1 a rij For situations in which the variances are unequal, Satterwaithe s approximation can be used.

- Analysis of Variance The three standard hypotheses of a two-way complete model are: = 0 AB H : αβ - αβ - αβ + αβ i s,j q 0 ij iq sj sq i.e., there is no interaction effect. Note that this hypothesis suggests that the interaction plots show parallel lines, and can also be written as AB H0 : ( αβ) - ( αβ) - ( αβ ) + ( αβ) = 0 i, j ij i j Nonrejection of this hypothesis (i.e., concluding that a significant interaction effect does not exist) usually leads to consideration of the second and third standard hypotheses of a two-way complete model: The second and third standard hypotheses of a two-way complete model (in no particular order) are: H : α = α = L = α A * * * 0 1 a and B * * * H0 : β 1 = β = L = βb * * where α = α + αβ β = β + αβ and i i i j j i.e., there is no corresponding main effect. Again note that these hypotheses may be of little interest if a substantial interaction exists. j

In order to test these three hypotheses, the variation in responses must be partitioned. As one might expect, we again utilize the concepts of full and reduced models. To test the interaction hypothesis, we compare the sum of squares for error under the two-way complete model (sse) with the sum of squares for error under the reduced model that results when H 0 is true ( sse AB ). 0 The difference AB ssab = sse0 - sse is called the Sum of Squares for Interaction AB. Note that large values of ssab relative to sse lead to rejection of AB H0 : ( αβ) - ( αβ) - ( αβ ) + ( αβ) = 0 i, j ij i j * * * Given that the least squares estimates of µ + α i + βj are y i + y j - y for the reduced model (with equal sample sizes), the sum of squares for error for the reduced model is ( ˆ ˆ ) a b r AB * * * 0 ijt i j i=1 j=1 t=1 sse = y - µ - α - β a b r ( ijt i j ) = y -y -y +y i=1 j=1 t=1

_ Now if we add and subtract y ij to this expression, we have a b r ( ( ) ( ) ) i=1 j=1 t=1 a b r ( ( ijt ij ) ( ij i j ) ) sse = y - y + y - y - y + y AB 0 ijt ij ij i j = y -y + y -y -y +y i=1 j=1 t=1 ( ijt ij ) ( ij i j ) a b r a b r = y -y + y -y -y +y i=1 j=1 t=1 i=1 j=1 t=1 sse So for equal sample sizes we have ssab = sse AB 0 = y -y + y -y -y +y i=1 j=1 t=1 i=1 j=1 t=1 a b r a b r ( ijt ij ) ( ij i j ) a b ( ij i j ) i=1 j=1 i=1 j=1 - sse a b r ( ijt ij ) - y - y i=1 j=1 t=1 = r y - y - y + y a b yij = - r y a yi b j y - + i=1 j=1 br ar abr

ssab AB Now if H 0 is true, then ~ χ ( a-1)( b-1) σ sse and since ~ χ n-ab σ and ssab and sse are independent, the ratio of these two Chi-square statistics (divided by their respective degrees of freedom) yields ssab ssab ( a-1) ( b-1) σ ( a-1) ( b-1) msab = = ~ F sse sse mse ( n-ab) σ ( n-ab) a-1 b-1,n-ab which provides us with the means for testing AB H0 : ( αβ) - ( αβ) - ( αβ ) + ( αβ) = 0 i, j ij i j We will reject AB H0 : ( αβ) - ( αβ) - ( αβ ) + ( αβ) = 0 i, j ij i j when msab >Fa-1 ( b-1 ) mse,n-ab,α Note that: if this hypothesis is rejected, it is often preferable to use the equivalent cell-means model and look at contrasts in the treatment combinations τ ii. if this hypothesis is not rejected, we can use the resulting model to test main effects directly (and not rerun a main effects model).

To test that Factor A has no effect on the responses, we can consider A+AB * * * H : α = α = L = α 0 1 a and ij i j * where α = α + ( αβ) αβ - αβ - αβ + αβ = 0 i, j i i i based on the reduced model Y = µ + β + * * ijt j ijt The reduced model on which this approach is based has an intuitive appeal. We can consider a more traditional approach to testing the hypothesis that Factor A has no effect on the responses H : α = α = L = α * where α = α + αβ A * * * 0 1 a i i i based on the reduced model ( ij i j ) Y = µ + β + αβ - αβ - αβ + αβ + ** * ijt j ijt This approach is preferred if we take the view that a main effect is not tested unless the hypothesis of no interaction is first not rejected. This is the approach we will take.

It can be shown that the least squares estimate of E[Y ijt ] for this reduced model is y - y + y ij i and so the corresponding sum of squares for error is a b r ( ) sse = y - y + y - y A 0 ijt ij i i=1 j=1 t=1 ( ijt ij ) ( i ) a b r a = y - y - br y - y i=1 j=1 t=1 i=1 sse So for equal sample sizes we have ssa = sse A 0 = y -y + y -y i=1 j=1 t=1 a b r ( ijt ij ) ( i ) i=1 a ( i ) i=1 - sse = br y - y a y = - br y abr i a b r ( ijt ij ) - y - y i=1 j=1 t=1

Now if A H 0 is true, then ssa ~ χ σ a-1 sse and since ~ χ n-ab σ and ssa and sse are independent, the ratio of these two Chi-Square statistics (divided by their respective degrees of freedom) yields ssa ssa ( a-1) σ ( a-1) msa = = ~ Fa-1,n-ab sse sse mse ( n-ab) σ ( n-ab) which provides us with the means for testing A * * * H0 : α 1 = α = L = αa * where α = α + αβ i i i We will reject when H : α = α = L = α * where α = α + αβ A * * * 0 1 a msa >Fa-1,n-ab,α mse i i i

Similarly, to test that Factor B has no effect on the responses, we can consider B+AB * * * H : β = β = L = β 0 1 b and ij i j * where β = β + ( αβ) αβ - αβ - αβ + αβ = 0 i, j j j j based on the reduced model Y = µ + α + * * ijt i ijt Again, the reduced model on which this approach is based has an intuitive appeal. We can consider a more traditional approach to testing the hypothesis that Factor A has no effect on the responses H : β = β = L = β * where β = β + αβ B * * * 0 1 b j j j based on the reduced model ( ij i j ) Y = µ + α + αβ - αβ - αβ + αβ + ** * ijt i ijt Again, this approach is preferred if we take the view that a main effect is not tested unless the hypothesis of no interaction is first not rejected. This is the approach we will take.

It can be shown that the least squares estimate of E[Y ijt ] for this reduced model is y - y + y ij j and so the corresponding sum of squares for error is a b r ( ) sse = y - y + y - y B 0 ijt ij j i=1 j=1 t=1 ( ijt ij ) ( j ) a b r b = y - y - ar y - y i=1 j=1 t=1 j=1 sse So for equal sample sizes we have ssb = sse B 0 = y -y + y -y i=1 j=1 t=1 a b r ( ijt ij ) ( j ) j=1 b ( j ) j=1 - sse = ar y - y b y j y = - ar abr a b r ( ijt ij ) - y - y i=1 j=1 t=1

Now if B H 0 is true, then ssb ~ χ σ b-1 sse and since ~ χ n-ab σ and ssb and sse are independent, the ratio of these two Chi-Square statistics (divided by their respective degrees of freedom) yields ssb ssb ( b-1) σ ( b-1) msb = = ~ Fb-1,n-ab sse sse mse ( n-ab) σ ( n-ab) which provides us with the means for testing B * * * H0 : β 1 = β = L = βb * where β = β + αβ j j j We will reject H : β = β = L = β * where β j = β j + ( αβ) j when msb >Fb-1,n-ab,α mse B * * * 0 1 b

The results of a Two Way Complete Analysis of Variance can be summarized and displayed in an ANOVA Table: Source of Variation Error Total Degrees of Freedom (df) n ab n - 1 Sum of Squares (SS) ( ij i j ) i=1 j=1 a b r ( ijt ij ) sse = y - y i=1 j=1 t=1 a b r ( ijt i ) sstot = y - y i=1 j=1 t=1 Mean Square (MS) ssa Factor A a-1 a ssa = br ( yi - y ) msa = i=1 a-1 Factor B b-1 ssb b ssb = ar ( y j - y ) msb = j=1 b-1 AB (a-1)(b-1) ssab ssab = msab = ( a-1 ) ( b-1 ) a b r y - y - y + y sse mse = n-ab F-Ratio msa F A = mse msb F B = mse msab F AB = mse Example Again consider the Automobile Battery Life problem augmented by the class of auto in which the battery is installed (Mid-sized or Full-sized): Automobile Battery Life (in Months) Size New England Mid West South West Mid 48 51 39 Full 4 45 43 Mid 43 56 38 Full 47 5 36 We ll use Region as Factor A (i = 1 for New England, i = for Mid West, and i = 3 for South West) and Class of Auto as Factor B (j = 1 for Mid-sized and j = for Full-sized). Use these data to perform a Two Way Complete ANOVA.

The interaction plot for this data could look like this: Life of Battery (Months) 60 Interaction Plot 50 40 30 0 Sealed Mid-sized Nonsealed Full-sized 10 0 New TryHard England NeverStart Mid West South WorryLast West Region Brand There is very little evidence of interaction between region and class of auto (the relationships between classes of auto are similar for the different classes of autos). Or the interaction plot could look like this: Life of Battery (Months) 60 Interaction Plot 50 40 30 0 New TryHard England Mid NeverStart West South WorryLast West 10 0 Mid-sized Sealed Full-sized Nonsealed Type Region of Battery Again, there is very little evidence of interaction between region and class of auto (the relationships between classes of auto are similar for the different regions). However, we will proceed with a two-way complete analysis

We first test the interaction hypothesis: AB H0 : ( αβ) - ( αβ) - ( αβ ) + ( αβ) = 0 i, j ij i j The appropriate sum of squares is a b a b yij y y i j y ssab = - - + r br ar abr i=1 j=1 i=1 j=1 a a i=1 b i=1 j=1 The calculated components of the ssab are ( 4 + 47 + 48 + 43) y i = br y ij 4+47 48+43 = + r ( 45+5) ( 51+56) ( 43+36) ( 39+38) + + + + = 4615 45+5+51+56 43+36+39+38 + + = 4588

and b j=1 y j 4 + 45 + 43 + 47 + 5 + 36 = ar 3 ( 48+51+39+43+56+38) 3 + = 4308.33 y 4 + 47 + 48 + 43 + 45 + 5 + 51 + 56 + 43 + 36 + 39 + 38 = = 4300 abr 3 So the sum of squares for interaction AB is a b a b yij y y i j y ssab = - - + r br ar abr i=1 j=1 i=1 j=1 = 4615-4588 - 4308.33 + 4300 = 18.67 The sum of squares for error is a b r ( ijt ij ) sse = y - y = 4 - i=1 j=1 t=1 4 + 47 4+47 39+38 + 47 - + L + 38 - = 87.0

So the corresponding mean squares are and ssab 18.67 msab = = = 9.33 a-1 b-1 sse 87.0 mse = = = 14.5 n-ab 6 which results in an F-statistic of msab 9.33 F AB = = = 0.644 mse 14.5 At (a 1)(b 1) = and n ab = 6 degrees of freedom, this test statistic has a p-value of 0.55814, so we do not reject the hypothesis of no interaction at any reasonable significance level. We can proceed with tests of main effects. Now we test the main effect associated with Factor A: H : α = α = L = α * where α = α + αβ A * * * 0 1 a The appropriate sum of squares is i i i y ssa = - y abr a i i=1 br Since we calculated the components of ssa when calculating ssab, we can simply substitute these results: ssa = 4588-4300 = 88

So the corresponding mean square is ssa 88 msa = = = 144.0 a-1 which results in an F-statistic of msa 144 F A = = = 9.931 mse 14.5 At a 1 = and n ab = 6 degrees of freedom, this test statistic has a p-value of 0.0149, so we have some evidence that the hypothesis of no main effect for Factor A is incorrect. Finally, we test the main effect associated with Factor B: H : β = β = L = β * where β = β + αβ B * * * 0 1 b The appropriate sum of squares is j j j y ssb = - y abr b j j=1 ar Since we calculated the components of ssb when calculating ssab, we can simply substitute these results: ssb = 4308.33-4300 = 8.33

So the corresponding mean square is ssb 8.33 msb = = = 8.33 b-1 1 which results in an F-statistic of msb 8.33 F B = = = 0.575 mse 14.5 At b 1 = 1 and n ab = 6 degrees of freedom, this test statistic has a p-value of 0.47710, so we so we do not reject the hypothesis of no main effect for Factor B at any reasonable significance level. The results of this Two Way Complete Analysis of Variance are summarized and displayed in the following ANOVA Table: Source of Variation Degrees of Freedom (df) Sum of Squares (SS) Mean Square (MS) F-Ratio Factor A a-1= ssa = 88 msa = 144 F A = 9.931 Factor B b-1=1 ssb = 8.33 msb = 8.33 F B = 0.575 AB (a-1)(b-1)= ssab = 18.67 msab = 9.33 F AB = 0.644 Error n ab=6 sse = 87 mse = 14.5 Total n 1=11 sstot = 40

SAS code for a Two Way Complete Model: DATA battery; INPUT region $ autotype $ treatmnt life; num=_n_; LABEL region= Region of Country' autotype='type of Auto (Mid- vs. Full-sized)' life='observed Life of Battery in Months' num='order of Data'; CARDS; NewEngland Mid 1 48......... SouthWest Full 6 36 ; PROC GLM DATA=battery; TITLE4 'Using PROC GLM for a Two-Factor Complete Analysis'; CLASS region autotype; MODEL life=region autotype region*autotype; RUN; SAS output for a Two Way Complete Model: Analysis of Variance AUTOMOBILE BATTERY LIFE DATA ANALYSIS FOR QA 605 WINTER QUARTER 001 Using PROC GLM for a Two-Factor Analysis Dependent Variable: life The GLM Procedure Observed Life of Battery in Months Sum of Source DF Squares Mean Square F Value Pr > F Model 5 315.0000000 63.0000000 4.34 0.0510 Error 6 87.0000000 14.5000000 Corrected Total 11 40.0000000 R-Square Coeff Var Root MSE life Mean 0.78358 8.461970 3.807887 45.00000 Source DF Type I SS Mean Square F Value Pr > F region 88.0000000 144.0000000 9.93 0.015 autotype 1 8.3333333 8.3333333 0.57 0.4771 region*autotype 18.6666667 9.3333333 0.64 0.5581 Source DF Type III SS Mean Square F Value Pr > F region 88.0000000 144.0000000 9.93 0.015 autotype 1 8.3333333 8.3333333 0.57 0.4771 region*autotype 18.6666667 9.3333333 0.64 0.5581

Of course, we could also analyze some contrasts with this Two Way Complete Analysis of Variance. Suppose we are interested in the following contrasts: 1. τ MidWest τ NewEngland. τ Full τ Mid 3. τ NewEngland Mid τ SouthWest Full 4. (τ NewEngland Mid - τ NewEngland Full ) (τ SouthWest Mid - τ SouthWest Full ) For the first contrast we have a contrast in the effects with coefficients [1-1 0] in α, [0 0] in β, and [0 0 0 0 0 0] in αβ. Note that SAS reads the effects in alphabetical or numerical order. For the other contrast we have effects coefficients [0 0 0] in α, [1-1] in β, and [0 0 0 0 0 0] in αβ [0 1-1] in α, [-1 1] in β, and [0 0 0 1-1 0] in αβ [0 0 0] in α, [0 0] in β, and [0 0-1 1 1-1] in αβ respectively.

SAS code for Contrasts in a Two Way Complete Model: DATA battery; INPUT region $ autotype $ treatmnt life; num=n; LABEL region='region of Country' autotype='type of Auto (Mid- vs. Full-sized)' life='observed Life of battery in Months' num='order of Data'; CARDS; NewEngland Mid 1 48......... SouthWest Full 6 36 ; PROC GLM DATA=battery; TITLE4 'Using PROC GLM for a Two-Factor Complete Analysis'; CLASS region autotype; MODEL life=region autotype region*autotype; ESTIMATE MW vs NE' region 1-1 0; ESTIMATE Mid vs Full' autotype 1-1; ESTIMATE NE Mid vs SE Full' region 0 1-1 autotype 1-1 region*autotype 0 0 1 0 0-1; ESTIMATE 'Interaction - NE vs SW' region*autotype 0 0-1 1 1-1; RUN; SAS output for Contrasts in a Two Way Complete Model: Analysis of Variance AUTOMOBILE BATTERY LIFE DATA ANALYSIS 3 FOR QA 605 WINTER QUARTER 001 Using PROC GLM for a Two-Factor Analysis The GLM Procedure Standard Parameter Estimate Error t Value Pr > t MW vs NW 6.00000000.695840.3 0.0674 Mid vs Full 1.66666667.19848433 0.76 0.4771 NE Mid vs SW Full 6.00000000 3.80788655 1.58 0.166 Interaction - MW vs SW.00000000 5.38516481 0.37 0.731

We could also compute the same contrasts with treatment coefficients. Again, suppose we are interested in the following contrasts: 1. τ MidWest τ NewEngland. τ Full τ Mid 3. τ NewEngland Mid τ SouthWest Full 4. (τ NewEngland Mid τ NewEngland Full ) (τ SouthWest Mid - τ SouthWest Full For the first contrast we have a contrast in the treatments with coefficients [-1 1 1 1 0 0] in τ For the other contrast we have treatment coefficients respectively. [-1 1-1 1-1 1] in τ, [1 0 0 0 0-1] in τ, [1-1 0 0-1 1] in τ, SAS code for Contrasts in a Two Way Complete Model: DATA battery; INPUT region $ autotype $ treatmnt life; num=_n_; CARDS; NewEngland Mid 1 48 NewEngland Full 4 NewEngland Mid 1 43 NewEngland Full 47 MidWest Mid 3 51 MidWest Full 4 45 MidWest Mid 3 56 MidWest Full 4 5 SouthWest Mid 5 39 SouthWest Full 6 43 SouthWest Mid 5 38 SouthWest Full 6 36 ; PROC GLM DATA=battery; New variable for treatment effects TITLE4 'Using PROC GLM for a Two-Factor Complete Analysis'; CLASS treatmnt; MODEL life=treatmnt; ESTIMATE MW vs. NE' treatmnt -1-1 1 1 0 0/divisor=; ESTIMATE Mid vs. Full' treatmnt 1-1 1-1 1-1/divisor=3; ESTIMATE NE Mid vs SW Full' treatmnt 1 0 0 0 0-1; ESTIMATE 'Interaction - NE vs. SW' treatmnt 1-1 0 0-1 1; RUN;

SAS output for Contrasts in a Two Way Complete Model: Analysis of Variance AUTOMOBILE BATTERY LIFE DATA ANALYSIS 3 FOR QA 605 WINTER QUARTER 001 Using PROC GLM for a Two-Factor Analysis The GLM Procedure Standard Parameter Estimate Error t Value Pr > t MW vs NE 6.00000000.695840.3 0.0674 Mid vs Full 1.66666667.19848433 0.76 0.4771 NE Mid vs SW Full 6.00000000 3.80788655 1.58 0.166 Interaction - NE vs SW.00000000 5.38516481 0.37 0.731 Same results as with effects coefficients! E. The Two Way Main Effects Model Analysis The two-way main effects model is Y = µ ˆ + ˆτ = µ + α + β + ijt ij i j ijt - ijt ~ N(0, σ ) - ijt s are mutually independent, t = 1,,r ij, i = 1,,a j = 1,,b - The Least Squares Estimators For a balanced design, the least squares estimators for this model are ˆµ + ˆτ = ˆµ + α ˆ + β ˆ = Y + Y - Y ij i j i j

Thus the least squares estimator for an estimable main effects contrast is a c α or b k β i i j j i=1 j=1 a a a = c α = c Y + Y - Y c Y i i i i j i i i=1 i=1 i=1 or b b b = k β = k Y + Y - Y k Y j j j i j j j j=1 j=1 j=1 with associated variance a ˆ a σ a Var ciα i = Var ciy i = ci i=1 i=1 br i=1 or ˆ b b σ b Var kjβ j = Var kjy j = ki j=1 j=1 ar j=1 Note that similar formula for unbalanced designs can also be derived, but are relatively complex and will be left to SAS in this course.

- Estimation of σ The minimum value of the sums of squares for error in the two-way main effects model is ( ˆ ˆ ˆ ) ( ) sse = yijt - µ + α i + βj = y ijt - Y i + Yj - Y = y ijt -Yi -Y j +Y a b rij a b ijt i j i=1 j=1 t=1 i=1 j=1 a b rij a b 1 1 ijt i j i=1 j=1 t=1 br i=1 ar j=1 = y -br y -ar y +abry = y - y - y + sum of squared errors 1 y abr The use the sse to calculate the mse, which is an unbiased estimate of σ sse mse = n - a - b + 1 Furthermore, since sse ~ χ σ n-a-b+1 a 100(1 α)% confidence bound for σ is given by σ χ sse n-a-b+1,1-α

- Multiple Comparisons A researcher may wish to make comparisons of either i) treatment combinations, ii) main effects of Factor A, or iii) main effects of Factor B For balanced designs, the previously discussed methods for multiple comparisons (Bonferroni, Scheffé, Tukey, Dunnett, and Hsu methods) can be used. A set of 100(1 α)% simultaneous confidence intervals for contrasts comparing levels of Factor A are c iτ i = ciαi ciyi ± w mse a a a a i=1 i=1 i=1 i=1 Similarly, a set of 100(1 α)% simultaneous confidence intervals for contrasts comparing levels of Factor B are k jτ j = kjβ j ky j j ± w mse c i br k j ar b b b b j=1 j=1 j=1 j=1

where the critical coefficients are w B = t n-a-b+1, α m or w = a-1 F b-1 F S a-1,n-a-b+1,α b-1,n-a-b+1,α w = T q q or a,n-a-b+1,α b,n-a-b+1,α ( 0.5) ( 0.5) w = w = t or t D1 H a-1,n-a- b +1,α b-1,n-a-b+1,α ( 0.5) ( 0.5) w = t or t D a-1,n-a-b+1,α b-1,n-a-b+1,α 100(1 α)% simultaneous confidence intervals for treatment means τ ij = µ + α i + β j are given by a+b-1 τ ij = µ + α j + βj ( Y i + Y j - Y ) ± w mse abr where the critical coefficients for the Bonferroni and Scheffé methods are w = t and w = a + b - 1 F BM n-a-b+1, α SM a+b-1,n-a-b+1,α ab respectively. Note that Satterthwaite s method is still appropriate when the variances are unequal and can not be stabilized by transformation.

- Analysis of Variance The two standard hypotheses of a two-way main effects model (in no particular order) are: A H : α = α = L = α 0 1 a and B H : β = β = L = β 0 b b b i.e., there is no corresponding main effect. Note that this hypothesis suggests that the interaction plots show no consistent gap across levels of Factor A. To test that Factor A has no effect on the responses, we can consider A H : α = α = L = α based on the reduced model 0 1 a Y ijt = µ + β j + ijt which is identical to _ a one-way ANOVA model where µ is replaced by µ * = µ + β with br observations per treatment level of Factor A. A Thus sse 0 is the same as the sums of squares for error in a one-way ANOVA a b r sse = y - y A 0 ijt j i=1 j=1 t=1

The sums of squares for testing is A ssa = sse - sse 0 A H 0 for a balanced design ( ijt j ) ( ijt i j ) a b r a b r = y -y - y -y -y +y i=1 j=1 t=1 i=1 j=1 t=1 ( ijt j ) ( ijt j ) ( i ) a b r a b r = y -y - y -y - y -y i=1 j=1 t=1 i=1 j=1 t=1 a i=1 ( i ) = br y - y i=1 a y y i ijt = - br abr which is identical to the sums of squares for testing the corresponding main effect in a two-way complete model. Now if A H 0 is true, then ssa ~ χ σ a-1 sse and since ~ χ n-a-b+1 σ and ssa and sse are independent, the ratio of these two Chi-Square statistics (divided by their respective degrees of freedom) yields ssa ssa ( a-1) σ ( a-1) msa = = ~ F sse sse mse ( n-a-b+1) σ ( n-a-b+1) which provides us with the means for testing A H : α = α = L = α 0 1 a a-1,n-a-b+1

We will reject when A H : α = α = L = α 0 1 a msa >Fa-1,n-a-b+1,α mse Similarly, to test that Factor B has no effect on the responses, we can consider B H : β = β = L = β based on the reduced model 0 1 b Y ijt = µ + α i + ijt which is identical to _ a one-way ANOVA model where µ is replaced by µ * = µ + α. with ar observations per treatment level of Factor B. B Thus sse 0 is the same as the sums of squares for error in a one-way ANOVA a b r sse = y - y B 0 ijt i i=1 j=1 t=1

The sums of squares for testing is B ssb = sse - sse B H 0 for a balanced design ( ijt i ) ( ijt i j ) ( ijt i ) ( ijt i ) ( j ) 0 a b r a b r = y -y - y -y -y +y i=1 j=1 t=1 i=1 j=1 t=1 a b r a b r = y -y - y -y - y -y i=1 j=1 t=1 i=1 j=1 t=1 b ( j ) = ar y - y j=1 b y j yijt = - ar abr j=1 which again is identical to the sums of squares for testing the corresponding main effect in a two-way complete model. Now if B H 0 is true, then ssb ~ χ σ b-1 sse and since ~ χ n-a-b+1 σ and ssa and sse are independent, the ratio of these two Chi-Square statistics (divided by their respective degrees of freedom) yields ssb ssb ( b-1) σ ( b-1) msb = = ~ F sse sse mse ( n-a-b+1) σ ( n-a-b+1) which provides us with the means for testing B H : β = β = L = β 0 1 b b-1,n-a-b+1

We will reject when B H : β = β = L = β 0 1 b msb >Fb-1,n-a-b+1,α mse The results of a Two Way Main Effects Analysis of Variance can be summarized and displayed in an ANOVA Table: Source of Variation Degrees of Freedom (df) Sum of Squares (SS) Mean Square (MS) F-Ratio Factor A Error Total a-1 Factor B b-1 n a b+1 n - 1 sse = a b r ( yijt - yi - y j + y ) i=1 j=1 t=1 a b r a i i=1 ssa = br y - y ( j ) b j=1 ssb = ar y - y ( ijt i ) sstot = y - y i=1 j=1 t=1 ssa msa = a-1 ssb msb = b-1 sse mse = n-a-b+1 F A msa = mse msb F B = mse

Example Again consider the Automobile Battery Life problem augmented by the class of auto in which the battery is installed (Mid-sized or Full-sized): Automobile Battery Life (in Months) Size New England Mid West South West Mid 48 51 39 Full 4 45 43 Mid 43 56 38 Full 47 5 36 We ll use Region as Factor A (i = 1 for New England, i = for Mid West, and i = 3 for South West) and Class of Auto as Factor B (j = 1 for Mid-sized and j = for Full-sized). Use these data to perform a Two Way main effects ANOVA. Recall the interaction plot for this data: Life of Battery (Months) 60 Interaction Plot 50 40 30 0 Sealed Mid-sized Nonsealed Full-sized 10 0 New TryHard England NeverStart Mid West South WorryLast West Region Brand There is very little evidence of interaction between region and class of auto (the relationships between classes of auto are similar for the different classes of auto).

Or this interaction plot: Life of Battery (Months) 60 Interaction Plot 50 40 30 0 New TryHard England Mid NeverStart West South WorryLast West 10 0 Mid-sized Sealed Full-sized Nonsealed Type Region of Battery Again, there is very little evidence of interaction between region and class of auto (the relationships between classes of auto are similar for the different regions). This could be used to justify our choice of a main effects analysis. First we test the main effect associated with Factor A: A H : α = α = L = α 0 1 a The appropriate sum of squares is y ssa = - y abr a i i=1 br Since this is equivalent to the sums of squares associated with Factor A in the two-way complete model (which we already calculated) we have that: y y ssa = - = 88 abr a i i=1 br

So the corresponding mean square is ssa 88 msa = = = 144.0 a-1 To calculate the F-statistic necessary to test the Factor A main effect hypothesis, we still need the sse: a b r ( ijt i j ) sse = y - y - y + y i=1 j=1 t=1 which is somewhat arduous to calculate. However, recall that for a balanced sample we have that sstot = ssa + ssb + sse From our previous work we already know that sstot = 40.0, so if we find ssb we can more easily calculate sse. Recall that ssb for the two-way main effects model is equivalent to the sums of squares associated with Factor B in the two-way complete model (which we already calculated): ( j ) b j=1 ssb = ar y - y = 8.33 so we have that sse = sstot - ssa - ssb =40-88 8.33 = 105.67 and the corresponding mean squares is sse 105.67 mse = = = 13.0875 n-a-b+1 8

which results in an F-statistic for the hypothesis test of a Factor A main effect of msa 144 F A = = = 10.90186 mse 13.1 At a 1 = and n a - b + 1 = 8 degrees of freedom, this test statistic has a p-value of 0.005191, so we have strong evidence that the hypothesis of no main effect for Factor A is incorrect. Next we test the main effect associated with Factor B: B H : β = β = L = β 0 1 b The appropriate sum of squares is y ssb = - y abr b j j=1 ar which we have already seen is equivalent to the sums of squares associated with Factor B in the two-way complete model (which we already calculated): y y ssb = - = 8.33 abr b j j=1 ar

So the corresponding mean square is ssb 8.33 msb = = = 8.33 b-1 1 which results in an F-statistic of msb 8.33 F B = = = 0.764 mse 13.1 At b 1 = 1 and n a - b + 1 = 8 degrees of freedom, this test statistic has a p-value of 0.49696, so we so we do not reject the hypothesis of no main effect for Factor B at any reasonable significance level. The results of our Two Way Main Effects Analysis of Variance are be summarized and displayed in the following ANOVA Table: Source of Variation Degrees of Freedom (df) Sum of Squares (SS) Mean Square (MS) F-Ratio Factor A a-1= ssa = 88 msa = 144 F A = 10.90 Factor B b-1=1 ssb = 8.33 msb = 8.33 F B = 0.764 Error n a b+1=8 sse = 105.67 mse = 13.1 Total n 1=11 sstot = 40

SAS code for a Two Way Main Effect Model: DATA battery; INPUT region $ autotype $ treatmnt life; num=_n_; LABEL region= Region of Country' autotype='type of Auto (Mid- vs. Full-sized)' life='observed Life of Battery in Months' num='order of Data'; CARDS; New England Mid 1 48......... SouthWest Full 6 36 ; PROC GLM DATA=battery; TITLE4 'Using PROC GLM for a Two-Factor Main Effects Analysis'; CLASS region autotype; MODEL life=region autotype; RUN; SAS output for a Two Way Main Effect Model: Analysis of Variance AUTOMOBILE BATTERY LIFE DATA ANALYSIS FOR QA 605 WINTER QUARTER 001 Using PROC GLM for a Two-Factor Analysis Dependent Variable: life The GLM Procedure Observed Life of Battery in Months Sum of Source DF Squares Mean Square F Value Pr > F Model 3 96.3333333 98.7777778 7.48 0.0104 Error 8 105.6666667 13.083333 Corrected Total 11 40.0000000 R-Square Coeff Var Root MSE life Mean 0.737148 8.0768 3.63437 45.00000 Source DF Type I SS Mean Square F Value Pr > F region 88.0000000 144.0000000 10.90 0.005 autotype 1 8.3333333 8.3333333 0.63 0.4499 Source DF Type III SS Mean Square F Value Pr > F region 88.0000000 144.0000000 10.90 0.005 autotype 1 8.3333333 8.3333333 0.63 0.4499

- A Note About Contrasts: Two estimable contrasts are said to be orthogonal iff their least squares estimates are uncorrelated. In terms of treatment combinations, this means that contrasts ν i i i=1 c τ ν and ksτs s=1 are orthogonal iff ν ν ν ν 0 = Cov c Y, k Y = c k Cov Y, Y i=1 s=1 i=1 s=1 (, ) (, ) i i i i i s i s i=1 i=1 s 1 ν i i s s i s i s ν ν ν = c k Cov Y Y + c k Cov Y Y ( ) = c k Var Y + 0 = σ i i i i=1 ν ck i i r i=1 i i.e., observed responses (Y it s) are independent Thus the two estimable contrasts orthogonal iff ck ν i i i=1 ri = 0 which for balanced designs simplifies to ν ck i i = 0 i=1 These conditions can be rewritten in two subscripts for two-way models, first generally d h a b ij ij i=1 j=1 rij and for balanced designs a b i=1 j=1 ij ij = 0 d h = 0

Note also that for ν treatment combinations, the maximum number of mutually orthogonal contrasts is ν 1. Example Again consider the Automobile Battery Life problem with the addition of information regarding the class of auto (Mid-sized or Full-sized): One set of five orthogonal constraints in treatment effects could be given by Contrast τ 1 τ τ 3 τ 4 τ 5 τ 6 1-1.0 1.0-1.0 1.0-1.0 1.0 1.0 1.0-1.0-1.0 0.0 0.0 3 1.0-1.0 0.0 0.0-1.0 1.0 4 0.0 0.0 1.0-1.0-1.0 1.0 5 1.0 1.0 1.0 1.0 -.0 -.0 This is often referred to as a complete set of mutually orthogonal contrasts. The sums of squares corresponding to the q th contrast in a complete set of mutually orthogonal contrasts is a b ij ij i=1 j=1 q a b cij ssc = c y r i=1 j=1 ij

SAS code for a Complete Set of Mutually Orthogonal Contrasts for Two Way Complete Model: DATA battery; INPUT region $ autotype $ treatmnt life; CARDS; NewEngland Mid 1 48......... SouthWest Full 6 36 ; PROC GLM DATA=battery; TITLE4 'Using PROC GLM for a Two-Factor Main Effects Analysis'; CLASS treatment; MODEL life=treatment; ESTIMATE 'Set of Orthogonal Contrasts - 1' treatmnt 1-1 1-1 1-1; CONTRAST 'Set of Orthogonal Contrasts - 1' treatmnt 1-1 1-1 1-1; ESTIMATE 'Set of Orthogonal Contrasts - ' treatmnt 1 1-1 -1 0 0; CONTRAST 'Set of Orthogonal Contrasts - ' treatmnt 1 1-1 -1 0 0; ESTIMATE 'Set of Orthogonal Contrasts - 3' treatmnt 1-1 0 0-1 1; CONTRAST 'Set of Orthogonal Contrasts - 3' treatmnt 1-1 0 0-1 1; ESTIMATE 'Set of Orthogonal Contrasts - 4' treatmnt 0 0 1-1 -1 1; CONTRAST 'Set of Orthogonal Contrasts - 4' treatmnt 0 0 1-1 -1 1; ESTIMATE 'Set of Orthogonal Contrasts - 5' treatmnt 1 1 1 1 - -; CONTRAST 'Set of Orthogonal Contrasts - 5' treatmnt 1 1 1 1 - -; RUN; SAS output for a Complete Set of Mutually Orthogonal Contrasts for Two Way Complete Model: Analysis of Variance AUTOMOBILE BATTERY LIFE DATA ANALYSIS 4 FOR QA 605 WINTER QUARTER 001 Using PROC GLM for a Two-Factor Analysis Dependent Variable: life The GLM Procedure Observed Life of battery in Months Contrast DF Contrast SS Mean Square F Value Pr > F Set of Orthogonal Contrasts - 1 1 8.333 8.333 0.57 0.4771 Set of Orthogonal Contrasts - 1 7.000 7.000 4.97 0.0674 Set of Orthogonal Contrasts - 3 1.000.000 0.14 0.731 Set of Orthogonal Contrasts - 4 1 18.000 18.000 1.4 0.3078 Set of Orthogonal Contrasts - 5 1 16.000 16.000 14.90 0.0084 Standard Parameter Estimate Error t Value Pr > t Set of Orthogonal Contrasts - 1 5.0000000 6.5954598 0.76 0.4771 Set of Orthogonal Contrasts - -1.0000000 5.38516481 -.3 0.0674 Set of Orthogonal Contrasts - 3.0000000 5.38516481 0.37 0.731 Set of Orthogonal Contrasts - 4 6.0000000 5.38516481 1.11 0.3078 Set of Orthogonal Contrasts - 5 36.0000000 9.3737905 3.86 0.0084 These sum to 315.0 (sst in the complete treatment model)!

- A Note on Estimating Sample Sizes: Again, estimation of sample size necessary to achieve a minimum level of power (or specified length of confidence interval) are dependent on our ability to accurately estimate the mse. If the objective is to to achieve a specified length of confidence interval, we can work with the sample size until we find a suitable value of the critical coefficient w. If we are interested in the power of our hypothesis test, i.e., the probability of rejecting H 0 when at least two treatment effects differ by a given amount ( ) or more, we will work with each factor (A and B) individually. We again denote the power of the test as π( ), which is obviously a function of - the desired power of the test - the treatment sample sizes r i, i = 1,,ν - the number of treatments ν - the chosen level of significance α - the error variance σ We can use, ν, α and an estimate of σ to determine the treatment sample sizes through the formulae aσ φ bσ φ r = for Factor A and r = for Factor B. b a A B smallest difference of interest in Factor A smallest difference of interest in Factor B If the values of r differ across factors (as they usually will!) choose the larger (i.e., more conservative) r.

- A Note on Single Replicate Experiments: If the sample size is limited to r = 1 observation per treatment combination: the experiment will suffer from low power confidence intervals will be relatively wide These issues can be addressed to some extent through the use of a two-way main effects model. Note that if such a model is inappropriate, we must use the two-way compete model which has degrees of freedom for error of ab(r 1) which is zero for a single replicate experiment (and we are unable to estimate σ )! We can proceed with a two-way complete analysis of a single replicate experiment under any of the following conditions: σ (or a very reliable estimate) is known in advance (very unlikely) the interaction is expected to be of a form with fewer than (a 1)(b 1) degrees of freedom use Tukey s Test for Additivity to measure interaction the number of treatment combinations is large and only a few nonnegligble contrasts are expected occurs most frequently in the presence of more than two crossed factors

Tukey s Test for Additivity an approach that uses a single degree of freedom to test for the presence of interaction. The null hypothesis is γ H = αβ = γαβ ij 0 ij and the alternative hypothesis is that the interaction is not of this form. The test statistic is where * ssab = F = a b i=1 j=1 ssab sse e * γ H 0 ~ F 1, ( a-1)( b-1 ),α ab y y y - ssa + ssb + aby y ij i j ssa and sse = sstot ssa ssb ssab * ( ssb) Note that: Tukey s test for additivity can only be used to test for an interaction effect that is expected to change proportionally to changes in the main effects the test is not robust with respect to the assumption of normality. One final note for an imbalanced design, use Type III sums of squares to test hypotheses and Least Squares (LS) Means for pairwise comparisons of treatment means.

Short Summary of Types of Sums of Squares To examine these SS and associated tests, we must consider three experimental design scenarios (here a "cell" is a treatment combination): 1. balanced data (each treatment combination has exactly r replicates). unbalanced data but each treatment combination has at least one observation 3. unbalanced data with one or more empty treatment combination The various types of sums of squares are: Type I (sequential) the incremental improvement in the error SS as each effect is added to the model in some prespecified order (i.e., sequential sum of squares) Type II (partial or hierarchical) - reduction in error SS due to adding the term to the model after all other terms except those that contain it (i.e., partial sum of squares for balanced designs) Type III (orthogonal) - reduction in error SS due to adding the term after all other terms have been added to the model (i.e., partial sum of squares for imbalanced designs with no sparseness) Type IV (balanced) - variation explained by balanced comparison of averages of cell means (i.e., partial sum of squares for sparse designs)

Note that: All four types of sums of squares yield the same results for balanced designs (this is the same analysis as provided by Proc ANOVA) For unbalanced designs with no missing treatment combinations, types III and IV sums of squares test the balanced hypotheses (correct for imbalance) hypotheses for Types I and II depend on the number of observations per cell (do not correct for imbalance ) Type I sums of squares are appropriate when hypotheses depend on the order in which effects are specified/ introduced. This is particularly critical when some factors (such as blocking) should be taken out before other factors, even in an unbalanced design. Sums of squares for all the effects sum to the sstot only for Type I sums of squares. Type I sums of squares for polynomial models correspond to tests of orthogonal polynomials. Type II sums of squares are appropriate for model building, and are the natural choice for regression analysis. Type III and Type IV sums of squares tests differ only if the design has empty treatment combinations. With one or more empty treatment combinations, main effects are difficult to understand, interpret, and compare (some marginal means may not even be defined). It is not generally obvious how to work with main effects with missing treatment combinations.

Example Consider an imbalanced version of the Automobile Battery Life problem with the addition of information regarding the class of auto in which the battery is installed (Mid-sized or Full-sized): Automobile Battery Life (in Months) New England Mid West South West 48 51 39 4 45 43 43 56 38 47 5 36 We ll use Region as Factor A (i = 1 for New England, i = for Mid West, and i = 3 for South West) and Class of Auto as Factor B (j = 1 for Mid-sized and j = for Full-sized). Use these data to perform a Two Way main effects ANOVA. SAS code for an Imbalanced Two Way Complete Model: DATA battery; INPUT region $ autotype $ treatmnt life; CARDS; NewEngland Mid 1 48......... SouthWest Full 6 36 ; PROC GLM DATA=battery; TITLE4 'Using PROC GLM for a Two-Factor Complete Analysis'; CLASS region autotype; MODEL life=region autotype region*autotype/ss1 SS SS3 SS4; MEANS region autotype/tukey CLDIFF ALPHA=0.01; LSMEANS region autotype/pdiff TDIFF ADJUST=TUKEY; RUN;