mutual_local {segregation} | R Documentation |
Calculates local segregation scores based on M
Description
Returns local segregation indices for each category defined
by unit
.
Usage
mutual_local(
data,
group,
unit,
weight = NULL,
se = FALSE,
CI = 0.95,
n_bootstrap = 100,
base = exp(1),
wide = FALSE
)
Arguments
data |
A data frame. |
group |
A categorical variable or a vector of variables
contained in |
unit |
A categorical variable or a vector of variables
contained in |
weight |
Numeric. (Default |
se |
If |
CI |
If |
n_bootstrap |
Number of bootstrap iterations. (Default |
base |
Base of the logarithm that is used in the calculation. Defaults to the natural logarithm. |
wide |
Returns a wide dataframe instead of a long dataframe.
(Default |
Value
Returns a data.table with two rows for each category defined by unit
,
for a total of 2*(number of units)
rows.
The column est
contains two statistics that
are provided for each unit: ls
, the local segregation score, and
p
, the proportion of the unit from the total number of cases.
If se
is set to TRUE
, an additional column se
contains
the associated bootstrapped standard errors, an additional column CI
contains
the estimate confidence interval as a list column, an additional column bias
contains
the estimated bias, and the column est
contains the bias-corrected estimates.
If wide
is set to TRUE
, returns instead a wide dataframe, with one
row for each unit
, and the associated statistics in separate columns.
References
Henri Theil. 1971. Principles of Econometrics. New York: Wiley.
Ricardo Mora and Javier Ruiz-Castillo. 2011. "Entropy-based Segregation Indices". Sociological Methodology 41(1): 159–194.
Examples
# which schools are most segregated?
(localseg <- mutual_local(schools00, "race", "school",
weight = "n", wide = TRUE
))
sum(localseg$p) # => 1
# the sum of the weighted local segregation scores equals
# total segregation
sum(localseg$ls * localseg$p) # => .425
mutual_total(schools00, "school", "race", weight = "n") # M => .425