Analysis of Variance: - One-Way ANOVA - Two-Way ANOVA
Analysis of Variance: - One-Way ANOVA - Two-Way ANOVA
Analysis of Variance: - One-Way ANOVA - Two-Way ANOVA
Analysis of Variance
• One-way ANOVA
• Two-way ANOVA
Analysis of Variance
Analysis of Variance
One-way analysis of variance (One-Way ANOVA) is a method used
to compare 2 or more group means simultaneously.
Example:
Terminology:
Factors are the independent variables (qualitative) in the study, e.g. Sex
Levels are the categories of the variable, e.g. Sex: Male/Female
Response is the dependent variable (quantitative)
Analysis of Variance
Data Format
From each
population,
samples of
observations are
taken,
xij is the jth
observation from
the ith sample
(i=1,2,…,k)
Shapiro-Wilk’s test
Ho: Distribution is normal.
H1: Distribution is not normal.
Barlett’s test
Ho: Population variances are all equal.
H1: Not all population variances are equal.
Analysis of Variance
GT = grand total
Analysis of Variance
MSW = MSE
Analysis of Variance
Homogeneity assumption:
Analysis of Variance
Conclusion:
At least one of the
three conditions
differed
significantly on
anxiety level.
Analysis of Variance
School Ho: μ1 = μ2 = μ3 = μ4
A B C D There are no differences in
the mean entrance exam
50
35 scores of the nursing
40 47
50 45 students across schools.
30 45
45 50
25 48
48 26 H1: Not all μ’s are equal
27 38
50 36
31 45 At least one the means is
24
39 different.
Are there differences in the mean scores?
Analysis of Variance
Homogeneity assumption:
Analysis of Variance
Statistical Decision:
Reject Ho. (p-value=0.0022).
Conclusion:
On the basis of these
data, we can conclude
that at least one school
differed significantly in
the mean entrance exam
score of nursing
students.
Analysis of Variance
Types of ANOVA
One-Way ANOVA
• one factor (independent variable-qualitative) with at least two levels
• the observations across levels are independent (different subjects)
Example:
0 mg 50 mg 100 mg
Types of ANOVA
Two-way ANOVA
• two factors (independent variable-qualitative)
• the observations across levels are independent (different subjects)
Example: Dosage
A study to determine the Center
effects of 3 doses of a new Placebo 25 mg 50 mg 75 mg
therapeutic agent on a 5 3 6 8 8 8 7 8
short-term memory 1 5 3 7 10 9 9 8 7
function was conducted at
two different centers. The
6 4 9 9 10 10 6 8
subjects were administered
2 5 8 8 6 8 10 9
a single oral dose of test
preparation and then
2 4 2 6 10 10 8 7 10
asked to recall items one 3 4 9 8 7 7 11 7
hour after exposure to a list
consisting of 12 items. Response: Anxiety rating
Factors: Dosage and Center
Analysis of Variance
Two-way ANOVA:
Ho1: μA1= μA2= μA3 Ho2: μB1= μB2= μB3 H03: Interaction absent
H1: not all are equal H13: Interaction present
Analysis of Variance
Assumptions
1. Normality. Each set of data has a normal distribution.
Two-Way ANOVA
Source df SS MS F
Column Means
(A)
Error (AxS) dfA SSA MSA
dfE(AxS) SSE(AxS) MSE(AxS)
Row Means (B) dfB SSB MSB MSB/MSE
Error (BxS) dfE(BxS) SSE(BxS) MSE(BxS)
Interaction (AxB) dfAxB SS(AxB) MS(AxB)
dfE(AxBxS) SSE(AxBxS) MSE(AxBxS)
Error (AxBxS) dfE(s) SSE(S) MSE(S)
Error (S)
Total N-1 SST
dfA = a – 1 df(AxB) = (a – 1)(b – 1)
dfE(AxS) = (a – 1) (n – 1) dfE(AxBxS) = (a – 1)(b – 1)(n – 1)
dfB = b – 1 dfE(S) = (n – 1)
dfE(BxS) = (b – 1) (n – 1) dfT = N - 1
Analysis of Variance
Two-Way ANOVA
Analysis of Variance
Two-Way ANOVA
Analysis of Variance
Two-Way ANOVA
Example: Researchers want to
compare anxiety levels of six
individuals at two marital status: Week
after they have divorced, and then Marital Subjec
Status t 1 2 3
again after they have gotten
married. Anxiety is measured three 1 5
3 7
times: week1, week2, and week3. 2
4
4
8
Anxiety is rated on a scale of 1-10, 3 3
Divorce 5 7
with 10 being “high anxiety” and 1 4 5
d 3 8
5 5
being “low anxiety”. Use ɑ = 0.05 6
4
5
7
level of significance to conduct an 3 7
analysis. 1
5 5 9
2
4 4 8
1st dependent factor: week 3
3 3 9
Married 4
5 5 8
2nd dependent factor: marital 5
5 5 7
6
status 4 4 9
Analysis of Variance
Two-Way ANOVA
1 3. Ho3: An interaction is
5 5 9
2 absent.
4 4 8
3 H13: An interaction is
3 3 9
Married 4 present.
5 5 8
5
5 5 7
6
4 4 9
Analysis of Variance
Two-Way ANOVA
Analysis of Variance
Two-Way ANOVA
Statistical Decision:
Two-Way ANOVA
Two-Way ANOVA
Two-Way ANOVA
Conclusion:
Anxiety levels
differed
significantly for
divorced and
remarried
individuals.
There was also
significant
difference between
the points in time
(after 1wk, 2 wks,
and 3wks).
An interaction effect
was also present.
Sample R Implementation
One-way ANOVA
y <- c(2,3,1,2, 8,7,9,8, 11,12,13,12)
a <- gl(3,4) # or use “factor”
anova(lm(y ~ a))
Sample R Implementation
Two-way ANOVA:
facmolb <- factor(ALLBm$mol.biol)
facB <-factor(ALLBm$BT)
anova(lm(ALLBm) ~ facB * facmolb))
Sample R Implementation
Test for normality of residuals:
shapiro.test(residuals(lm(y ~ ALLB123$BT)))
#Ho: The population is normal.
References