chapter 8 실험계획및분산분석 - seoul national...

45
2017/5/01 Chapter 8 실험계획 및 분산분석 (Experimental Design & ANalysis Of VAariance, ANOVA)

Upload: others

Post on 19-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

2017/5/01

Chapter 8 실험계획 및 분산분석(Experimental Design &

ANalysis Of VAariance, ANOVA)

Page 2: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

선형모형 (linear model): 설명변수들의 선형의 선형결합의 형태로 반응변수를 설명하고자 함.

(to explain the response variable by the linear combinations of the explanatory variables)

분산분석 (analysis of variance):전체변동을 몇 개의 성분으로 분할하는 기법 (Divide total variation into several components)전체변동에 대해 각각의 변동요인의 기여 규모를 파악 (contribution of particular components)

목적 (Aims):모분산의 추정과 가설 검정 (estimation & testing for the variances)모평균의 추정과 가설검정 (estimation & testing for

the means)

8.1 선형모형과 분산분석(Linear Model & Analysis of Variance)

Page 3: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

* motivation

비교하고 싶은 그룹이 두 개이면 (comparisons of two groups) -> t-test

비교하고 싶은 그룹이 두 개 이상이면 (more than two groups) -> 두 개 그룹씩 뽑아서 쌍을 만든 후에여러 개의 t-test를 실시한다. (pairwise t-tests)

번거롭기도 하고 이론적으로 틀린 결론에 도달할 수있다. (cumbersome & theoretically wrong -> 다중비교의 문제 (multiple-comparisons problems)

전체 자료를 사용하지 않고 자료의 부분 만을 사용하므로 효율이 떨어진다. (efficiency problems due to the usage of partial data)

전체 자료를 이용하여서 세 그룹이상을 비교하는 분석(more than 3 groups using whole data) -> 분산 분석 ANOVA (종속변수는 연속형, 독립변수는 이산형) response var: conti, explanatory var: categorical

Page 4: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

<Ex 8.1.1> 혈청 콜레스테롤을 낮추는 세 가지 약 A, B, C를 비교. 실험에 참여한 사람들에게 A, B, C 중 하나를처방한 뒤에, 혈청 콜레스테롤이 줄어들었는지 측정. 처방받은 약에 따라 그룹을 나눴을 때, 각 그룹별 표본평균에 변동과 각 그룹 내의 관측값의 변동을 생각. 이때전자는 그룹 간 변동(between group variation), 후자는그룹 내 변동(within group variation). 그룹 간 변동은처방 약의 효과, 그룹 내 변동은 식습관의 차이, 유전적차이 등 다양한 이유로 인하여 발생. 따라서 그룹 간 변동이 그룹 내 변동에 비하여 상대적으로 작으면, 약의효과는 동일하다고 결론.

Response variable: reduction of cholesterol level

Explanatory variable: drugs A, B, C

Within group variation: due to other factors like genetic or nutrition, etc…

Between group variation: drug effect

Page 5: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

Chole

ster

ol

level

Chole

ster

ol

level

A B C

Treatments

between group variation

wit

hin

gro

up v

aria

tion

Between group variation: small

Within group variation: large

A B C

Page 6: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

8.2 일원배치 분산분석 (One-way ANOVA)

[완전 확률화 계획법] : (complete randomization)

(treatments)

(total)

(average)

처리변수 (treatment)

𝟏 𝟐 𝟑 ⋯ 𝒌

𝑥11 𝑥12 𝑥13 ⋯ 𝑥1𝑘

𝑥21 𝑥22 𝑥23 ⋯ 𝑥2𝑘

𝑥31 𝑥32 𝑥33 ⋯ 𝑥3𝑘

⋮ ⋮ ⋮ ⋮ ⋮

𝑥𝑛11 𝑥𝑛22 𝑥𝑛33 ⋯ 𝑥𝑛𝑘𝑘

합 (total) 𝑇.1 𝑇.2 𝑇.3 ⋯ 𝑇.𝑘 𝑇..

평균(average) 𝑥.1 𝑥.2 𝑥.3 ⋯ 𝑥.𝑘 𝑥..

Page 7: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

모형 (model)

1

:

ij j ijij

j ij

k

jj

k

j j

x

효과

번째측정치 j처리의 평균 ij번째 오차

: 전체평균

j번째 처리

ij-th observation mean of j-th treatment group error of ij-th observation

Grand mean

Effect of j-th treatment group

Page 8: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

𝑥𝑖𝑗 = 𝜇𝑗 + 𝜀𝑖𝑗 = 𝜇 + 𝜏𝑗 + 𝜀𝑖𝑗

(treatments)

처리변수 (treatment)

𝟏 𝟐 𝟑 ⋯ 𝒌

𝑥11 𝑥12 𝑥13 ⋯ 𝑥1𝑘

𝑥21 𝑥22 𝑥23 ⋯ 𝑥2𝑘

𝑥31 𝑥32 𝑥33 ⋯ 𝑥3𝑘

⋮ ⋮ ⋮ ⋮ ⋮

𝑥𝑛11 𝑥𝑛22 𝑥𝑛33 ⋯ 𝑥𝑛𝑘𝑘

합 (total) 𝑇.1 𝑇.2 𝑇.3 ⋯ 𝑇.𝑘 𝑇..

평균(average) 𝑥.1 𝑥.2 𝑥.3 ⋯ 𝑥.𝑘 𝑥..

pop mean 𝜇1 𝜇2 𝜇3 … 𝜇𝑘 𝜇

effect 𝜏1= 𝜇1 − 𝜇 …… 𝜏𝑘= 𝜇𝑘 − 𝜇

Page 9: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

모형의 가정 (Assumptions of the model)(a) 독립 확률표본 (independent random sample)(b) 𝑥𝑖,𝑗~𝑁(𝜇𝑗 , 𝜎𝑗

2), 𝑖 = 1,2,… , 𝑛𝑗 ∗ 𝑘번째 -> 𝑗번째

(c) 𝜎12 = 𝜎2

2 = ⋯ = 𝜎𝑘2 = 𝜎2

(d) 𝜇𝑗의 평균은 𝜇. 따라서 𝜏𝑗 = 𝜇𝑗 − 𝜇이라고 하면, 𝜏𝑗 = 0

(e) 𝑥𝑖𝑗의 평균은 𝜇𝑗이고 𝜀𝑖𝑗의 평균은 0이다.

(f) 𝜀𝑖𝑗와 𝑥𝑖𝑗의 차이는 상수, 𝜀𝑖𝑗의 분산은 𝑥𝑖𝑗의 분산과 동일. 따

라서 오차항의 분산은 𝜎2이다.

(g) 𝜀𝑖𝑗는 독립이며 정규분포를 따른다. (indep. & normally dist)

=> 𝑥𝑖𝑗 = 𝜇𝑗 + 𝜀𝑖𝑗 = 𝜇 + 𝜏𝑗 + 𝜀𝑖𝑗 , 𝜀𝑖𝑗~𝑁(0, 𝜎2) independent

Page 10: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

모형의 가설 (Hypothesis of the model)

𝐻0 ∶ 𝜇1 = 𝜇2 = ⋯ = 𝜇𝑘 vs 𝐻𝐴 ∶적어도 하나 이상의 𝜇𝑗는 다르다.

만약 영가설이 사실이면(즉, 모평균이 서로 같다면) 처리효과는모두 0이므로 영가설과 대립가설은 다음과 같이 표현.

𝐻0 ∶ 𝜏𝑗 = 0, 𝑗 = 1,2,⋯ , 𝑘 vs 𝐻𝐴 ∶적어도 하나 이상의 𝜏𝑗은 0이

아니다. (More than one 𝜏𝑗’s are not equal to 0.)

등분산과 정규성의 가정이 만족되나 영가설이 사실이 아닌 경우 모집단의 분포영가설이 사실이고 가정이 만족될 때,

모집단의 분포

Under 𝐻0with normal and homogeneityassumptions

Under 𝐻𝐴 with normal and homogeneity assumptions

Page 11: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

2

..

1 1

2

. . ..

1 1

2 2

. . . .. . ..

1 1 1 1 1 1

2 2

. . ..

1 1 1

( )

( )

( ) 2 ( )( ) ( )

( ) ( )

j

j

j j j

j

nk

ij

j i

nk

ij j j

j i

n n nk k k

ij j ij j j j

j i j i j i

nk k

ij j j j

j i j

SST x x

x x x x

x x x x x x x x

x x n x x

총제곱합 (sum of squares, total)

Within-group SS Among(Between)-group SS

Page 12: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

within among groupSST SSW SSA

그룹 제곱 그룹 제곱내 합 간 합

MSAvariance ratio=

MSW

그룹 제곱

그룹 제곱

간 평균분산비 =

내 평균

->분산비가 커지면 그룹간의 variation이 크다.그룹간의 성질이 다르다. 그룹의 효과가 크다.

Within-group SS Among(Between)-group SS

->larger VR -> larger between-group SS 0 ->groups are different -> bigger group effect !

Page 13: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

𝝈𝟐의 불편추정량

2

1 1

1

( )

( 1)

jk n

ij jj i

k

jj

x xMSW

n

Page 14: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

ANOVA Table

factor

Within

group

Between

group

total

Sum of squares Mean square Variance ratio

요인 제곱합 자유도 평균제곱합 F

집단 간 제곱합𝑆𝑆𝐴 =

𝑗=1

𝑘

𝑛𝑗 𝑥.𝑗 − 𝑥..2

𝑘 − 1 𝑀𝑆𝐴 = 𝑆𝑆𝐴/(𝑘 − 1)𝑀𝑆𝐴

𝑀𝑆𝑊

집단 내 제곱합𝑆𝑆𝑊 =

𝑗=1

𝑘

𝑖=1

𝑛𝑗

𝑥𝑖𝑗 − 𝑥.𝑗2

𝑁 − 𝑘 𝑀𝑆𝑊= 𝑆𝑆𝑊/(𝑁 − 𝑘)

총 제곱합𝑆𝑆𝑇 =

𝑗=1

𝑘

𝑖=1

𝑛𝑗

𝑥𝑖𝑗 − 𝑥..2

𝑁 − 1

Degree of freedom

Page 15: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

<Ex 8.2.3> 소의 연령에 따른 육류의 셀레늄(selenium) 농도 비교 (Age group of cows and selenium concentration of milk)

(1) 데이터

【표 8.2.3】 연령에 따른 셀레늄 함유량(mg=100g)

나이 그룹

A B C D

1820 1483 191 724 1020 1652 775 752

2588 1723 1098 613 805 1309 1393 804

2670 727 644 918 631 1002 533 1182

1022 1463 136 949 641 966 734 1243

1555 1777 1605 877 760 788 485 985

222 1129 1247 1368 1085 472 449 1295

1197 1529 1692 775 471 236 1676

1249 1422 697 1307 771 831 754

1520 445 849 344 869 698 937

489 990 1199 961 513 167 1022

2575 489 429 239 731 824 1073

1426 2408 798 944 1130 448 948

1846 1064 631 1096 1034 991 222

1088 629 1016 1261 590 721

912 1025 42 994 375

Page 16: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간
Page 17: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

Critical value = 3.95, alpha=0.01

> qf(0.99,3,109)[1] 3.966509

> 1-pf(9.353,3,109)[1] 1.48582e-05>

요인 제곱합 자유도 평균제곱합 F집단 간 제곱 5918736.75 3 1972912.25 9.33집단 내 제곱합 23038971.22 109 211366.71총 제곱합 28957707.96 112

Page 18: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

SAS program data cele;

input value group $ @@;

cards;

1820 A 1483 A 2588 A 1723 A 2670 A 727 A

1022 A 1463 A 1555 A 1777 A 222 A 1129 A

1197 A 1249 A 1520 A 489 A 2575 A 1426 A

1846 A 1088 A 912 A 1383 A 191 B 1098 B 644 B

136 B 1605 B 1247 B 1529 B 1422 B 445 B 990 B

489 B 2408 B 1064 B 629 B 724 C 1020 C 613 C

805 C 918 C 631 C 949 C 641 C 877 B 760 C

1368 C 1085 C 1692 C 775 C 697 C 1307 C

849 C 344 C 1199 C 961 C 429 C 239 C 798 C

944 C 631 C 1096 C 1016 C 1025 C 948 C

1652 D 775 D 752 D

1309 D 1393 D 804 D

1002 D 533 D 1182 D

966 D 734 D 1243 D

788 D 485 D 985 D

472 D 449 D 1295 D

471 D 236 D 1676 D

771 D 831 D 754 D

869 D 698 D 937 D

513 D 167 D 1022 D

731 D 824 D 1073 D

1130 D 448 D 948 D

1034 D 991 D 222 D

1261 D 590 D 721 D

42 D 994 D 375 D

767 D 1781 D 1187 D

;

proc anova data=cele;

class group;

model value=group;

means group/tukey;

* means group/bon;

run;

Page 19: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간
Page 20: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

* Multiple Comparisons (다중비교)

ex) significance level = for a test

In general, if we want to test ,then

overall is 0.1855, not 0.05 -> inflated type I error !!

01 1 01 01

02 2 02 02

0 0 0 01 02

01

: 0 ( ) 1

: 0 ( ) 1

( ) where and

(

Let H p do not reject H H is true

H p do not reject H H is true

then p do not reject H H H H H

p do not reject H and do not reje

02 0

2

)

(1- ) (1- ) (1- )

ct H H

1 2 3 0k

4

(1 ) (1 )

1 0.1855 0.8145 ( .95) .95

k

Page 21: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

* Bonferroni Correction : Set individual significance

the overall significance level is about for m multiple tests.

m=4

example) When we have 10 hypotheses,

Individual p=0.05 -> multiple comparisons problem

(too many false findings)

Individual p=

This is often called “Bonferroni corrected p-value”.

m

40.05

1 0.95 1 0.054

0.050.005

10

Page 22: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

[처리그룹 쌍별 두 모평균 차이의 검정] Detecting pairwise differences

After rejecting , which pairs have larger differences?

1. LSD (least significant difference, 최소 유의차 검정법)2. Duncan’s new multiple range test

Duncan의 새로운 다중범위 검정법

3. Tukey’s HSD

0 1 2 5:H

Liberal Conservative

DuncanLSD

SNK Tukey HSD

Scheffe

Page 23: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

[Tukey의 HSD (honestly significance difference) 검정]

, ,

* *

, , *

's are the same

: sample size of smaller cell

k N k j

j

k N k j

j

MSEHSD q n

n

MSEHSD q n

n

=

max min, , : dist of ,

2 /

: significance level, : number of gropus, : df

k N k

y yq

S n

k N k

[Bonferroni 방법] 계산된 p-value에 가능한 모든 방법의 수𝑘2

를 곱함. Bonferroni corrected p-value: multiply # of all possible

methods 𝑘2

to the p-value

Page 24: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

A B C D

A - 463.43 574.65 596.63

B - 111.22 133.20

C - 21.99

D -

데이터의 각 처리그룹별 표본평균의 차이Differences of means between pair of groups

𝛼=0.05. 𝑘 = 4, 𝑁 − 𝑘 = 109> qtukey(0.05, nmeans= 4, df=109, lower=F)= 3.689,

MSE= 211366.71

Page 25: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

개별 영가설 HSD* 검정결과

𝐻0: 𝜇𝐴 = 𝜇𝐵𝐻𝑆𝐷∗ = 3.689

211366.71

2

1

22+1

14= 410.0038 463.43 > 410.0038이므로

𝐻0을 기각함.

𝐻0: 𝜇𝐴 = 𝜇𝐶𝐻𝑆𝐷∗ = 3.689

211366.71

2

1

22+1

29= 339.0679 574.65 > 339.0531이므로

𝐻0을 기각함.

𝐻0: 𝜇𝐴 = 𝜇𝐷𝐻𝑆𝐷∗ = 3.689

211366.71

2

1

22+1

48= 308.7657 596.63 > 308.7522이므로

𝐻0을 기각함.

𝐻0: 𝜇𝐵 = 𝜇𝐶𝐻𝑆𝐷∗ = 3.689

211366.71

2

1

14+1

29= 390.2862 111.22 < 390.2691 이므로

𝐻0을 기각하지 못함.

𝐻0: 𝜇𝐵 = 𝜇𝐷𝐻𝑆𝐷∗ = 3.689

211366.71

2

1

14+1

48= 364.2698 113.20 < 364.2539이므로

𝐻0을 기각하지 못함.

𝐻0: 𝜇𝐶 = 𝜇𝐷𝐻𝑆𝐷∗ = 3.689

211366.71

2

1

29+1

48= 282.0575 21.99 < 282.0452이므로

𝐻0을 기각하지 못함.

Tukey의 HSD 결과

Page 26: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간
Page 27: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간
Page 28: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

8.3 완전확률화 완전 블록 계획법과 이원배치 분산분석(Randomized complete block design & Two-way ANOVA)

R.A.Fisher (1925) : to compare the yields of certain species 땅을 블록(block=land)으로 나누고 블록 안에서Randomize (other factors) in a block 하는 것이다.

처리

블록 𝟏 𝟐 𝟑 ⋯ 𝒌 합total

평균average

1 𝑥11 𝑥12 𝑥13 ⋯ 𝑥1𝑘 𝑇1. 𝑥1.

2 𝑥21 𝑥22 𝑥23 ⋯ 𝑥2𝑘 𝑇2. 𝑥2.

3 𝑥31 𝑥32 𝑥33 ⋯ 𝑥3𝑘 𝑇3. 𝑥3.

⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮

𝑛 𝑥𝑛1 𝑥𝑛2 𝑥𝑛3 ⋯ 𝑥𝑛𝑘 𝑇𝑛. 𝑥𝑛.

합 Total 𝑇.1 𝑇.2 𝑇.3 ⋯ 𝑇.𝑘 𝑇..평균

Average 𝑥.1 𝑥.2 𝑥.3 ⋯ 𝑥.𝑘 𝑥..

Page 29: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

모형𝑥𝑖𝑗 = 𝜇 + 𝛽𝑖 + 𝜏𝑗 + 𝜀𝑖𝑗

𝑖 = 1,2,⋯ , 𝑛; 𝑗 = 1,2,⋯ , 𝑘

𝑥𝑖𝑗:각 실험단위로부터 얻은 관측값 (Observation)

𝜇:미지의 상수로서 전체평균. (grand mean)

𝛽𝑖: 𝑖번째 블록의 블록효과 block effect for i-th obs

𝜏𝑗: 𝑗번째 처리의 처리효과. trt effect for j-th obs

𝜀𝑖𝑗: 그 외 효과들의 총합. random error

모형의 가정𝑎 𝑥𝑖𝑗:랜덤독립표본 (random and independent sample)

(b) 𝑥𝑖𝑗~independent𝑁 𝜇𝑖𝑗 , 𝜎2 ⇔ 𝜀𝑖𝑗~independent𝑁 0, 𝜎

2

(c) 𝑗=1𝑘 𝜏𝑗 = 𝑖=1

𝑛 𝛽𝑖 = 0

블록효과와 처리효과는 가법적이다. Block effect & trt

effect are additive.

Page 30: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

0

(hypothesis)

: 0 1,2, ,

:All 0 is not true. Some 0.

j

A j j

H j k

H

가설

2

..

1 1

2 2 2

. .. . .. . . ..

1 1 1 1 1 1

( )

( ) ( ) ( )

: 1 ( 1) ( 1) ( 1)( 1)

j

k n

ij

j i

nk n k k n

i j ij i j

j i j i j i

SST x x

x x x x x x x x

SST SSBl SSTr SSE

df nk n k n k

*

Page 31: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

ANOVA table

요인 (factor)제곱합(sum of square)

자유도(df) 평균제곱 (mean square) F

처리 (trt) 𝑆𝑆𝑇𝑟 (𝑘 − 1) 𝑀𝑆𝑇𝑟 = 𝑆𝑆𝑇𝑟/(𝑘 − 1) 𝑀𝑆𝑇𝑟 𝑀𝑆𝐸

블록 (block) 𝑆𝑆𝐵𝑙 (𝑛 − 1) 𝑀𝑆𝐵𝑙 = 𝑆𝑆𝐵𝑙/(𝑛 − 1)

잔차(residual) 𝑆𝑆𝐸 (𝑛 − 1)(𝑘 − 1) 𝑀𝑆𝐸 = 𝑆𝑆𝐸/(𝑛 − 1)(𝑘 − 1)

합 (sum) 𝑆𝑆𝑇 𝑘𝑛 − 1

Page 32: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

Ex. 8.3.1 약의 종류와 나이에 따라 치료까지 걸린 시간

Trt time by drug and age group

Age

약의 종류 (drug)

나이 그룹 (age group) A B C 합 total 평균average

< 20 11* 8 10 29 9.7

20 - 29 6 5 11 22 7.3

30 - 39 7 10 13 30 10

40 - 49 9 12 13 34 11.3

50 - 10 17 15 42 14

합 total 43 52 62 151

평균 average 8.6 10.4 12.4 10.5

Page 33: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

response<-c(11, 6, 7, 9, 10, 8, 5, 10, 12, 17, 10, 11, 13, 13, 15)

drug<-factor(c(rep('A',5),rep('B',5),rep('C',5)))

age<-factor(rep(1:5))

dat<-data.frame(response=response,drug=drug,age=age)

anova(lm(response~drug+age,data=dat))

Analysis of Variance Table

Response: response

Df Sum Sq Mean Sq F value Pr(>F)

drug 2 36.133 18.0667 3.4522 0.08300 .

age 4 71.733 17.9333 3.4268 0.06505 .

Residuals 8 41.867 5.2333

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘

Page 34: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간
Page 35: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

8.4 요인 실험과 이원배치 분산분석(Factorial Experiment and two-way ANOVA)

반응시간 (reduction of response time )= 약품수준(소량, 중간, 다량)*연령층(중년, 노년)drug level (min, med, max)*age(mid, old)

• 교호작용이 없을 때 (Without interaction)

요인B – 약품용량 (Factor-B, drug level)

요인A – 연령Factor A-age j=1 j=2 j=3

중년층(Mid) i=1 5 10 20

노년층(old) i=2 10 15 25

ageDrug dosage

ageDrug level

red

uct

ion

of

resp

on

se t

ime

Page 36: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

•교호작용이 있을 때 (With interaction)

요인B – 약품용량

요인A - 연령

j=1 j=2 j=3 j=2-1 j=3-2

중년층(i=1) 5 10 20 5 10

노년층(i=2) 15 10 5 -5 -5

Page 37: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

요인(factor) B

요인 (factor)A 1 2 ⋯ 𝑏 합 total 평균

average

1𝑥111 𝑥121 ⋯ 𝑥1𝑏1

𝑇1.. 𝑥1..⋮𝑥11𝑛

⋮𝑥12𝑛

⋮⋯

⋮𝑥1𝑏𝑛

2𝑥211 𝑥221 ⋯ 𝑥2𝑏1

𝑇2.. 𝑥2..⋮𝑥21𝑛

⋮𝑥22𝑛

⋮⋯

⋮𝑥2𝑏𝑛

⋮⋮ ⋮ ⋮ ⋮ ⋮ ⋮

𝑎𝑥𝑎11 𝑥𝑎21 ⋯ 𝑥𝑎𝑏1

𝑇𝑎.. 𝑥𝑎..⋮𝑥𝑎1𝑛

⋮𝑥𝑎2𝑛

⋮⋯

⋮𝑥𝑎𝑏𝑛

합 total𝑇.1. 𝑇.2. ⋯ 𝑇.𝑏. 𝑇...

평균average

𝑥.1. 𝑥.2. ⋯ 𝑥.𝑏. 𝑥...

Page 38: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

모형

𝑥𝑖𝑗𝑘 = 𝜇 + 𝛼𝑖 + 𝛽𝑗 + (𝛼𝛽)𝑖𝑗+𝜀𝑖𝑗𝑘,

𝑖 = 1, 2,⋯ , 𝑎; 𝑗 = 1, 2,⋯ , 𝑏; 𝑘 = 1, 2,⋯ , 𝑛

𝑥𝑖𝑗𝑘: 관측값 (observation)

𝜇: 전체 평균 (grand mean),

𝛼𝑖:요인 A의 효과 (effect of factor A),

𝛽𝑗: 요인 B의 효과 (effect of factor B),

(𝛼𝛽)𝑖𝑗: 요인 A와 요인 B의 교호작용 (interaction),

𝜀𝑖𝑗𝑘: 실험 오차 (random error).

Page 39: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

모형의 가정 (Assumptions of the model)

i. 각 칸의 관측값들은 두 요인의 수준들의 특정 조합으로 정의된 모집단에서 뽑은 𝑛개의 독립 표본으로 구성되어 있다. (independent sample)

ii. 𝑎𝑏개의 모집단은 각각 정규분포를 따른다. Normal distribution

iii. 모든 모집단은 동일한 분산을 가진다. Same variances

𝑥𝑖𝑗𝑘 = 𝜇 + 𝛼𝑖 + 𝛽𝑗 + (𝛼𝛽)𝑖𝑗+𝜀𝑖𝑗𝑘, 𝜀𝑖𝑗𝑘~𝑖𝑖𝑑 𝑁(0, 𝜎2), 𝑖 =

1, 2,⋯ , 𝑎; 𝑗 = 1, 2,⋯ , 𝑏; 𝑘 = 1, 2,⋯ , 𝑛

Page 40: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

0

0

0

0

0

0

: 0 1, ,

: Not 0 for some .

: 0 1, ,

: Not 0 for some .

:( ) 0 1, , 1, ,

:Not ( ) 0 for some , .

SST=SSA+SSB+SSAB+SSE

i

A i

j

A j

ij

A ij

H i a

H H i

H j b

H H j

H i a j b

H H i j

Hypotheses(가설)

Page 41: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

요인 factor 제곱합 SS 자유도 df 평균제곱 MS F

A 𝑆𝑆𝐴 𝑎 − 1 𝑀𝑆𝐴 = 𝑆𝑆𝐴/(𝑎 − 1) 𝑀𝑆𝐴 𝑀𝑆𝐸

B 𝑆𝑆𝐵 𝑏 − 1 𝑀𝑆𝐵 = 𝑆𝑆𝐵/(𝑏 − 1) 𝑀𝑆𝐵 𝑀𝑆𝐸

AB 𝑆𝑆𝐴𝐵 (𝑎 − 1)(𝑏 − 1) 𝑀𝑆𝐴𝐵 = 𝑆𝑆𝐴𝐵/(𝑎 − 1)(𝑏 − 1) 𝑀𝑆𝐴𝐵 𝑀𝑆𝐸

처리 trt 𝑆𝑆𝑇𝑟 𝑎𝑏 − 1

잔차residual 𝑆𝑆𝐸 𝑎𝑏(𝑛 − 1) 𝑀𝑆𝐸 = 𝑆𝑆𝐸/𝑎𝑏(𝑛 − 1)

이요인 완전확률화 설계의 분산분석표(고정효과모형)

ANOVA table for two-way complete randomized design

𝑆𝑆𝑇 = 𝑆𝑆𝑇𝑟 + 𝑆𝑆𝐸

𝑆𝑆𝑇𝑟 = 𝑆𝑆𝐴 + 𝑆𝑆𝐵 + 𝑆𝑆𝐴𝐵

Page 42: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

<Ex. 8.4.2>

간호사의 가정방문시간 (time of staying home for a nurse) =간호사의 연령 , 환자의 질환

(age of the nurse, disease of the patient)

( )

1, , 1, , 1, ,

(Model)

xijk i j ij ijk

i a j b k n

모형

Page 43: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간
Page 44: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

* miscellaneous (기타)

Log transformation: when normal assumption isviolated.

Normality is still problematic even after thevariable transformation. Sample size is too smallto check normality -> Nonparametric approach

e.g. income, concentration

Page 45: Chapter 8 실험계획및분산분석 - Seoul National Universityhosting03.snu.ac.kr/~hokim/int/2017/chap_8.pdf · 2017. 5. 1. · Ex. 8.3.1 약의종류와나이에따라치료까지걸린시간

Type of Sum of Squares

* Type Ⅰ:sequential (if we know the relative importance of the variables)

Type Ⅱ: partial without interaction terms

**TypeⅢ:partial with interactions(If we don’t know the relative importance of the variables)

TypeⅣ: There are missing cells (if none, same as TypeⅢ)

* , ** : defaults

model i ijY A :

One way ANOVA