Escolar Documentos
Profissional Documentos
Cultura Documentos
Multi-factor ANOVA
Thursday Sessions
ANOVA
One-way ANOVA Two-way ANOVA ANCOVA With-in subject Between subject Repeated measures MANOVA etc.
What is ANOVA?
ANalysis Of VAriance
Partitions the observed variance based on explanatory variables Compare partitions to test significance of explanatory variables
Some Terminology
Between subjects design each subject participates in one and only one group Within subjects design the same group of subjects serves in more than one treatment
Subject is now a factor
Mixed design a study which has both between and within subject factors Repeated measures general term for any study in which multiple measurements are measured on the same subject
Can be either multiple treatments or several measurements over time
January 7, 2009 morning session
4
ANOVA
Use variances and variance like quantities to study the equality or nonequality of population means So, although it is analysis of variance we are actually analyzing means, not variances There are other methods which analyze the variances between groups
ANOVA
Typical exploratory analysis includes
Tabulation of the number of subjects in each experimental group Side-by-side box plots Statistics about each group
At least mean and standard deviation, can include 5-number summary and information on skewness
Notation
If we have k groups, denote the means of the groups as:
1, 2, . . ., k
With random assignment, the sample mean for any treatment group is representative of the population mean for that group
January 7, 2009 morning session
7
Assumptions
1. The errors ij are normally distributed 2. Across the conditions, the errors have equal spread. Often referred to as equal variances.
Rule of thumb: the assumption is met if the largest variance is less than twice the smallest variance If unequal variances need to make a correction!! This is usually /2.
1. Look at normal probability plot 2. Look at residual versus fitted plot 3. Hard to check, often assumed from study design
For mild violations of the assumptions, there are options for correction
When the assumptions are not met the p-value is simply wrong!!
January 7, 2009 morning session
9
One-way ANOVA
One-way ANOVA is used when
Only testing the affect of one explanatory variable Each subject has only one treatment or condition
Thus a between-subjects design
Hypothesis Testing
H0: 1 = 2 = . . . = k H1: the s are not all equal The alternative hypothesis H1: 1 k is wrong! The null hypothesis is called the overall null and is the hypothesis tested by ANOVA If the overall null is rejected, must do more specific hypothesis testing to determine which means are different, often referred to as contrasts
11
Terminology
The sample variance is the sum of the squared deviations from the mean divided by the degrees of freedom 2
(x x)
i
N 1
SS MS df
12
One-way ANOVA
In one-way ANOVA we work with two mean square quantities
MSwithin the mean square within-groups MSbetween the mean square between-groups
MSwithin
SS within df within
MSbetween
SS between df between
13
14
One-way ANOVA
For each individual group we have
SS i df i
2 ( x x ) j 1 ij i ni
ni 1
MSwithin
2 n ( x x ) i i 1 i
k 1
15
Mean Squares
What do these values mean? MSwithin is considered a true estimate of 2 that is unaffected by whether the null or alternative hypothesis is true MSbetween is considered a good estimate of 2 only when the null hypothesis is true
If the alternative is true, values of MSbetween tend to be inflated
Thus, we can look at the ratio of the two mean square values to evaluate the null hypothesis
January 7, 2009 morning session
16
SSbetween
SSbetween
17
Sig P-value
MSbetween MSwithin
SSwithin
dfwithin
MSwithin
19
Example
Suppose we want to know if typing speed varies across majors
Box plots
21
Summary
The largest variance is less than twice the smallest variance (38.8 < 2 20.1 = 40.2). Use = 0.05.
Major Biology Business English Mathematics ni 25 25 25 25 Mean 45.3 47.6 55.6 45.1 Variance 24.7 25.4 38.8 20.1
22
Degrees of Freedom
How many groups do we have? What is the sample size? Using these values:
What is dfwithin?
What is dfbetween?
23
Degrees of Freedom
How many groups do we have?
There are k = 4 groups Biology, English, Business, and Mathematics
What is dfwithin?
N k = 100 4 = 96
January 7, 2009 morning session
24
Sample Output
SS Group (Treatment, between) Residual (Error, within) Total 1807.49 Df 3 MS 602.50 F 22.091 Sig 0.000
2618.20
96
27.17
4425.69
99
25
Results
F-statistic = 22.1 P-value: <0.0005 Conclusion the average words per minute differs for at least one of the majors To make stronger statements need to do further testing
26
27
Further Analysis
If H0 is rejected, we conclude that not all the s are equal
Contrasts
A simple contrast hypothesis compares two population means
HO: 1 = 5
29
Planned Comparisons
Most statistical packages allow you to enter custom planned contrast hypotheses The p-values are only valid under strict conditions
The conditions maintain Type-1 error rate across the whole experiment
Computer packages assume that you have checked the assumptions of the ANOVA test
January 7, 2009 morning session
30
31
Unplanned Comparisons
What if we notice a possible interesting difference when looking at the results? Can do comparisons but need to adjust the -level to control for Type-1 error One common method is to use Tukeys simultaneous confidence intervals to calculate any and all pairs of group population means
This procedure takes multiple comparisons into consideration to preserve the level
January 7, 2009 morning session
32
Other Options
Bonferroni correction for the number of comparisons done Dunnetts tests Scheffe procedure
33
34
Conclusions
In the table on the previous page,
1 = Biology, 2 = Business, 3 = English, 4 = Mathematics
Biology, Business, and Mathematics are all are significantly different from English There are no other significant differences
35
36
Comparison to Regression
Sample regression output
Which major is our baseline?
37
Comparison to Regression
F-statistic = 22.1, p-value < 0.0005
This is the same F-statistic and p-value as the ANOVA on slide 25
At least one of the explanatory variables is important in this corresponds to the rejection of the null, at least one of the means differs
38
Comparison to Regression
Note that Biology is the baseline and 45.3 is the mean WPM for Biology students Note that Business and Mathematics are not significant Agrees with post-hoc comparisons that neither Business or Mathematics is significantly different from Biology, but English is not To make further conclusions will need to look at multiple comparisons, such as the previous Tukey intervals
39
Regression
The conclusions about the overall null hypothesis will be the same
Estimate of 2
Based on previous years, we know that 95% of the student scores on SATs fall between 900 and 1500 = (1500-900)/4 = 150 2 = 150^2
42
43
sd[treatment]
Different applets will define things slightly different. Find an applet you understand.
For the applet I will show you, they require sd[treatment]. From their definition this is calculated as
sd[treatme nt]
2 ( ) i1 i k
k -1
47
Two-way ANOVA
Suppose we now have two categorical explanatory variables Is there a significant X1 effect? Is there a significant X2 effect? Are there significant interaction effects? If X1 has k levels and X2 has m levels, then the analysis is often referred to as a k by m ANOVA or k x m ANOVA
48
Terminology
If the interaction is significant, the model is called an interaction model If the interaction is not significant, the model is called an additive model
49
Assumptions
The assumptions are the same as in One-way ANOVA
1. The errors ij are normally distributed
2. Across the conditions, the errors have equal spread. Often referred to as equal variances. 3. The errors are independent from each other
50
Two-way ANOVA
Two-way (or multi-way) ANOVA is an appropriate analysis method for a study with a quantitative outcome and two (or more) categorical explanatory variables. The assumptions are Normality, equal variance, and independent errors.
51
Results
Results are again displayed in a ANOVA table Will have one line for each term in the model. For a model with two factors, we will have one line for each factor and one line for the interaction. We will also have a line for the error and the total. See next page.
52
The MS(error), denoted by * in the above table, is the true estimate of 2 The MS in each row is that rows SS/df The F-statistic is the MS/MS(error)
January 7, 2009 morning session
53
Exploratory Analysis
Table of means Interaction or profile plots
An interaction plot is a way to look at outcome means for two factors simultaneously A plot with parallel lines suggests an additive model A plot with non-parallel lines suggests an interaction model Note that an interaction plot should NOT be the deciding factor in whether or not to run an interaction model
January 7, 2009 morning session
54
Example
Continuing with the previous example, suppose wed like to add gender as an explanatory variable X1: Major 4 levels X2: Gender 2 levels Response: words per minute typed We will fit an 4 by 2 ANOVA
January 7, 2009 morning session
55
English
Mathematics Overall
55.3
45.6 48.9
55.9
44.6 47.9
55.6
45.1 48.4 Male
Note, this table should also include the standard error of each of the means.
Female 11 15 11 13
56
14 10 14 12
Mathematics
Interaction plots
57
Interaction plots
There are two ways to do an interaction plot. Both are legitimate. Ease of interpretation is the final criteria of which to do. If one explanatory variable has more levels than the other, interpretation is often easier if the explanatory variable with more levels defines the x-axis If one explanatory variable is quantitative but has been categorized and the other is categorical, interpretation is often easier if the categorized quantitative variable defines the xaxis.
Example: age, 20-29, 30-39, 40-49, etc.
January 7, 2009 morning session
58
Results
Typical output:
Results
Updated results
Now we can interpret the main effects. We can see that major is significant but that gender is not.
60
61
Notes
If the interaction is significant, do not check the main effects. The main effects should always be kept if the interaction is significant. Note that due to the groups of students, you will see vertical lines in the residual versus predicted plot. This is due to the fact that all students with a particular combination of the factors will have the same predicted value.
January 7, 2009 morning session
62
Example 2
Using the same variables, lets look at a different outcome
63
English
Mathematics Overall
45.3
41.8 41.3
60.0
50.0 49.8
51.8
46.1 51.2
64
65
66
Results Example 2
Results
Example 2
68
Example 2
69
Example 3
Again, using the same variables, lets look at a different outcome
70
English
Mathematics Overall
54.8
52.0 51.3
62.1
48.4 51.1
58.1
50.1 58.0
71
72
Results Example 3
Results
In this case, the interaction and major are significant, but gender is not. Since the interaction is significant, leave gender in the model.
January 7, 2009 morning session
73
Example 3
74
Exploratory Analysis
76
Exploratory Analysis
77
78
ANOVA output
Conclusions?
79
80
Post-hoc Comparisons
Since there are only two levels of training and there is a significant training effect, we dont need multiple comparisons for training
81
Residual plot
No problems
82
Further Analysis
If there had been an interaction, we could create a table indicating which differences were significant
83
ANCOVA
Analysis of Covariance
At least one quantitative and one categorical explanatory variable In general, the main interest is the effects of the categorical variable and the quantitative variable is considered to be a control variable It is a blending of regression and ANOVA
84
Example
Suppose that we have two different math tutors and would like to compare performance on the final math test We also have time on tutor and would like to use that as another explanatory variable
85
Exploratory Analysis
86
ANCOVA
87
88
ANCOVA
89