tidycensus에서 오차 범위 다루기

R로 분석하는 미국 인구조사 데이터

Kyle Walker

Instructor

ACS 데이터 vs. 인구조사 데이터

R로 분석하는 미국 인구조사 데이터

ACS의 오차 범위

get_acs(geography = "county", 
        variables = c(median_age = "B01002_001"), 
        state = "OR")
# A tibble: 36 x 5
   GEOID NAME                     variable   estimate   moe
   <chr> <chr>                    <chr>         <dbl> <dbl>
 1 41001 Baker County, Oregon     median_age     48.2   0.4
 2 41003 Benton County, Oregon    median_age     32.6   0.3
 3 41005 Clackamas County, Oregon median_age     41.4   0.2
 4 41007 Clatsop County, Oregon   median_age     43.7   0.4
 5 41009 Columbia County, Oregon  median_age     43.3   0.4
 6 41011 Coos County, Oregon      median_age     48.2   0.3
 7 41013 Crook County, Oregon     median_age     48.3   0.7
# ... with 29 more rows
R로 분석하는 미국 인구조사 데이터

오차 범위 살펴보기

vt_eldpov <- get_acs(geography = "tract", 
                     variables = c(eldpovm = "B17001_016", 
                                   eldpovf = "B17001_030"), 
                     state = "VT")
vt_eldpov
# A tibble: 368 x 5
   GEOID       NAME                 variable estimate   moe
   <chr>       <chr>                <chr>       <dbl> <dbl>
 1 50001960100 Census Tract 9601... eldpovm        0.    9.
 2 50001960100 Census Tract 9601... eldpovf        5.    5.
 3 50001960200 Census Tract 9602... eldpovm        0.    9.
 4 50001960200 Census Tract 9602... eldpovf        0.    9.
 5 50001960300 Census Tract 9603... eldpovm       16.   14.
 6 50001960300 Census Tract 9603... eldpovf        5.    7.
# ... with 362 more rows
R로 분석하는 미국 인구조사 데이터

오차 범위 함수 사용하기

tidycensus에서 오차 범위 계산에 사용하는 함수:

  • moe_sum(): 합계의 오차 범위
  • moe_product(): 곱의 오차 범위
  • moe_ratio(): 비율의 오차 범위
  • moe_prop(): 비례의 오차 범위
R로 분석하는 미국 인구조사 데이터

그룹별 오차 범위

vt_eldpov2 <- vt_eldpov %>%
  group_by(GEOID) %>%
  summarize(
    estmf = sum(estimate), 
    moemf = moe_sum(moe = moe, estimate = estimate))
vt_eldpov2
# A tibble: 184 x 3
   GEOID       estmf moemf
   <chr>       <dbl> <dbl>
 1 50001960100     5 10.3 
 2 50001960200     0  9   
 3 50001960300    21 15.7 
 4 50001960400    29 11.4 
 5 50001960500     0  9   
# ... with 179 more rows
R로 분석하는 미국 인구조사 데이터

연습해 봅시다!

R로 분석하는 미국 인구조사 데이터

Preparing Video For Download...