Làm việc với sai số biên trong tidycensus

Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Kyle Walker

Instructor

Dữ liệu ACS so với dữ liệu điều tra dân số

Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Sai số biên trong 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
Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Kiểm tra sai số biên

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
Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Dùng các hàm sai số biên

tidycensus gồm các hàm tính sai số biên:

  • moe_sum(): MOE cho tổng suy dẫn
  • moe_product(): MOE cho tích suy dẫn
  • moe_ratio(): MOE cho tỷ số suy dẫn
  • moe_prop(): MOE cho tỷ lệ suy dẫn
Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Sai số biên theo nhóm

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
Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Cùng luyện tập nào!

Phân tích dữ liệu Điều tra Dân số Hoa Kỳ bằng R

Preparing Video For Download...