第 6 回 分散分析(第 7 章) Analysis of Variance

20
1 第6第 第第第第 7第Analysis of Variance •第第第第第第第第第第第第第 –第第第第第 第第第第第第 第第第第第 体() •第第第第第第 Decomposition of Sum of Squares –第 第第第第第第 第第第第第第第第 第第 体=+ •第第第第第第第第第 第第第第第第第第 –第第 第第 第 第第第第第第第第第 (体)

description

第 6 回 分散分析(第 7 章) Analysis of Variance. 回帰モデルにおける分散分析 回帰式の全体的な適合度(分散分析) 平方和の分解 Decomposition of Sum of Squares 全体の散らばり=説明できた部分+残差 対応のないデータと,対応のあるデータ 個人(個体)による違いを考える. 帰無仮説と対立仮説 Null Hypothesis and Alternate Hypothesis. A person has headache (pain in head) - PowerPoint PPT Presentation

Transcript of 第 6 回 分散分析(第 7 章) Analysis of Variance

Page 1: 第 6 回 分散分析(第 7 章) Analysis of Variance

1

第 6 回 分散分析(第 7 章)Analysis of Variance

•回帰モデルにおける分散分析–回帰式の全体的な適合度(分散分析)

•平方和の分解 Decomposition of Sum of Squares

–全体の散らばり=説明できた部分+残差•対応のないデータと,対応のあるデータ

–個人(個体)による違いを考える

Page 2: 第 6 回 分散分析(第 7 章) Analysis of Variance

帰無仮説と対立仮説Null Hypothesis and Alternate Hypothesis

• A person has headache ( pain in head)

Before it, he drank a glass of bad wine.

• Alternate Hypothesis: what is susceptive;

The wine was the cause of the pain. (guilty)

• Null Hypothesis: Opposite to that hypothesis;

The wine was not the cause of the pain. (innocent)

2

Page 3: 第 6 回 分散分析(第 7 章) Analysis of Variance

棄却と採択Rejection of the Null Hypothesis

• When we permit the Null Hypothesis, the probability of the realized event is calculated.– Calculate the probability of headache when he did not drink

such a wine.

• If the probability is too small (smaller than your critical probability), you can reject the null-hypothesis and approve the alternate hypothesis.– The wine was the cause of the pain. (guilty)

• If the probability is not too small, you cannot say anything. (not actively approve the null hypothesis). – The wine was not the cause of the pain. (innocent)

3

Page 4: 第 6 回 分散分析(第 7 章) Analysis of Variance

連続変数と棄却域Critical Value for Continuous Variable

• If he had headache with certain large probability, when drinking no wine, we cannot reject the Null Hypothesis.

4

•We take a continuous variable such as headache duration, we can set the critical region, more easily, based on the usual probability density.

No-ache Ache Duration ofheadache

0.05Probability Density under the Null Hypothesis

60min

Page 5: 第 6 回 分散分析(第 7 章) Analysis of Variance

5

  F 分布 ( F distribution)

• 確率密度関数

自由度 (f1,f2) の F 分布

F分布も χ2分布と関係がある。

X, Y が独立でそれぞれ自由度 f1, f2 の χ2 分布に従うとき、

は自由度 (f1, f2) の F 分布に従う。

したがって 2 つの標本群から計算した分散の比をとると、その統計量は F 分布に従う.

2

1/

/fY

fXZ

Page 6: 第 6 回 分散分析(第 7 章) Analysis of Variance

6

  F 分布表 ( F distribution)

Page 7: 第 6 回 分散分析(第 7 章) Analysis of Variance

7

目的変数をどの程度 [ 記述 ] 出来たか?

ix

Y

X

yiy

)(ˆii XfY

残差 誤差・

iii yy ˆ

残差平方和Error Sum of Squared

        

22 )ˆ( i

iii

iE yyS

Y

y

Xi による説明式がない場合yi の推計値として、平均値 y を使うしかない

平均値周りのバラツキ(全平方和)

Total Sum of Squares2)(

iiT yyS

なる説明式がある場合回帰( Xi で説明できた  y  からのずれ)

yyi ˆ

回帰平方和Regressed Sum of Squared

        

2)ˆ( i

iR yyS

決定係数

説明できた平方和の割合

T

E

T

R

S

S

S

SR 12

Page 8: 第 6 回 分散分析(第 7 章) Analysis of Variance

8

平方和(散らばり)の分解Decomposition of Sum of Squared

全体の散らばり( Total) を分解 説明できた散らばり( Regressed)   +残りの散らばり( Error)

それぞれを平方和( Sum of Squared) で評価  ST=SR+SE

帰無仮説: SR と SE は統計的に同程度のものそのときには、 Fo = VR/VE は F 分布 ( 自由度 fR, fE) に従

う       ただし VR=SR/fR , VE=SE/fE

Page 9: 第 6 回 分散分析(第 7 章) Analysis of Variance

9

回帰による記述(説明)力の検定

– 回帰平方和が統計的に大きな意味を持っているか?

– 分散分析表を作り、 F 検定を行って判断する。

• 帰無仮説:回帰平方和は誤差平方和と同程度の大きさ (回帰式は、誤差に比べて大きな説明力はない)• 対立仮説:回帰平方和は誤差平方和より大きい (回帰式によって誤差よりもかなり大きい部分が説明

できた)

Page 10: 第 6 回 分散分析(第 7 章) Analysis of Variance

10

回帰による記述(説明)力の検定例

• 帰無仮説:回帰平方和は誤差平方和と同程度の大きさ (回帰式は、誤差に比べて大きな説明力はない)→棄

却• 対立仮説:回帰平方和は誤差平方和より大きい (回帰式により、誤差よりもかなり大きい部分が説明

できた)Multiple R-squared: 0.9511, Adjusted R-squared: 0.9348 F-statistic: 58.37 on 2 and 6 DF, p-value: 0.0001168

Page 11: 第 6 回 分散分析(第 7 章) Analysis of Variance

11

7.1 一元配置法 ( 対応なし )p .159

• 指導法ごとに,テストの点数が異なるか ?

A B C D

15

9

18

14

18

13

8

8

12

7

10

6

11

7

12

10

7

3

5

7

Page 12: 第 6 回 分散分析(第 7 章) Analysis of Variance

12

変動の分解A B C D

15

9

18

14

18

13

8

8

12

7

10

6

11

7

12

10

7

3

5

7

A B C D

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

A B C D

+5

-1

+8

+4

+8

+3

-2

-2

+2

-3

0

-4

+1

-3

+2

0

-3

-7

-5

-3

全体変動観測値 全体平均

A B C D

+5

-1

+8

+4

+8

+3

-2

-2

+2

-3

0

-4

+1

-3

+2

0

-3

-7

-5

-3

全体変動

A B C D

4.8

4.8

4.8

4.8

4.8

-0.4

-0.4

-0.4

-0.4

-0.4

-0.8

-0.8

-0.8

-0.8

-0.8

-3.6

-3.6

-3.6

-3.6

-3.6

A B C D

0.2

-5.8

3.2

-0.8

3.2

3.4

-1.6

-1.6

2.4

-2.6

0.8

-3.2

1.8

-2.2

2.8

3.6

0.6

-3.4

-1.4

-0.6

群内変動 ( 残差 )群間平均

Page 13: 第 6 回 分散分析(第 7 章) Analysis of Variance

13

平方和の評価A B C D

+5

-1

+8

+4

+8

+3

-2

-2

+2

-3

0

-4

+1

-3

+2

0

-3

-7

-5

-3

全体変動

A B C D

4.8

4.8

4.8

4.8

4.8

-0.4

-0.4

-0.4

-0.4

-0.4

-0.8

-0.8

-0.8

-0.8

-0.8

-3.6

-3.6

-3.6

-3.6

-3.6

A B C D

0.2

-5.8

3.2

-0.8

3.2

3.4

-1.6

-1.6

2.4

-2.6

0.8

-3.2

1.8

-2.2

2.8

3.6

0.6

-3.4

-1.4

-0.6

群内変動 ( 残差 )群間平均

平方和  322 平方和  184 平方和  138

自由度 19 = 20-1 自由度 3 = 4-1 自由度 16=4(5-1)

分散 16.94 = 322/19 分散 61.3-184/3 分散 8.6=138/16

F=61.33/8.625=7.11

Page 14: 第 6 回 分散分析(第 7 章) Analysis of Variance

14

  F 分布表 ( F distribution)

7.111 > F(0.05:3,16) = 3.24

3.24 7.11

Under the null-hypothesis,The Ratio of Variance goes beyond the observed value (7.111) with Probability smaller than 0.05.

You can reject the null-hypothesis:The inter-group variation is statistically different from the inner-group.

Page 15: 第 6 回 分散分析(第 7 章) Analysis of Variance

R による計算  aov()> 統計テスト 2 [1] 15 9 18 14 18 13 8 8 12 7 10 6 11 7 12 10 7 3 5 7> 指導法 2 [1] A A A A A B B B B B C C C C C D D D D DLevels: A B C D> oneway.test( 統計テスト 2~ 指導法 2,var.equal=TRUE)

One-way analysis of means

data: 統計テスト 2 and 指導法 2 F = 7.1111, num df = 3, denom df = 16, p-value = 0.002988

> summary(aov( 統計テスト 2~ 指導法 2)) Df Sum Sq Mean Sq F value Pr(>F) 指導法 2 3 184.000 61.333 7.1111 0.002988 **Residuals 16 138.000 8.625 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 >

Page 16: 第 6 回 分散分析(第 7 章) Analysis of Variance

16

7.2 一元配置法 ( 対応あり )p .175

• 3 科目に対する好意度の評価学生 線形代数 微分積分 確率統計

田中岸

大引吉川荻野

7

8

9

5

6

5

4

7

1

3

8

6

7

2

5

Page 17: 第 6 回 分散分析(第 7 章) Analysis of Variance

17

変動の分解線 微 確

田岸大吉荻

7

8

9

5

6

5

4

7

1

3

8

6

7

2

5

線 微 確

田岸大吉荻

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

5.53

線 微 確

田岸大吉荻

1.46

2.46

3.46

-0.53

0.46

-0.53

-1.53

1.46

-4.53

-2.53

2.46

0.46

1.46

-3.53

-0.53

全体変動観測値 全体平均

線 微 確

田岸大吉荻

1.13

0.46

2.13

-2.86

-0.86

1.13

0.46

2.13

-2.86

-0.86

1.13

0.46

2.13

-2.86

-0.86

全体変動

線 微 確

田岸大吉荻

1.46

1.46

1.46

1.46

1.46

-1.53

-1.53

-1.53

-1.53

-1.53

0.06

0.06

0.06

0.06

0.06

( 残差 )条件 ( 科目間 ) 個人差 ( 個人間 )

線 微 確

田岸大吉荻

-1.13

0.53

-0.13

0.86

-0.13

-0.13

-0.46

0.86

-0.13

-0.13

1.26

-0.06

-0.73

-0.73

-0.26

Page 18: 第 6 回 分散分析(第 7 章) Analysis of Variance

18

平方和の評価

平方和  73.73平方和  22.53 平方和  6.133

自由度14 = 15-1 自由度 2 = 3-1 自由度 8=4(3-1)

分散 11.267 分散  0.767

線 微 確

田岸大吉荻

1.13

0.46

2.13

-2.86

-0.86

1.13

0.46

2.13

-2.86

-0.86

1.13

0.46

2.13

-2.86

-0.86

全体変動

線 微 確

田岸大吉荻

1.46

1.46

1.46

1.46

1.46

-1.53

-1.53

-1.53

-1.53

-1.53

0.06

0.06

0.06

0.06

0.06

( 残差 )条件 ( 科目間 ) 個人差 ( 個人間 )

線 微 確

田岸大吉荻

-1.13

0.53

-0.13

0.86

-0.13

-0.13

-0.46

0.86

-0.13

-0.13

1.26

-0.06

-0.73

-0.73

-0.26

平方和  45.06

自由度 4 = 5-1

分散 11.267

Fo=11.267/0.767=14.69>F(2,8,0.05)=4.64

Fo=11.267/0.767=14.69>F(4,8,0.05)=3.84

Page 19: 第 6 回 分散分析(第 7 章) Analysis of Variance

R による計算  aov()> 好意度 [1] 7 8 9 5 6 5 4 7 1 3 8 6 7 2 5> 科目 [1] 線形代数 線形代数 線形代数 線形代数 線形代数 微分積分 微分積分 微分積分 微分積分 [10] 微分積分 確率統計 確率統計 確率統計 確率統計 確率統計Levels: 確率統計 線形代数 微分積分> 人 [1] 田中 岸 大引 吉川 荻野 田中 岸 大引 吉川 荻野 田中 岸 大引 吉川 荻野Levels: 荻野 岸 吉川 大引 田中> summary(aov( 好意度 ~ 科目 )) Df Sum Sq Mean Sq F value Pr(>F)科目 2 22.533 11.267 2.6406 0.1121Residuals 12 51.200 4.267

Page 20: 第 6 回 分散分析(第 7 章) Analysis of Variance

R による計算  aov()> summary(aov( 好意度 ~ 人 )) Df Sum Sq Mean Sq F value Pr(>F) 人 4 45.067 11.267 3.9302 0.03603 *Residuals 10 28.667 2.867 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> summary(aov( 好意度 ~ 科目 + 人 ) ) Df Sum Sq Mean Sq F value Pr(>F) 科目 2 22.533 11.267 14.696 0.002095 ** 人 4 45.067 11.267 14.696 0.000931 ***Residuals 8 6.133 0.767 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1