View source: R/herfindahl_new.R
herfindahl_new | R Documentation |
This function takes the raw output of the weight_overlap function (also part of the arealOverlapr pkg), and calculates the population overlap between two levels of geography, and the demographic information of interest from census data.
herfindahl_new(overlap_dyad_output, pop_field, id1)
overlap_dyad_output |
The outputted data frame from the overlap_dyad_creatr function |
id1 |
The ID field (chr) from the first shpfile of interest. |
shp_atom |
The atomic unit of geography shpfile that will be used to calculate the spatial weights by population |
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 |
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
herf_index = The Herfindahl index, a measure of the diversity of shp2 units within the shp1 file. The scale ranges from 0 for complete heterogeneity and division across shp2 polygons, and 1 for complete homogeneity and nestedness within a single shp2 polygon.
eff_num = The effective number of shp2 polygonal units within the shp1 polygons. This is the inverse of the Herfindahl index.
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_herf <- herfindahl_new(test_output,"pop_wt", "id1") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.