Biostatistik – HPM FK UGM
Lecture 12
Multisample inference:
Analysis of Variance
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
1
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Learni ng Obj ecti ves
1.
2.
3.
4.
Describe Analysis of Variance
(ANOVA)
Explain the Rationale of ANOVA
Compare Experimental Designs
Test the Equality of 2 or More Means
a. Completely Randomized Design
b. Randomized Block Design
c. Factorial Design
5.
Use of Computer Program
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
2
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Anal ysi s of Vari ance
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
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
3
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Anal ysi s of Vari ance
The ANOVA table was previously
discussed in the context of regression
models with quantitative independent
variables, in this chapter the focus will
be on nominal independent variables
(factors)
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
4
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Anal ysi s of Vari ance
A factor refers to a categorical
quantity under examination in an
experiment as a possible cause of
variation in the response variable.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
5
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Anal ysi s of Vari ance
Levels refer to the categories,
measurements, or strata of a factor
of interest in the experiment.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
6
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Types of Experi mental Desi gns
Experimental
Designs
Completely
Randomized
Randomized
Block
One-Way
Anova
10/27/2017
awilopo@yahoo.com
Factorial
Two-Way
Anova
Biostatistics I: 2017-18
7
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Compl etel y Randomi zed
Desi gn
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
8
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Compl etel y Randomi zed Desi gn
1.
Experimental Units (Subjects) Are
Assigned Randomly to Treatments
2.
One Factor or Independent Variable
3.
Subjects are Assumed Homogeneous
2 or More Treatment Levels or groups
Analyzed by One-Way ANOVA
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
9
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
1.
Tests the Equality of 2 or More (p)
Population Means
2.
Variables
10/27/2017
awilopo@yahoo.com
One Nominal Independent Variable
One Continuous Dependent Variable
Biostatistics I: 2017-18
10
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
Assumpti ons
1.
Randomness & Independence of
Errors
2.
Normality
•
3.
Populations (for each condition) are
Normally Distributed
Homogeneity of Variance
•
10/27/2017
awilopo@yahoo.com
Populations (for each condition) have
Equal Variances
Biostatistics I: 2017-18
11
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Hypotheses
H0: 1 = 2 = 3 = ... = p
All Population Means
are Equal
No Treatment Effect
Ha: Not All j Are Equal
At Least 1 Pop. Mean
is Different
Treatment Effect
1 2 ... p
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
12
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Hypotheses
H0: 1 = 2 = 3 = ... = p
All Population Means
are Equal
No Treatment Effect
f(X)
1 = 2 = 3
Ha: Not All j Are Equal
At Least 1 Pop. Mean is
Different
Treatment Effect
1 = 2 = ... = p
Or i ≠ j for some i, j.
10/27/2017
awilopo@yahoo.com
X
f(X)
Biostatistics I: 2017-18
1 = 2 3
X
13
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Basi c Idea
1.
Compares 2 Types of Variation to Test
Equality of Means
2.
If Treatment Variation Is Significantly
Greater Than Random Variation then
Means Are Not Equal
3.
Variation Measures Are Obtained by
‘Partitioning’ Total Variation
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
14
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
15
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
16
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
17
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
10/27/2017
awilopo@yahoo.com
Variation due to
random sampling
Biostatistics I: 2017-18
18
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
Variation due to
random sampling
Sum of Squares Among
Sum of Squares Between
Sum of Squares
Treatment
Among Groups Variation
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
19
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
Variation due to
random sampling
Sum of Squares Among
Sum of Squares Between
Sum of Squares
Treatment (SST)
Among Groups Variation
10/27/2017
awilopo@yahoo.com
Sum of Squares Within
Sum of Squares Error
(SSE)
Within Groups Variation
Biostatistics I: 2017-18
20
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Total Vari ati on
SS Total Y11 Y Y21 Y Yij Y
2
2
2
Response, Y
Y
Group 1
10/27/2017
awilopo@yahoo.com
Group 2
Biostatistics I: 2017-18
Group 3
21
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Treatment Vari ati on
SST n1 Y1 Y n2 Y2 Y n p Y p Y
2
2
2
Response, Y
Y3
Y
Y1
Group 1
10/27/2017
awilopo@yahoo.com
Y2
Group 2
Biostatistics I: 2017-18
Group 3
22
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Random (Error) Vari ati on
SSE Y11 Y1 Y21 Y1 Y pj Y p
2
2
2
Response, Y
Y3
Y1
Group 1
10/27/2017
awilopo@yahoo.com
Y2
Group 2
Biostatistics I: 2017-18
Group 3
23
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
Test Stati sti c
1.
Test Statistic
F = MST / MSE
STT / p 1
SSE / n p
• MST Is Mean Square for Treatment
• MSE Is Mean Square for Error
2.
Degrees of Freedom
1 = p -1
2 = n - p
• p = # Populations, Groups, or Levels
• n = Total Sample Size
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
24
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Summary Tabl e
Source of Degrees Sum of
Variation
of
Squares
Freedom
Mean
Square
(Variance)
Treatment
p-1
SST
MST =
MST
SST/(p - 1) MSE
Error
n-p
SSE
MSE =
SSE/(n - p)
Total
n-1
SS(Total) =
SST+SSE
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
F
25
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Cri ti cal
Val ue
If means are equal,
F = MST / MSE 1.
Only reject large F!
Reject H0
Do Not
Reject H0
0
Fa ( p1, n p)
F
Always One-Tail!
© 1984-1994 T/Maker Co.
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
26
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Exampl e
Food1 Food2 Food3
As a vet epidemiologist
25.40 23.40 20.00
you want to see if 3 food
26.31 21.80 22.20
supplements have
different mean milk yields. 24.10 23.50 19.75
You assign 15 cows, 5 per 23.74 22.75 20.60
25.10 21.60 20.40
food supplement.
Question: At the .05 level,
is there a difference in
mean yields?
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
27
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
Sol uti on
H0: 1 = 2 = 3
Ha: Not All Equal
= .05
1 = 2 2 = 12
Critical Value(s):
= .05
0
10/27/2017
awilopo@yahoo.com
3.89
F
Test Statistic:
F
MST
MSE
23.5820
.9211
25.6
Decision:
Reject at = .05
Conclusion:
There Is Evidence Pop.
Means Are Different
Biostatistics I: 2017-18
28
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Summary Tabl e
Sol uti on
Source of Degrees of Sum of
Variation Freedom Squares
Food
3-1=2
47.1640
Error
15 - 3 = 12 11.0532
Total
15 - 1 = 14 58.2172
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
Mean
Square
(Variance)
F
23.5820
25.60
.9211
29
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS CODES FOR ANOVA
Data Anova;
input group$ milk @@;
cards;
food1 25.40
food2 23.40
food1 26.31
food2 21.80
food1 24.10
food2 23.50
food1 23.74
food2 22.75
food1 25.10
food2 21.60
;
run;
food3 20.00
food3 22.20
food3 19.75
food3 20.60
food3 20.40
proc anova; /* or PROC GLM */
class group;
model milk=group;
run;
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
30
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
OUTPUT - ANOVA
Source
DF
Model
2
Error
12
Corrected Total
10/27/2017
awilopo@yahoo.com
Sum of
Squares
Mean Square
F Value
Pr > F
47.16400000
23.58200000
25.60
F
0.0030
resp Mean
43350.00
Source
10/27/2017
F Value
F Value
Pr > F
11.99 0.0006
1.90 0.1759
51
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS OUTPUT - LSD
Means with the same letter are not significantly
different.
t Grouping
10/27/2017
awilopo@yahoo.com
Mean
N
trt
A
50200
5
C:
B
B
C B
C
C
44800
5
D:
41000
5
A:
37400
5
B:
Biostatistics I: 2017-18
52
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS OUTPUT - Bonferroni
Means with the same letter are not significantly
different.
Bon Grouping
A
A
B A
B
B C
C
C
10/27/2017
awilopo@yahoo.com
Mean
N
trt
50200
5
C:
44800
5
D:
41000
5
A:
37400
5
B:
Biostatistics I: 2017-18
53
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Factori al Experi ments
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
54
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Factori al Desi gn
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.
10/27/2017
awilopo@yahoo.com
Analyzed by Two-Way ANOVA
Biostatistics I: 2017-18
55
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Advantages
of Factori al Desi gns
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
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
56
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
1.
Tests the Equality of 2 or More
Population Means When Several
Independent Variables Are Used
2.
Same Results as Separate One-Way
ANOVA on Each Variable
-
10/27/2017
awilopo@yahoo.com
But Interaction Can Be Tested
Biostatistics I: 2017-18
57
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA Assumpti ons
1.
Normality
• Populations are Normally Distributed
2.
Homogeneity of Variance
• Populations have Equal Variances
3.
Independence of Errors
• Independent Random Samples are Drawn
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
58
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Data Tabl e
Factor
A
1
Y111
1
Y112
Y211
2
Y212
:
:
Ya11
a
Ya12
10/27/2017
awilopo@yahoo.com
Factor B
2
...
Y121 ...
Y122 ...
Y221 ...
Y222 ...
:
:
Ya21 ...
Ya22 ...
b
Y1b1
Y1b2
Y2b1
YX
2b2
:
Yab1
Yab2
Biostatistics I: 2017-18
Observation k
Yijk
Level i
Factor
A
Level j
Factor
B
59
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Nul l Hypotheses
1. No Difference in Means Due to
Factor A
H0: 1. = 2. =... = a.
2. No Difference in Means Due to
Factor B
3.
H0: .1 = .2 =... = .b
No Interaction of Factors A & B
10/27/2017
awilopo@yahoo.com
H0: ABij = 0
Biostatistics I: 2017-18
60
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Total Vari ati on Parti ti oni ng
Total Variation
SS(Total)
Variation Due to
Treatment A
Variation Due to
Treatment B
SSA
SSB
Variation Due to
Interaction
Variation Due to
Random Sampling
SS(AB)
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
SSE
61
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Summary Tabl e
Source of Degrees of Sum of
Variation
Freedom Squares
Mean
Square
F
A
(Row)
a-1
SS(A)
MS(A)
MS(A)
MSE
B
(Column)
b-1
SS(B)
MS(B)
MS(B)
MSE
AB
(a-1)(b-1)
(Interaction)
Error
Total
10/27/2017
awilopo@yahoo.com
n - ab
SS(AB)
SSE
MS(AB) MS(AB)
MSE
MSE
Same as
n-1
SS(Total)
Other
Biostatistics I: 2017-18
62
Designs
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Interacti on
1. Occurs When Effects of One Factor
Vary According to Levels of Other
Factor
2. When Significant, Interpretation of
Main Effects (A & B) Is Complicated
3.
Can Be Detected
10/27/2017
awilopo@yahoo.com
In Data Table, Pattern of Cell Means in One
Row Differs From Another Row
In Graph of Cell Means, Lines Cross
Biostatistics I: 2017-18
63
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Graphs of Interacti on
Effects of Gender (male or female) & dietary
group (sv, lv, nor) on systolic blood pressure
Interaction
Average
Response
No Interaction
male
Average
Response
male
female
sv
10/27/2017
awilopo@yahoo.com
lv
nor
Biostatistics I: 2017-18
female
sv
lv
nor
64
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA F-Test Exampl e
Effect of diet (sv-strict vegetarians, lvlactovegetarians, nor-normal) and gender
(female, male) on systolic blood pressure.
Question: Test for interaction and main effects
at the .05 level.
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
65
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS CODES FOR ANOVA
data factorial;
input dietary$ sex$
sbp;
cards;
sv male 109.9
sv male 101.9
sv male 100.9
sv male 119.9
sv male 104.9
sv male 189.9
sv female 102.6
sv female 99
sv female 83 .6
sv female 99.6
sv female 102.6
sv female 112.6
10/27/2017
awilopo@yahoo.com
lv male 116.5
lv male 118.5
lv male 119.5
lv male 110.5
lv male 115.5
lv male 105.2
nor male 128.3
nor male 129.3
nor male 126.3
nor male 127.3
nor male 126.3
nor male 125.3
nor female 119.1
nor female 119.2
nor female 115.6
nor female 119.9
nor female 119.8
nor female 119.7
;
run;
Biostatistics I: 2017-18
66
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS CODES FOR ANOVA
proc glm;
class dietary sex;
model sbp=dietary sex dietary*sex;
run;
proc glm;
class dietary sex;
model sbp=dietary sex;
run;
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
67
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS OUTPUT - ANOVA
Dependent Variable: sbp
Sum of
Source
DF
Squares Mean Square F Value Pr > F
Model
5 2627.399667
525.479933
1.96 0.1215
Error
24 6435.215000
268.133958
Corrected Total
29 9062.614667
R-Square
0.289916
Coeff Var
14.08140
Root MSE
16.37480
sbp Mean
116.2867
Source
dietary
sex
dietary*sex
DF
Type I SS Mean Square F Value Pr > F
2
958.870500
479.435250
1.79 0.1889
1 1400.686992 1400.686992
5.22 0.0314
2
267.842175
133.921087
0.50 0.6130
Source
dietary
sex
dietary*sex
DF Type III SS Mean Square F Value Pr > F
2 1039.020874
519.510437
1.94 0.1659
1 877.982292
877.982292
3.27 0.0829
2
267.842175
133.921087
0.50 0.6130
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
68
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Li near Contrast
Linear Contrast is a linear combination of the
means of populations
Purpose: to test relationship among different
group means
L cj j
with
c
j
0
Example: 4 populations on treatments T1, T2, T3 and T4.
Contrast T1
T2
T3
T4
relation to test
L1
L2
10/27/2017
awilopo@yahoo.com
1
1
0
-1/2
-1
-1/2
0
0
Biostatistics I: 2017-18
μ1 - μ 3 = 0
μ1 – μ2/2 – μ3/2 = 0
69
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
T-test for Li near Contrast (LSD)
Construct a t statistic involving k group
means. Degrees of freedom of t - test: df = n-
k.
k
To test H0:
L c j j 0 Construct
t
j 1
L
k
c 2j
j 1
nj
s2
Compare with critical value t1-α/2,, n-k.
Reject H0 if |t| ≥ t1-α/2,, n-k.
SAS uses contrast statement and performs an F – test df (1, n-k);
Or estimate statement and perform a t-test df (n-k).
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
70
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
T-test for Li near Contrast (Scheffe)
Construct multiple contrasts involving k
group means. Trying to search for
significant contrast
k
To test H0:
L c j j 0 Construct
j 1
Compare with critical value.
t
L
k
c 2j
j 1
nj
s2
a (k 1) Fk 1,n k ,1
Reject H0 if |t| ≥ a
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
71
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS Code for contrast testi ng
proc glm;
class trt block;
model resp=trt block;
Means trt /lsd bon scheffe;
contrast 'A - B = 0' trt 1 -1 0 0 ;
contrast 'A - B/2 - C/2 = 0' trt 1 -.5 -.5 0 ;
contrast 'A - B/3 - C/3 -D/3 = 0' trt 3 -1 -1 -1 ;
contrast 'A + B - C - D = 0' trt 1 1 -1 -1 ;
lsmeans trt/stderr pdiff;
lsmeans trt/stderr pdiff adjust=scheffe; /* Scheffe's test */
lsmeans trt/stderr pdiff adjust=bon;
/* Boneferoni's test
*/
estimate ‘A - B' trt 1 -1 0 0 0;
run;
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
72
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Regressi on representati on of Anova
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
73
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Regressi on representati on of Anova
yij i eij i eij
One-way anova:
p
0
i1
i
Two-way anova:
yijk ij eijk i j ij eijk
a
i 1
b
i
0, j 0,
j 1
b
j 1
ij
0 for all i and
a
i 1
ij
0 for all j
SAS uses a different constraint
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
74
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Regressi on representati on of Anova
One-way anova: Dummy variables of
factor with p levels
y 0 1 x1 2 x2 ... p1 x p1 e
1
where xi
0
if level i
if otherwise
This is the parameterization used by SAS
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
75
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Concl usi on: shoul d be abl e to
1. Recognize the applications that uses
ANOVA
2. Understand the logic of analysis of
variance.
3. Be aware of several different analysis of
variance designs and understand when to use
each one.
4. Perform a single factor hypothesis test
using analysis of variance manually and with
the aid of SAS or any statistical software.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
76
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Concl usi on: shoul d be abl e to
5. Conduct and interpret post-analysis of
variance pairwise comparisons
procedures.
6. Recognize when randomized block
analysis of variance is useful and be able to
perform the randomized block analysis.
7. Perform two factor analysis of variance
tests with replications using SAS and
interpret the output.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
77
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Key Terms
Between-Sample
Variation
Completely
Randomized
Design
Experiment-Wide
Error Rate
Factor
10/27/2017
awilopo@yahoo.com
Levels
One-Way Analysis
of Variance
Total Variation
Treatment
Within-Sample
Variation
Biostatistics I: 2017-18
78
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Multisample inference:
Analysis of Variance
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
1
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Learni ng Obj ecti ves
1.
2.
3.
4.
Describe Analysis of Variance
(ANOVA)
Explain the Rationale of ANOVA
Compare Experimental Designs
Test the Equality of 2 or More Means
a. Completely Randomized Design
b. Randomized Block Design
c. Factorial Design
5.
Use of Computer Program
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
2
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Anal ysi s of Vari ance
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
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
3
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Anal ysi s of Vari ance
The ANOVA table was previously
discussed in the context of regression
models with quantitative independent
variables, in this chapter the focus will
be on nominal independent variables
(factors)
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
4
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Anal ysi s of Vari ance
A factor refers to a categorical
quantity under examination in an
experiment as a possible cause of
variation in the response variable.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
5
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Anal ysi s of Vari ance
Levels refer to the categories,
measurements, or strata of a factor
of interest in the experiment.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
6
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Types of Experi mental Desi gns
Experimental
Designs
Completely
Randomized
Randomized
Block
One-Way
Anova
10/27/2017
awilopo@yahoo.com
Factorial
Two-Way
Anova
Biostatistics I: 2017-18
7
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Compl etel y Randomi zed
Desi gn
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
8
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Compl etel y Randomi zed Desi gn
1.
Experimental Units (Subjects) Are
Assigned Randomly to Treatments
2.
One Factor or Independent Variable
3.
Subjects are Assumed Homogeneous
2 or More Treatment Levels or groups
Analyzed by One-Way ANOVA
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
9
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
1.
Tests the Equality of 2 or More (p)
Population Means
2.
Variables
10/27/2017
awilopo@yahoo.com
One Nominal Independent Variable
One Continuous Dependent Variable
Biostatistics I: 2017-18
10
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
Assumpti ons
1.
Randomness & Independence of
Errors
2.
Normality
•
3.
Populations (for each condition) are
Normally Distributed
Homogeneity of Variance
•
10/27/2017
awilopo@yahoo.com
Populations (for each condition) have
Equal Variances
Biostatistics I: 2017-18
11
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Hypotheses
H0: 1 = 2 = 3 = ... = p
All Population Means
are Equal
No Treatment Effect
Ha: Not All j Are Equal
At Least 1 Pop. Mean
is Different
Treatment Effect
1 2 ... p
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
12
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Hypotheses
H0: 1 = 2 = 3 = ... = p
All Population Means
are Equal
No Treatment Effect
f(X)
1 = 2 = 3
Ha: Not All j Are Equal
At Least 1 Pop. Mean is
Different
Treatment Effect
1 = 2 = ... = p
Or i ≠ j for some i, j.
10/27/2017
awilopo@yahoo.com
X
f(X)
Biostatistics I: 2017-18
1 = 2 3
X
13
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Basi c Idea
1.
Compares 2 Types of Variation to Test
Equality of Means
2.
If Treatment Variation Is Significantly
Greater Than Random Variation then
Means Are Not Equal
3.
Variation Measures Are Obtained by
‘Partitioning’ Total Variation
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
14
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
15
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
16
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
17
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
10/27/2017
awilopo@yahoo.com
Variation due to
random sampling
Biostatistics I: 2017-18
18
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
Variation due to
random sampling
Sum of Squares Among
Sum of Squares Between
Sum of Squares
Treatment
Among Groups Variation
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
19
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Parti ti ons Total Vari ati on
Total variation
Variation due to
treatment
Variation due to
random sampling
Sum of Squares Among
Sum of Squares Between
Sum of Squares
Treatment (SST)
Among Groups Variation
10/27/2017
awilopo@yahoo.com
Sum of Squares Within
Sum of Squares Error
(SSE)
Within Groups Variation
Biostatistics I: 2017-18
20
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Total Vari ati on
SS Total Y11 Y Y21 Y Yij Y
2
2
2
Response, Y
Y
Group 1
10/27/2017
awilopo@yahoo.com
Group 2
Biostatistics I: 2017-18
Group 3
21
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Treatment Vari ati on
SST n1 Y1 Y n2 Y2 Y n p Y p Y
2
2
2
Response, Y
Y3
Y
Y1
Group 1
10/27/2017
awilopo@yahoo.com
Y2
Group 2
Biostatistics I: 2017-18
Group 3
22
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Random (Error) Vari ati on
SSE Y11 Y1 Y21 Y1 Y pj Y p
2
2
2
Response, Y
Y3
Y1
Group 1
10/27/2017
awilopo@yahoo.com
Y2
Group 2
Biostatistics I: 2017-18
Group 3
23
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
Test Stati sti c
1.
Test Statistic
F = MST / MSE
STT / p 1
SSE / n p
• MST Is Mean Square for Treatment
• MSE Is Mean Square for Error
2.
Degrees of Freedom
1 = p -1
2 = n - p
• p = # Populations, Groups, or Levels
• n = Total Sample Size
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
24
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA
Summary Tabl e
Source of Degrees Sum of
Variation
of
Squares
Freedom
Mean
Square
(Variance)
Treatment
p-1
SST
MST =
MST
SST/(p - 1) MSE
Error
n-p
SSE
MSE =
SSE/(n - p)
Total
n-1
SS(Total) =
SST+SSE
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
F
25
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Cri ti cal
Val ue
If means are equal,
F = MST / MSE 1.
Only reject large F!
Reject H0
Do Not
Reject H0
0
Fa ( p1, n p)
F
Always One-Tail!
© 1984-1994 T/Maker Co.
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
26
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test Exampl e
Food1 Food2 Food3
As a vet epidemiologist
25.40 23.40 20.00
you want to see if 3 food
26.31 21.80 22.20
supplements have
different mean milk yields. 24.10 23.50 19.75
You assign 15 cows, 5 per 23.74 22.75 20.60
25.10 21.60 20.40
food supplement.
Question: At the .05 level,
is there a difference in
mean yields?
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
27
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
One-Way ANOVA F-Test
Sol uti on
H0: 1 = 2 = 3
Ha: Not All Equal
= .05
1 = 2 2 = 12
Critical Value(s):
= .05
0
10/27/2017
awilopo@yahoo.com
3.89
F
Test Statistic:
F
MST
MSE
23.5820
.9211
25.6
Decision:
Reject at = .05
Conclusion:
There Is Evidence Pop.
Means Are Different
Biostatistics I: 2017-18
28
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Summary Tabl e
Sol uti on
Source of Degrees of Sum of
Variation Freedom Squares
Food
3-1=2
47.1640
Error
15 - 3 = 12 11.0532
Total
15 - 1 = 14 58.2172
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
Mean
Square
(Variance)
F
23.5820
25.60
.9211
29
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS CODES FOR ANOVA
Data Anova;
input group$ milk @@;
cards;
food1 25.40
food2 23.40
food1 26.31
food2 21.80
food1 24.10
food2 23.50
food1 23.74
food2 22.75
food1 25.10
food2 21.60
;
run;
food3 20.00
food3 22.20
food3 19.75
food3 20.60
food3 20.40
proc anova; /* or PROC GLM */
class group;
model milk=group;
run;
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
30
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
OUTPUT - ANOVA
Source
DF
Model
2
Error
12
Corrected Total
10/27/2017
awilopo@yahoo.com
Sum of
Squares
Mean Square
F Value
Pr > F
47.16400000
23.58200000
25.60
F
0.0030
resp Mean
43350.00
Source
10/27/2017
F Value
F Value
Pr > F
11.99 0.0006
1.90 0.1759
51
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS OUTPUT - LSD
Means with the same letter are not significantly
different.
t Grouping
10/27/2017
awilopo@yahoo.com
Mean
N
trt
A
50200
5
C:
B
B
C B
C
C
44800
5
D:
41000
5
A:
37400
5
B:
Biostatistics I: 2017-18
52
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS OUTPUT - Bonferroni
Means with the same letter are not significantly
different.
Bon Grouping
A
A
B A
B
B C
C
C
10/27/2017
awilopo@yahoo.com
Mean
N
trt
50200
5
C:
44800
5
D:
41000
5
A:
37400
5
B:
Biostatistics I: 2017-18
53
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Factori al Experi ments
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
54
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Factori al Desi gn
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.
10/27/2017
awilopo@yahoo.com
Analyzed by Two-Way ANOVA
Biostatistics I: 2017-18
55
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Advantages
of Factori al Desi gns
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
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
56
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
1.
Tests the Equality of 2 or More
Population Means When Several
Independent Variables Are Used
2.
Same Results as Separate One-Way
ANOVA on Each Variable
-
10/27/2017
awilopo@yahoo.com
But Interaction Can Be Tested
Biostatistics I: 2017-18
57
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA Assumpti ons
1.
Normality
• Populations are Normally Distributed
2.
Homogeneity of Variance
• Populations have Equal Variances
3.
Independence of Errors
• Independent Random Samples are Drawn
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
58
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Data Tabl e
Factor
A
1
Y111
1
Y112
Y211
2
Y212
:
:
Ya11
a
Ya12
10/27/2017
awilopo@yahoo.com
Factor B
2
...
Y121 ...
Y122 ...
Y221 ...
Y222 ...
:
:
Ya21 ...
Ya22 ...
b
Y1b1
Y1b2
Y2b1
YX
2b2
:
Yab1
Yab2
Biostatistics I: 2017-18
Observation k
Yijk
Level i
Factor
A
Level j
Factor
B
59
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Nul l Hypotheses
1. No Difference in Means Due to
Factor A
H0: 1. = 2. =... = a.
2. No Difference in Means Due to
Factor B
3.
H0: .1 = .2 =... = .b
No Interaction of Factors A & B
10/27/2017
awilopo@yahoo.com
H0: ABij = 0
Biostatistics I: 2017-18
60
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Total Vari ati on Parti ti oni ng
Total Variation
SS(Total)
Variation Due to
Treatment A
Variation Due to
Treatment B
SSA
SSB
Variation Due to
Interaction
Variation Due to
Random Sampling
SS(AB)
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
SSE
61
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA
Summary Tabl e
Source of Degrees of Sum of
Variation
Freedom Squares
Mean
Square
F
A
(Row)
a-1
SS(A)
MS(A)
MS(A)
MSE
B
(Column)
b-1
SS(B)
MS(B)
MS(B)
MSE
AB
(a-1)(b-1)
(Interaction)
Error
Total
10/27/2017
awilopo@yahoo.com
n - ab
SS(AB)
SSE
MS(AB) MS(AB)
MSE
MSE
Same as
n-1
SS(Total)
Other
Biostatistics I: 2017-18
62
Designs
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Interacti on
1. Occurs When Effects of One Factor
Vary According to Levels of Other
Factor
2. When Significant, Interpretation of
Main Effects (A & B) Is Complicated
3.
Can Be Detected
10/27/2017
awilopo@yahoo.com
In Data Table, Pattern of Cell Means in One
Row Differs From Another Row
In Graph of Cell Means, Lines Cross
Biostatistics I: 2017-18
63
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Graphs of Interacti on
Effects of Gender (male or female) & dietary
group (sv, lv, nor) on systolic blood pressure
Interaction
Average
Response
No Interaction
male
Average
Response
male
female
sv
10/27/2017
awilopo@yahoo.com
lv
nor
Biostatistics I: 2017-18
female
sv
lv
nor
64
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Two-Way ANOVA F-Test Exampl e
Effect of diet (sv-strict vegetarians, lvlactovegetarians, nor-normal) and gender
(female, male) on systolic blood pressure.
Question: Test for interaction and main effects
at the .05 level.
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
65
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS CODES FOR ANOVA
data factorial;
input dietary$ sex$
sbp;
cards;
sv male 109.9
sv male 101.9
sv male 100.9
sv male 119.9
sv male 104.9
sv male 189.9
sv female 102.6
sv female 99
sv female 83 .6
sv female 99.6
sv female 102.6
sv female 112.6
10/27/2017
awilopo@yahoo.com
lv male 116.5
lv male 118.5
lv male 119.5
lv male 110.5
lv male 115.5
lv male 105.2
nor male 128.3
nor male 129.3
nor male 126.3
nor male 127.3
nor male 126.3
nor male 125.3
nor female 119.1
nor female 119.2
nor female 115.6
nor female 119.9
nor female 119.8
nor female 119.7
;
run;
Biostatistics I: 2017-18
66
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS CODES FOR ANOVA
proc glm;
class dietary sex;
model sbp=dietary sex dietary*sex;
run;
proc glm;
class dietary sex;
model sbp=dietary sex;
run;
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
67
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS OUTPUT - ANOVA
Dependent Variable: sbp
Sum of
Source
DF
Squares Mean Square F Value Pr > F
Model
5 2627.399667
525.479933
1.96 0.1215
Error
24 6435.215000
268.133958
Corrected Total
29 9062.614667
R-Square
0.289916
Coeff Var
14.08140
Root MSE
16.37480
sbp Mean
116.2867
Source
dietary
sex
dietary*sex
DF
Type I SS Mean Square F Value Pr > F
2
958.870500
479.435250
1.79 0.1889
1 1400.686992 1400.686992
5.22 0.0314
2
267.842175
133.921087
0.50 0.6130
Source
dietary
sex
dietary*sex
DF Type III SS Mean Square F Value Pr > F
2 1039.020874
519.510437
1.94 0.1659
1 877.982292
877.982292
3.27 0.0829
2
267.842175
133.921087
0.50 0.6130
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
68
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Li near Contrast
Linear Contrast is a linear combination of the
means of populations
Purpose: to test relationship among different
group means
L cj j
with
c
j
0
Example: 4 populations on treatments T1, T2, T3 and T4.
Contrast T1
T2
T3
T4
relation to test
L1
L2
10/27/2017
awilopo@yahoo.com
1
1
0
-1/2
-1
-1/2
0
0
Biostatistics I: 2017-18
μ1 - μ 3 = 0
μ1 – μ2/2 – μ3/2 = 0
69
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
T-test for Li near Contrast (LSD)
Construct a t statistic involving k group
means. Degrees of freedom of t - test: df = n-
k.
k
To test H0:
L c j j 0 Construct
t
j 1
L
k
c 2j
j 1
nj
s2
Compare with critical value t1-α/2,, n-k.
Reject H0 if |t| ≥ t1-α/2,, n-k.
SAS uses contrast statement and performs an F – test df (1, n-k);
Or estimate statement and perform a t-test df (n-k).
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
70
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
T-test for Li near Contrast (Scheffe)
Construct multiple contrasts involving k
group means. Trying to search for
significant contrast
k
To test H0:
L c j j 0 Construct
j 1
Compare with critical value.
t
L
k
c 2j
j 1
nj
s2
a (k 1) Fk 1,n k ,1
Reject H0 if |t| ≥ a
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
71
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
SAS Code for contrast testi ng
proc glm;
class trt block;
model resp=trt block;
Means trt /lsd bon scheffe;
contrast 'A - B = 0' trt 1 -1 0 0 ;
contrast 'A - B/2 - C/2 = 0' trt 1 -.5 -.5 0 ;
contrast 'A - B/3 - C/3 -D/3 = 0' trt 3 -1 -1 -1 ;
contrast 'A + B - C - D = 0' trt 1 1 -1 -1 ;
lsmeans trt/stderr pdiff;
lsmeans trt/stderr pdiff adjust=scheffe; /* Scheffe's test */
lsmeans trt/stderr pdiff adjust=bon;
/* Boneferoni's test
*/
estimate ‘A - B' trt 1 -1 0 0 0;
run;
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
72
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Regressi on representati on of Anova
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
73
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Regressi on representati on of Anova
yij i eij i eij
One-way anova:
p
0
i1
i
Two-way anova:
yijk ij eijk i j ij eijk
a
i 1
b
i
0, j 0,
j 1
b
j 1
ij
0 for all i and
a
i 1
ij
0 for all j
SAS uses a different constraint
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
74
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Regressi on representati on of Anova
One-way anova: Dummy variables of
factor with p levels
y 0 1 x1 2 x2 ... p1 x p1 e
1
where xi
0
if level i
if otherwise
This is the parameterization used by SAS
10/27/2017
awilopo@yahoo.com
Biostatistics I: 2017-18
75
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health
Concl usi on: shoul d be abl e to
1. Recognize the applications that uses
ANOVA
2. Understand the logic of analysis of
variance.
3. Be aware of several different analysis of
variance designs and understand when to use
each one.
4. Perform a single factor hypothesis test
using analysis of variance manually and with
the aid of SAS or any statistical software.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
76
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Concl usi on: shoul d be abl e to
5. Conduct and interpret post-analysis of
variance pairwise comparisons
procedures.
6. Recognize when randomized block
analysis of variance is useful and be able to
perform the randomized block analysis.
7. Perform two factor analysis of variance
tests with replications using SAS and
interpret the output.
10/27/2017
sawilopo@yahoo.com
Biostatistics I: 2017-18
77
Universitas Gadjah Mada, Faculty of Medicine, Department of Public Health
Key Terms
Between-Sample
Variation
Completely
Randomized
Design
Experiment-Wide
Error Rate
Factor
10/27/2017
awilopo@yahoo.com
Levels
One-Way Analysis
of Variance
Total Variation
Treatment
Within-Sample
Variation
Biostatistics I: 2017-18
78
Universitas Gadjah Mada, Faculty of Medicine, Dept. Biostat. Epi. and Pop. Health