신뢰구간 해석

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

Andrew Bray

Assistant Professor of Statistics at Reed College

신뢰구간

결론: 실제로 행복한 미국인의 비율은 0.705~0.841 사이입니다.

여기서 ‘신뢰’는 무엇을 뜻할까요?

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

데이터셋 1

ds1 <- filter(gss, year == 2016)

p_hat <- ds1 %>% summarize(mean(happy == "HAPPY")) %>% pull()
SE <- ds1 %>% specify(response = happy, success = "HAPPY") %>% generate(reps = 500, type = "bootstrap") %>% calculate(stat = "prop") %>% summarize(sd(stat)) %>% pull()
c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7073114 0.8393553

confidence-interval

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

one.png

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

two.png

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

three.png

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

four.png

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

five.png

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

six.png

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

seven.png

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

eight.png

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

nine.png

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

ten.png

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

데이터셋 2

ds2 <- filter(gss, year == 2014)

p_hat <- ds1 %>% summarize(mean(happy == "HAPPY")) %>% pull()
SE <- ds1 %>% specify(response = happy, success = "HAPPY") %>% generate(reps = 500, type = "bootstrap") %>% calculate(stat = "prop") %>% summarize(sd(stat)) %>% pull()
c(p_hat - 2 * SE, p_hat + 2 * SE)
0.8348831 0.9384503

Screenshot 2019-02-21 18.05.03.png

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

데이터셋 3

ds3 <- filter(gss, year == 2012)

p_hat <- ds1 %>% summarize(mean(happy == "HAPPY")) %>% pull()
SE <- ds1 %>% specify(response = happy, success = "HAPPY") %>% generate(reps = 500, type = "bootstrap") %>% calculate(stat = "prop") %>% summarize(sd(stat)) %>% pull()
c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7626359 0.8906974

1-2-1.png

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

데이터셋 3

ds3 <- filter(gss, year == 2012)
p_hat <- ds3 %>%
  summarize(mean(happy == "HAPPY")) %>%
  pull()
SE <- ds3 %>%
  specify(response = happy, 
          success = "HAPPY") %>%
  generate(reps = 500, 
           type = "bootstrap") %>%
  calculate(stat = "prop") %>%
  summarize(sd(stat)) %>%
  pull()

c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7626359 0.8906974

1-2-2.png

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

데이터셋 3

ds3 <- filter(gss, year == 2012)
p_hat <- ds3 %>%
  summarize(mean(happy == "HAPPY")) %>%
  pull()
SE <- ds3 %>%
  specify(response = happy, 
          success = "HAPPY") %>%
  generate(reps = 500, 
           type = "bootstrap") %>%
  calculate(stat = "prop") %>%
  summarize(sd(stat)) %>%
  pull()

c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7626359 0.8906974

1-2-3.png

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

데이터셋 3

ds3 <- filter(gss, year == 2012)
p_hat <- ds3 %>%
  summarize(mean(happy == "HAPPY")) %>%
  pull()
SE <- ds3 %>%
  specify(response = happy, 
          success = "HAPPY") %>%
  generate(reps = 500, 
           type = "bootstrap") %>%
  calculate(stat = "prop") %>%
  summarize(sd(stat)) %>%
  pull()

c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7626359 0.8906974

1-2-4.png

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

데이터셋 3

ds3 <- filter(gss, year == 2012)
p_hat <- ds3 %>%
  summarize(mean(happy == "HAPPY")) %>%
  pull()
SE <- ds3 %>%
  specify(response = happy, 
          success = "HAPPY") %>%
  generate(reps = 500, 
           type = "bootstrap") %>%
  calculate(stat = "prop") %>%
  summarize(sd(stat)) %>%
  pull()

c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7626359 0.8906974

1-2-5.png

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

데이터셋 3

ds3 <- filter(gss, year == 2012)
p_hat <- ds3 %>%
  summarize(mean(happy == "HAPPY")) %>%
  pull()
SE <- ds3 %>%
  specify(response = happy, 
          success = "HAPPY") %>%
  generate(reps = 500, 
           type = "bootstrap") %>%
  calculate(stat = "prop") %>%
  summarize(sd(stat)) %>%
  pull()

c(p_hat - 2 * SE, p_hat + 2 * SE)
0.7626359 0.8906974

1-2-6.png

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

신뢰구간

해석: “행복한 미국인의 실제 비율이 0.705~0.841 사이라고 95% 신뢰합니다.”

구간의 너비에 영향을 주는 요인

  • n
  • 신뢰수준
  • p
R로 배우는 범주형 데이터 추론

연습해 봅시다!

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

Preparing Video For Download...