Description Usage Arguments Details Value Note Source
The Divergence Index is additively decomposable. This function allows for splitting a population into groups of observations and calculating the divergence score within those groups and between those groups.
1 2 3 4 5 6 7 8 | decompose_divergence(
dataframe,
groupCol = NULL,
popCol = NA,
weightCol = NA,
output = "scores",
...
)
|
dataframe |
A dataframe composed of numeric/integer columns representing percentages of each
population group. All columns are used in the divergence calculation
except for those specified in |
groupCol |
Name of the column(s) in the dataframe used for grouping.
if passing a |
popCol |
Either NA (default), which sets the population of each row to 1,
or a character string of the column name in |
weightCol |
alias for popCol |
output |
Any of:
|
... |
options passed through to |
The sum of the scores reported in decompose_divergence
when setting summed==TRUE
should always be equal to the
Deomposing the divergence index allows users to simultatneously examine the segregation within and between groups of a large geography. Furthermore, users can assess the percentage of segregation coming from each group.
The output
paramater "scaled" transforms the divergence index
it from an absolute to a relative measure of inequality and segregation, and negates
several of its desirable properties, including aggregation equivalence and independence.
(See Roberto, 2016)
A dataframe as specified by the output
parameter.
The dataframe will have three columns: 'within_divergence', equivalent to
divergence()
for each dataframe or group in dataframe
;
'between_divergence', the divergence score of each group's demographics compared
to the full population; and weightCol
, the sum of the weights for each group.
The sum of decompose_divergence(...,summed = T)
should
equal the result of divergence(...,summed = T)
The divergence
parameters for each group are set to their defaults
unless explicitly noted above.
decompose_divergence
treats the entire dataset its given as the total population,
which may not be desirable in some contexts, for example, when trying to return divergence
scores across years. In that context, it's helpful to split the dataframe into a list of
dataframes and use decompose_divergence
inside a sapply function.
Roberto, 2016. "A Decomposable Measure of Segregation and Inequality."
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.