편의 표본추출

R에서의 표본추출

Richie Cotton

Data Evangelist at DataCamp

Literary Digest의 선거 예측

1936년자 Literary Digest 1면. 선거 예측 헤드라인: 랜던 130만 표, 루스벨트 약 100만 표.

  • 예측: 랜던 57%, 루스벨트 43%
  • 실제: 랜던 38%, 루스벨트 62%
  • 표본이 모집단을 대표하지 않아 표본 편향 발생
  • 가장 쉬운 방식으로 수집하는 것을 편의 표본추출이라 함
R에서의 표본추출

프랑스인 평균 나이 구하기

디즈니랜드 파리 사진.

  • 디즈니랜드 파리에서 10명 설문
  • 평균 나이 24.6세
  • 이것이 프랑스 전체의 좋은 추정일까요?
1 Image by Sean MacEntee
R에서의 표본추출

설문 정확도는?

연도 프랑스 평균 연령
1975 31.6
1985 33.6
1995 36.2
2005 38.9
2015 41.2
  • 24.6세는 부정확한 추정치입니다.
  • 디즈니랜드 방문객은 전체 인구를 대표하지 않습니다.
R에서의 표본추출

편의 표본추출: 커피 평점

coffee_ratings %>% 
  summarize(mean_cup_points = mean(total_cup_points))
  mean_cup_points
1           82.09
coffee_ratings_first10 <- coffee_ratings %>% 
  slice_head(n = 10)
coffee_ratings_first10 %>% 
  summarize(mean_cup_points = mean(total_cup_points))
  mean_cup_points
1            89.1
R에서의 표본추출

선택 편향 시각화

coffee_ratings %>%
  ggplot(aes(x = total_cup_points)) +
  geom_histogram(binwidth = 2)

모집단의 컵 포인트 히스토그램.

coffee_ratings_first10 %>%
  ggplot(aes(x = total_cup_points)) +
  geom_histogram(binwidth = 2) +
  xlim(59, 91)

표본의 컵 포인트 히스토그램.

R에서의 표본추출

선택 편향 시각화 2

coffee_ratings %>%
  ggplot(aes(x = total_cup_points)) +
  geom_histogram(binwidth = 2) 

모집단의 컵 포인트 히스토그램.

coffee_ratings %>%
  slice_sample(n = 10) %>% 
  ggplot(aes(x = total_cup_points)) +
  geom_histogram(binwidth = 2) +
  xlim(59, 91)

무작위 표본의 컵 포인트 히스토그램.

R에서의 표본추출

연습해 봅시다!

R에서의 표본추출

Preparing Video For Download...