Upgrade to Pro — share decks privately, control downloads, hide ads and more …

関連2群のt検定/独立2群のt検定 / Paired and unpaired t-tests

Kenji Saito
December 20, 2023

関連2群のt検定/独立2群のt検定 / Paired and unpaired t-tests

早稲田大学大学院経営管理研究科「企業データ分析」2023 冬の第7-8回で使用したスライドです。

Kenji Saito

December 20, 2023
Tweet

More Decks by Kenji Saito

Other Decks in Business

Transcript

  1. generated by Stable Diffusion XL v1.0 2023 7-8 2 t

    2 t (WBS) 2023 7-8 2 t 2 t — 2023-12-21 – p.1/32
  2. ( ) 1 11 30 • 2 11 30 (B

    A ) • 3 12 7 • 4 12 7 • 5 12 14 • 6 12 14 t • 7 12 21 2 ( ) t • 8 12 21 2 ( ) t • 9 1 11 P 10 1 11 11 1 18 12 1 18 13 1 25 14 1 25 W-IOI 2023 7-8 2 t 2 t — 2023-12-21 – p.3/32
  3. ( 20 ) 1 • 2 R • 3 •

    4 • 5 • 6 ( ) • 7 (1) • 8 (2) • 9 R ( ) (1) 10 R ( ) (2) 11 R ( ) (1) 12 R ( ) (2) 13 GPT-4 14 GPT-4 15 ( ) LaTeX Overleaf 8 (12/21 ) / (2 ) OK / 2023 7-8 2 t 2 t — 2023-12-21 – p.4/32
  4. 5 1 : 2 : 3 : 4 : 2

    6 t µ 95% Student t σ 95% 95% 95% 2023 7-8 2 t 2 t — 2023-12-21 – p.5/32
  5. ( Student µ 95% ) 7 2 t ( t

    ) 2 ( ) 2 d ( ) ← [ 3] σd 2 t 8 2 t ( t ) 2 ( ) ( ) ← [ 4] σ 2 t 2023 7-8 2 t 2 t — 2023-12-21 – p.6/32
  6. 3. µ 95% (1) (t ) µ 95% (2) 2023

    12 17 ( ) 23:59 JST ( ) Waseda Moodle (Q & A ) (1) Discord 2023 7-8 2 t 2 t — 2023-12-21 – p.8/32
  7. . . . . . . 10 8 (12/20( )

    ) ( ) ^^; ( ) ( ) 8 6 (1) ( ) ( ) (cf. p.50 Advice) (2) µ (µ N(µ, σ2) ) · ( ) (3) µ x t 2023 7-8 2 t 2 t — 2023-12-21 – p.9/32
  8. (1/2) (^^;) ( ( n ) ) = ( -

    ) ÷ × 10 + 50 x − µ σ (z) ×10 + 50 50 10 “ .txt” ( ) “ .R” psd(v) : v ( sd(v) ) ndistg(x, µ, σ) : z 2023 7-8 2 t 2 t — 2023-12-21 – p.10/32
  9. (2/2) (“ .R” ) > g <- read.table(" .txt", header=T)

    > g$ # > ndistg(x=91, mu=mean(g$ ), sigma=psd(g$ )) # 5 z ( ) z 2023 7-8 2 t 2 t — 2023-12-21 – p.11/32
  10. I 95% 100 95 ⇒ ( ) ^^; ( p.146)

    ( ) 2023 7-8 2 t 2 t — 2023-12-21 – p.12/32
  11. µ 95% (1/4) : N(µ, σ2) ( : ) STEP

    1 : : 10 STEP 2 : µ . . . 20 19 µ x [ 1] N(µ, σ2 n ) : 10 x z 95% ( 20 19 ) −z0.05 ≤ z (x − µ) √ n σ ≤ +z0.05 σ 2023 7-8 2 t 2 t — 2023-12-21 – p.13/32
  12. . . . . . . 1.96 σ √n (

    ) σ ↑ −z0.05 ≤ (x − µ) √ n σ (1) ⇒ −z0.05 × σ ≤ (x − µ) √ n (2) ⇒ −z0.05 × σ √ n ≤ x − µ (3) ⇒ µ − z0.05 × σ √ n ≤ x (4) ⇒ µ ≤ x + z0.05 × σ √ n (5) σ 2023 7-8 2 t 2 t — 2023-12-21 – p.14/32
  13. µ 95% (2/4) s N(0, 12) ( n 1,000 .

    . . ) n ( df) t (Student ) x Student t 95% ( 20 19 ) −t0.05 (df) ≤ t (x − µ) √ n s ≤ +t0.05 (df) µ . . . − t0.05 (df) ≤ (x − µ) √ n s (6) ⇒ − t0.05 (df) × s √ n ≤ x − µ (7) ⇒ µ ≤ x + t0.05 (df) × s √ n ( ) (8) (x − µ) √ n s ≤ +t0.05 (df) (9) ⇒ x − µ ≤ +t0.05 df × s √ n (10) ⇒ x − t0.05 (df) × s √ n ≤ µ ( ) (11) 2023 7-8 2 t 2 t — 2023-12-21 – p.15/32
  14. µ 95% (3/4) ┸ ┼ ┸⒨⒨⒭  ┸⒨⒨⒭  ┸

    df 9 t0.05 9 = 2.26  ▂  ▂ ฼ฏۉЖͷ  ৴པ۠ؒ ͕ 4UVEFOU Խ͞Εͨ΋ͷ ┸⒨⒨⒭  º 㲋┲ ┷ ্ଆ৴པݶք Լଆ৴པݶք 2023 7-8 2 t 2 t — 2023-12-21 – p.16/32
  15. µ 95% (4/4) “ .txt” µ 95% ( 100 )

    > mean(g$ ) - abs(qt(0.025, 99)) * sd(g$ ) / sqrt(100) # > mean(g$ ) + abs(qt(0.025, 99)) * sd(g$ ) / sqrt(100) # qt(0.025, length(g$ ) - 1) sqrt(length(g$ )) 95% CI [55.3, 62.9] “ L.R” sample t.test(g$ ) 95% CI [47.9, 55.6] 2023 7-8 2 t 2 t — 2023-12-21 – p.17/32
  16. S µ 95% 20 95% (95%) t ⇒ 2023 7-8

    2 t 2 t — 2023-12-21 – p.18/32
  17. S I R R [ ] Excel R Studio L.R

    95% R ⇒ 2023 7-8 2 t 2 t — 2023-12-21 – p.19/32
  18. S R ChatGPT4 ChatGPT ⇒ GPT GPT 3 (1) (GPT

    ) · R · µ 95% GPT-4 (n ) (2) (GPT ) (3) 2023 7-8 2 t 2 t — 2023-12-21 – p.20/32
  19. 7 2 t ( t ) 2 ( ) 2

    d ( ) ← [ 3] σd 2 t 2023 7-8 2 t 2 t — 2023-12-21 – p.21/32
  20. 3 : ( ) A B N(µA , σ2 A

    ) N(µB , σ2 B ) ( ) xA xB (xA + xB ) (xA − xB ) ( (reproductive property)) (xA + xB ) ( ) (µa + µb ) (xA − xB ) ( ) (µa − µb ) (xA + xB ) (xA − xB ) (σ2 A + σ2 B ) (xA + xB ) (xA − xB ) σ2 A + σ2 B 2023 7-8 2 t 2 t — 2023-12-21 – p.22/32
  21. 2 ( ) d ( ) d sd d (

    )µd d ( )µd d Student µd t = (d − µd ) √ n sd = d √ n sd (t ) t df = n − 1 t t(n − 1) ( ) t0.05 (df) t0.05 (df) < |t| (P < 0.05) 2023 7-8 2 t 2 t — 2023-12-21 – p.23/32
  22. N ( p.160) “ N.R” ( t.test() ) p.158 “

    .txt” / colnames(g) <- c(" ", " ") sampleA <- g$ sampleB <- g$ # 2023 7-8 2 t 2 t — 2023-12-21 – p.24/32
  23. 8 2 t ( t ) 2 ( ) (

    ) ← [ 4] σ 2 t 2023 7-8 2 t 2 t — 2023-12-21 – p.25/32
  24. 4 : (xA − xB ) ( ) 1 3

    A B N(µA , σ2 A ) N(µB , σ2 B ) xA xB xA xB (xA − xB ) (xA − xB ) ( ) (µA − µB ) (xA − xB ) xA xB σ2 A nA + σ2 B nB σ2 A nA + σ2 B nB 2023 7-8 2 t 2 t — 2023-12-21 – p.26/32
  25. (1/2) 2 ( ) xA − xB (1) : (2)

    : σ ( ) σ sp sp = s2 A (nA − 1) + s2 B (nB − 1) nA + nB − 2 (R var() ) nA + nB − 2 t Welch A B (µA = µB ) A B (µA = µB ) 2023 7-8 2 t 2 t — 2023-12-21 – p.27/32
  26. (2/2) xA − xB Student µA = µB t =

    (xA − xB ) − (µA − µB ) sp 1 nA + 1 nB = xA − xB sp 1 nA + 1 nB (t ) t dfp = nA + nB − 2 t ( ) t0.05 (dfp ) t0.05 (dfp ) < |t| (P < 0.05) 2023 7-8 2 t 2 t — 2023-12-21 – p.28/32
  27. P ( p.186) “ P.R” ( t.test() ) p.184 “

    .txt” A /B colnames(g) <- c(" ", " ") sampleA <- g$ sampleB <- g$ # 2023 7-8 2 t 2 t — 2023-12-21 – p.29/32
  28. 4. t (1) 2 t (2) 2 t (3) 2024

    1 7 ( ) 23:59 JST ( ) Waseda Moodle (Q & A ) (1)(2) Discord 2023 7-8 2 t 2 t — 2023-12-21 – p.31/32