비율에 대한 가설검정

R로 배우는 범주형 데이터 추론

Andrew Bray

Assistant Professor of Statistics at Reed College

2-1-1.png

R로 배우는 범주형 데이터 추론

2-1-2.png

R로 배우는 범주형 데이터 추론

2-1-3.png

R로 배우는 범주형 데이터 추론

2-1-4.png

R로 배우는 범주형 데이터 추론

2-1-5.png

R로 배우는 범주형 데이터 추론

2-1-6.png

R로 배우는 범주형 데이터 추론

미국인의 절반이 사형을 지지할까?

gss2016 %>%
  ggplot(aes(x = cappun)) +
  geom_bar()
p_hat <- gss2016 %>%
  summarize(mean(cappun == "FAVOR")) %>%
  pull()
p_hat
0.5666667

ch2v1-density-plot.png

R로 배우는 범주형 데이터 추론

미국인의 절반이 사형을 지지할까?

null <- gss2016 %>%
  specify(
    response = cappun, 
    success = "FAVOR"
  ) %>%
  hypothesize(
    null = "point", 
    p = 0.5
  ) %>%
  generate(
    reps = 500, 
    type = "simulate"
  ) %>%
  calculate(stat = "prop")
A tibble: 500 x 2
   replicate  stat
   <fct>     <dbl>
 1 1         0.48 
 2 2         0.447
 3 3         0.48 
 4 4         0.44 
 5 5         0.407
 6 6         0.52 
 7 7         0.413
 8 8         0.553
 9 9         0.52 
10 10        0.467
# … with 490 more rows
R로 배우는 범주형 데이터 추론

미국인의 절반이 사형을 지지할까?

ggplot(null, aes(x = stat)) +
  geom_density() +
  geom_vline(
    xintercept = p_hat, 
    color = "red"
  )
null %>%
  summarize(mean(stat > p_hat)) %>%
  pull() * 2

ch2v1-density-plot.png

R로 배우는 범주형 데이터 추론

가설검정

  • 귀무가설: 세계의 상태에 대한 이론.
  • 귀무분포: 귀무가설이 참일 때 검정통계량의 분포.
  • p값: 귀무가설과 관측치의 일치 정도.
    • p값 큼: 일치함(p값 > 알파)
    • p값 작음: 불일치(p값 < 알파)
R로 배우는 범주형 데이터 추론

Ayo berlatih!

R로 배우는 범주형 데이터 추론

Preparing Video For Download...