correct_match_shp2: Find the percent of the population that can be correctly...

View source: R/correct_match_shp2.R

correct_match_shp2R Documentation

Find the percent of the population that can be correctly identified at level 2 using only info from level 1

Description

This function takes the raw output of the overlap_dyad_creatr function to calculate, first, the shp1-shp2 dyads with the highest degree of overlap in order to calculate the proportion of the shp2 polygons' populations that could be correclty identified only using residency of the shp1 residency. Output is a df of each unique shp2 polygon value.

Usage

correct_match_shp2(overlap_dyad_output, id1, id2)

Arguments

overlap_dyad_output

The outputted data frame from the overlap_dyad_creatr function

id1

The ID field (chr) from the first shpfile of interest.

id2

The ID field (chr) from the second shpfile of interest.

census_fields

The string vector of other population fields of interest referring to census data that should be caclulated, which amounts to the raw weighted number of the individuals part of the demographic in question residing within the overlap of the two shpfile polygons of interest

Value

The data frame with the dyadic population overlap between the first and second shapefiles. The following are the values:

  • id1 = The renamed id field from the first shpfile

  • id2 = The renamed id field from the second shpfile

  • correctly_matched_pop = The numeric field of the summed estimated number of people residing between within the overlying area between the shp1 polygon and the shp2 polygon with the highest degree of overlap, to the shp2 level.

  • correct_pct = The proportion of the population that can be correctly identified using only shp1 residency.

Examples


zctas <- arealOverlapr::zctas
cbg_oh <- arealOverlapr::cbg_oh
oh_sen <- arealOverlapr::oh_sen
test_overlap <-weight_overlap(shp1 = zctas, shp_atom = cbg_oh, shp2 = oh_sen, pop_field = "POP2010")
test_output <- overlap_dyad_creatr(test_overlap, id1="ZCTA5CE10",id2="id", census_fields = c("WHITE","BLACK","MALES"))
test_correct <- correct_match_shp2(test_output, "id1", "id2")
 )

jcuriel-unc/arealOverlapr2 documentation built on March 27, 2022, 4:28 p.m.