Class 24: Tues., Dec. 7th Today: Two-way analysis of variance Thursday: Design of Experiments Schedule: –Thurs., Dec. 9 th – Final class –Mon., Dec. 13 th (5 pm) – Preliminary results from final project due –Tues., Dec. 14 th (5 pm) – Homework 9 due –Tues., Dec. 21 st (Noon) – Final project due.
Analysis of Variance Terminology The criterion (criteria) by which we classify the groups in analysis of variance is called a factor. In one-way analysis of variance, we have one factor. The possible values of the factor are levels. Milgram’s study: Factor is experimental condition with levels remote, voice-feedback, proximity and touch- proximity. Handicap study: Factor is type of videotape with levels amputee, crutches, hearing, none and wheelchair. Two-way analysis of variance: Groups are classified by two factors.
Two-way Analysis of Variance Examples Milgram’s study: In thinking about the Obedience to Authority study, many people have thought that women would react differently than men. Two-way analysis of variance setup in which the two factors are experimental condition (levels remote, voice-feedback, proximity, touch-proximity) and sex (levels male, female). Package Design Experiment: Several new types of cereal packages were designed. Two colors and two styles of lettering were considering. Each combination of lettering/color was used to produce a package, and each of these combinations was test marketed in 12 comparable stores and sales in the stores were recorded.. Two-way analysis of variance in which two factors are color (levels red, green) and lettering (levels block, script). Goal of two-way analysis of variance: Find out how the mean response in a group depends on the levels of both factors and find the best combination.
Two-way Analysis of Variance The mean of the group with the ith level of factor 1 and the jth level of factor 2 is denoted, e.g., in package-design experiment, the four group means are As with one-way analysis of variance, two-way analysis of variance can be seen as a a special case of multiple regression. For two-way analysis of variance, we have two categorical explanatory variables for the two factors and also include an interaction between the factors.
Estimated Mean for Red Block group = = Estimated Mean for Red Script group = =
The LS Means Plots show how the means of the groups vary as the levels of the factors vary. For the top plot for color, green refers to the mean of the two green groups (green block and green script) and red refers to the mean of the two red groups (red block and red script). Similarly for the second plot for TypeStyle, block refers to the mean of the two block groups (red block and green block). The third plot for TypeStyle*Color shows the mean of all four groups.
Two-way ANOVA in JMP Use Analyze, Fit Model with a categorical variable for the first factor, a categorical variable for the second factor and an interaction variable that crosses the first factor and the second factor. The LS Means Plots are produced by going to the output in JMP for each variable that is to the right of the main output, clicking the red triangle next to each variable (for package design, the vairables are Color, TypeStyle, Typestyle*Color) and clicking LS Means Plot.
Interaction in Two-Way ANOVA Interaction between two factors: The impact of one factor on the response depends on the level of the other factor. For package design experiment, there would be an interaction between color and typestyle if the impact of color on sales depended on the level of typestyle. Formally, there is an interaction if LS Means Plot suggests there is not much interaction. Impact of changing color from red to green on mean sales is about the same when the typestyle is block as when the typestyle is script.
Effect Test for Interaction A formal test of the null hypothesis that there is no interaction, for all levels i,j,i’,j’ of factors 1 and 2, versus the alternative hypothesis that there is an interaction is given by the Effect Test for the interaction variable (here Typestyle*Color). p-value for Effect Test = No evidence of an interaction.
Implications of No Interaction When there is no interaction, the two factors can be looked in isolation, one at a time. When there is no interaction, mean for group ij can be expressed as When there is no interaction, best group is determined by finding best level of factor 1 and best level of factor 2 separately. For package design experiment, suppose there are two separate groups: one with an expertise in lettering and the other with expertise in coloring. If there is no interaction, groups can work independently to decide best letter and color. If there is an interaction, groups need to get together to decide on best combination of letter and color.
Model when There is No Interaction When there is no evidence of an interaction, we can drop the interaction term from the model and the mean for group ij can be expressed as Mean for red block group = = Mean for red script group = =165.92
Tests for Main Effects When There is No Interaction Effect test for color: Tests null hypothesis that group mean does not depend on color versus alternative that group mean is different for at least two levels of color. p-value =0.0804, moderate but not strong evidence that group mean depends on color. Effect test for TypeStyle: Tests null hypothesis that group mean does not depend on TypeStyle versus alternative that group mean is different for at least two levels of TypeStyle. p-value = , evidence that group mean depends on TypeStyle. These are called tests for “main effects.” These tests only make sense when there is no interaction.
Which Combinations Works Best? For which pairs of groups is there strong evidence that the groups different means – is there strong evidence that one combination works best. We combine the two factors into one factor (Combination) and use Tukey’s HSD, to compare groups pairwise, adjusting for multiple comparisons.
Although the combination Red Script generated the most sales, there is not strong evidence that it is better than Red Block or Green Script. There is strong evidence that Red Script is better than Green Block.
Checking Assumptions As with one-way ANOVA, two-way ANOVA is a special case of multiple regression and relies on the assumptions: –Linearity: Automatically satisfied –Constant variance: Spread within groups is the same for all groups. –Normality: Distribution within each group is normal. To check assumptions, combine two factors into one factor (Combination) and check assumptions as in one-way ANOVA.
Checking Assumptions Check for constant variance: (Largest standard deviation of group/Smallest standard deviation of group) 2 =(44.85/33.51) 2 <3. Constant variance OK. Check for normality: Look at normal quantile plots for each combination (not shown). For all normal quantile plots, the points fall within the 95% confidence bands. Normality assumption OK.
Evaluating Employee Time Schedules Should the clerical employees of a large insurance company be switched to a four-day week, allowed to use flextime schedules or kept to the usual 9-5 workday. Data in flextime.JMP measure percent efficiency gains over a four week period for 11 employees under each of three schedules (flextime, four- day week, regular hours) for three departments (Claims, Data Processing, Investments). Two-way analysis of variance with one factor being Schedule and the other factor being Department.
Strong evidence of an interaction between schedule and department, p-value for Effect test < We can’t look at schedule and department in isolation. Other effect tests not meaningful when there is an interaction.
Schedule is important but it affects different departments in different ways. The flextime schedule is best for the data processing department. The four-day schedule is best for the investments department. The schedules are all about equal for the claims department. Use Tukey’s HSD with a variable that combines schedule and department to see for which groups there is strong evidence that the means are different.