One Way ANOVA Repeated Measures 花蓮慈濟醫院 葉日弌
One Way ANOVA Repeated Measures
花蓮慈濟醫院
葉日弌
每個個體都接受多種處理或多次測量的實驗設計
比較兩組樣本之平均數
1.獨立樣本(Independent samples): t-test.
2.相關樣本(Dependent/Related samples): paired t-test.
兩組獨立與相關樣本之檢定
•兩組樣本之 t-test oPaired t-test
oIndependent samples
•Equal variance
•Unequal variance
獨立與相關樣本
兩個不同的醫師針對10個腫瘤分別利用相同的工具測量其體積,結果如下表所示
腫瘤 A醫師 B醫師
1 17.2 15.8
2 22.3 20.3
3 14.5 14.2
4 18.5 15.7
5 28.0 26.8
6 24.8 24.0
7 21.8 20.3
8 25.4 23.0
9 29.3 27.5
10 20.5 19.7
配對(非獨立)樣本 腫瘤 A醫師 B醫師 差異
1 17.2 15.8 1.4
2 22.3 20.3 2.0
3 14.5 14.2 0.3
4 18.5 15.7 2.8
5 28.0 26.8 1.2
6 24.8 24.0 0.8
7 21.8 20.3 1.5
8 25.4 23.0 2.4
9 29.3 27.5 1.8
10 20.5 19.7 0.8
t-test for the differences
General definition of t-statistic
Standard deviation of the paired differences
Standard error of the differences (n=sample size)
t-statistic for differences where δ is the null hypothesis
t-statistic for the null hypothesis that δ = 0
差異 • A醫師之結果
o Population mean:
o Sample mean: 22.23
• B醫師之結果 o Population mean:
o Sample mean: 20.73
• 差之標準差 6.61 • 差異
o Population mean:
o Sample mean:
1x
2x
n
d
d
n
i
i 1
21
2
1
差異之分布 • 假設di 是常態分布, 以下統計量是自由度為n-1的 t-distribution
• 標準差
ns
dt
d
1
1
2
n
dd
s
n
i
i
d
t-test 1) Null hypothesis:
1) 獨立樣本; alpha=0.05
2) p = 0.48, df = 18
0:0 drBdrAdrBdrAH
72.0
1061.6
5.1
21
21
ns
xxt
xx
Confidence interval • 計算方式和one-sample t-test一樣
• 結果為 (-2.9, 5.9)
n
std
n
std da
da 2/12/1 ,
Non-paired vs. paired
The paired t test
15
paired t-test 使用時機 1. 同一個體接受多次測量.
2. 表現隨著時間增強或減弱.
3. 配對比較
16
Before-After
前測 後測 T
reat
ment
17
Matched Subject Design 根據已知影響結果的因子將受試配對分組比較,如
1. 年齡
2. 性別
3. 用藥記錄
4. 是否吸煙
5. 其他共病
Paired t-test
• 個體在接受處置前後均接受測量
• 依據個體前後測的差值而非組平均的差值做比較
Paired t-test 1) Null hypothesis:
1) 非獨立樣本; alpha=0.05
2) p = 0.00016
0:0 drBdrAdrBdrAH
16.61077.0
5.1
ns
dt
d
Analysis of variance
(ANOVA)
Analysis of Variance
比較三組以上樣本之平均數
1. 獨立樣本 : Analysis of Variance (ANOVA)
2. 相關樣本: Repeated Measures ANOVA
一因子變異數分析
一因子變異數分析
母體參數的推估
母體參數的推估
withinbetweentotal SSSSSS
• dfbetween=k-1; k=# of treatment (level)
• dfwithin =N-k; N=total sample size
• dftotal =N-1
withinbetweentotal dfdfdf
一般情形之完全隨機化設計的ANOVA表
F = MSbetween / MSwithin
= (SSbetween/dfbetween)/(SSwithin/dfwithin)
=MSB/MSE
完全隨機化設計的F檢定
reject H0
KH 210 :
),1( knkFMSE
MSBF
Repeated measures
ANOVA
comprehensive
double blind
study
ANOVA approach: different subjects in the treatment groups
Null hypothesis: the 4 group means are equal
F-distribution
Sums of squares are additive
F-statistic is used to determine significance
SSt are the squared differences of the treatment means from the mean of all the treatments
MSt = SSt / (number of groups-1)
MSwithin or s2
wit
Squared differences of individuals from their group’s mean divided by the number of people in the group minus 1
全部變異TSS
dftotal= mn-1
組間變異BSS
dfbetween subject = n-1
組內變異WSS
dfwithin = n(m-1)
隨機變異
個體間差異之變異
dftreatment = m-1 隨機化之殘差變異
dfresidual = (n-1)(m-1)
o group means:
• diet 1 = 4.96
• diet 2 = 5.23
• diet 3 = 4.93
• diet 4 = 4.8
o Grand mean:
= 1/4 ( + + + )= 4.98
= 4.45
1x
2x
3x
4x
2x 4x3x1xx
1.x
• SS total (df = 27) = (4.6-4.98)^2+….+ (5.6-4.98)^2 = 4.50
• SS between subjects (df = 6) = (4. 6454.98)^2 …..+ (5.55-4.98)^2 +…= 3.49
• SS between treatments (df = 3) =
7*(4.96-4.98)^2 +……..+7*(5.55-4.98)^2 = 0.681
• SS residual (df = 18) = SS total - SS between subjects - SS between treatments = 0.681-0.3 = 0.338
• F = MSE between treatments / MSE residual
= (SS between treatments /df between treatments ) /
(SS residual /df residual)
Repeated Measures Designs
• 優點
• 以自身當對照組,減少變異 • 檢定力較高
• 缺點 • 可能有前次處理殘存的效果(carryover effect) • 重複測量會有練習效果 • 有的狀況無法重複
Post hoc testing
• F 值達到顯著水準
o 至少有一組平均值和其他組不同
• 到底是哪一組?
• 使用事後檢定 (Post hoc tests)
o Bonferroni
o Tukey
Sphericity檢定
• Mauchly’s Test
• 若 p > .05 接受變異數相等
• 若 p < .05 採取以下措施
• 使用校正因子例如Greenhouse-Geisser • 或者使用不同的自由度(比較保守)
Post Hoc Analysis • 如果拒絕H0 就不用作了…
對應的無母數方法
Marijuana during pregnancy and behavioral characteristics at age 10
Kruskal-Wallis Statistic
Rank observations without regard to treatment group
P < 0.05
Chi-square calculation
The Friedman test
Friedman chi-square statistic
Repeated Measures ANOVA in Stata
person drug score
1 1 30
1 2 28
1 3 16
1 4 34
2 1 14
2 2 18
2 3 10
2 4 22
3 1 24
3 2 20
3 3 18
3 4 30
4 1 38
4 2 34
4 3 20
4 4 44
5 1 26
5 2 28
5 3 14
5 4 30
Repeated Measures ANOVA in SPSS
Data
Run repeated measures
Descriptive statistics
Mauchly’s test of Sphericity
Result of F test
Confidence interval of the means
Post Hoc
Plot
The End