Presentation is loading. Please wait.

Presentation is loading. Please wait.

Two-Way ANOVA Interactions. What we will cover Two-way ANOVA: Family of ANOVA tests More examples in R Looking at interaction plots How to interpret the.

Similar presentations


Presentation on theme: "Two-Way ANOVA Interactions. What we will cover Two-way ANOVA: Family of ANOVA tests More examples in R Looking at interaction plots How to interpret the."— Presentation transcript:

1 Two-Way ANOVA Interactions

2 What we will cover Two-way ANOVA: Family of ANOVA tests More examples in R Looking at interaction plots How to interpret the results

3 Background Analysis of variance: A analysis of variance is a technique that partitions the total sum of squares of deviations of the observations about their mean into portions associated with independent variables in the experiment and a portion associated with error A factor refers to a categorical quantity under examination in an experiment as a possible cause of variation in the response variable.

4 Types of Experimental Designs Experimental Designs One-Way Anova Completely Randomized Randomized Block Two-Way Anova Factorial

5 One-Way ANOVA Partitions Total Variation Variation due to treatment Variation due to random sampling Total variation Remember we mentioned that ‘between groups’ and ‘within groups’ may be called something else…

6 Factorial Design 1.Experimental Units (Subjects) Are Assigned Randomly to Treatments Subjects are Assumed Homogeneous 2.Two or More Factors or Independent Variables Each Has 2 or More Treatments (Levels) 3.Analyzed by Two-Way ANOVA (if we have two factors) 1.Saves Time & Effort e.g., Could Use Separate Completely Randomized Designs for Each Variable 2.Controls Confounding Effects by Putting Other Variables into Model 3.Can Explore Interaction Between Variables

7 Total Variation Two-Way ANOVA Total Variation Partitioning Variation Due to Treatment A Variation Due to Random Sampling Variation Due to Interaction SSESS(AB) SS(Total) Variation Due to Treatment B SSBSSA

8 Part 2 – The two way ANOVA Example Suppose you want to determine whether the brand of laundry detergent used and the temperature affects the amount of dirt removed from your laundry. To this end, you buy two different brand of detergent (“ Super” and “Best”) and choose three different temperature levels (“cold”, “warm”, and “hot”). Then you divide your laundry randomly into 6×r piles of equal size and assign each r piles into the combination of (“Super” and “Best”) and (”cold”,”warm”, and “hot”).

9 Two-way ANOVA A two-way ANOVA always involves two independent variables. Each independent variable, or factor, is made up of, or defined by, two or more elements called levels. When looked at simultaneously, the levels of the first factor and the levels of the second factor create the conditions of the study to be compared. Each of these conditions is referred to as a cell.

10 Two-way ANOVA In any two-way ANOVA, the first research question asks whether there is a statistically significant main effect for the factor that corresponds to the rows of the two-dimensional picture of the study. The second research question asks whether there is a statistically significant main effect for the factor that corresponds to the columns of the two-dimensional picture of the study. The third first research question asks whether there is a statistically significant interation effect between factor A and factor B. Factor A = detergent [super, best], Factor B = temperature [cold,warm,hot], dependent variable (a.k.a. y, or response) = amount of dirt removed.

11 Hypotheses

12 R Another example. Note you don't have the 'detergent.csv' file but we can create it from the Excel file below. > detergent plot.design( detergent ) > detergent_aov summary( detergent_aov ) Df Sum Sq Mean Sq F value Pr(>F) Factor.Detergent 1 20.17 20.17 9.811 0.00576 ** Factor.Temperature 2 200.33 100.17 48.730 5.44e-08 *** Factor.Detergent:Factor.Temperature 2 16.33 8.17 3.973 0.03722 * Residuals 18 37.00 2.06 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Excel file

13 First Example Note you don't have the 'detergent.csv' file but you can create it from the Excel file on moodle.Excel file > detergent <- read.csv( "C:/detergent.csv", header=TRUE) > names(detergent) > par(mfrow=c(1,2)) > plot( Dirt.Removed ~ Factor.Detergent + Factor.Temperature, data=detergent) > detergent_aov <- aov(Dirt.Removed ~ Factor.Detergent * Factor.Temperature, data=detergent) > summary( detergent_aov )

14 Check the P-value What is it? “The P value or calculated probability is the estimated probability of rejecting the null hypothesis (H0) of a study question when that hypothesis is true.” [http://www.statsdirect.com/help/basics/pval.htm]http://www.statsdirect.com/help/basics/pval.htm “…p-value is the probability of finding the observed sample results, or "more extreme" results, when the null hypothesis is actually true (where "more extreme" is dependent on the way the hypothesis is tested)[http://en.wikipedia.org/wiki/P-value]null hypothesis Just think about what we are really doing! We assume the null hypothesis is true

15 Reducing the Dataset detergent_no_cold <- detergent[detergent$Factor.Temperature != 'cold',] detergent__no_cold_aov <- aov(Dirt.Removed ~ Factor.Detergent * Factor.Temperature, data=detergent_no_cold) summary(detergent__no_cold_aov) detergent_no_warm = subset(detergent, Factor.Temperature != 'warm') View(detergent_no_cold) View(detergent_no_warm) detergent_no_temperature = detergent[c(1,3)] detergent_no_brand <- detergent[2:3]

16 Calculations The excel file shows where some of the values come from etc. But this type of analysis is done with a stats package. We can carry out the two-way ANOVA in excel too…

17 Modelling the H 0 What do we use to model the null hypothesis? It’s often useful at a high level to think of distributions as a normal curve. But in practice an F-distribution is different etc.

18 We can never be certain… What are our chances of making a type I error? What is a type I error?! (You should know this) How does this relate to ‘alpha inflation’?

19 Back to ANOVA A two-factor ANOVA should begin with an examination of the interactions. Interpretation of the main effects changes according to whether interactions are present. If there is an interaction between DRUG and GENDER, say, the drug that is best for men might be different from the one that is best for women. If there is no interaction between the factors, then the effect of one factor is the same for all levels of the other factor. With no interaction, the drug that is best on average is the best for everyone. > par(mfrow=c(2,1)) > interaction.plot( Factor.Temperature,Factor.Detergent, Dirt.Removed) > interaction.plot( Factor.Detergent, Factor.Temperature, Dirt.Removed)

20 Two-way ANOVA Table Source of Variation Degrees of Freedom Sum of SquaresMeanSquare F-ratio P-value Factor A a  1a  1a  1a  1 SS A MS A F A = MS A / MS E Tail area Factor B b  1b  1b  1b  1 SS B MS B F B = MS B / MS E Tail area Interaction (a – 1)(b – 1) SS AB MS AB F AB = MS AB / MS E Tail area Error ab(n – 1) SS E MS E Total abn  1 SS T This is our initial focus which is the p-value for Question 1: Is there an interaction effect?

21 Tests of Hypotheses If the interaction is not statistically significant (i.e. p-value > 0.05) then we conclude the main effects (if present) are independent of one another. We can then test for significance of the main effects separately, again using an F-test. If a main effect is significant we can then use multiple comparison procedures as usual to compare the mean response for different levels of the factor while holding the other factor fixed.


Download ppt "Two-Way ANOVA Interactions. What we will cover Two-way ANOVA: Family of ANOVA tests More examples in R Looking at interaction plots How to interpret the."

Similar presentations


Ads by Google