mutual_total {segregation} | R Documentation |
Calculates the Mutual Information Index M and Theil's Entropy Index H
Description
Returns the total segregation between group
and unit
.
If within
is given, calculates segregation within each
within
category separately, and takes the weighted average.
Also see mutual_within
for detailed within calculations.
Usage
mutual_total(
data,
group,
unit,
within = NULL,
weight = NULL,
se = FALSE,
CI = 0.95,
n_bootstrap = 100,
base = exp(1)
)
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 |
within |
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. |
Value
Returns a data.table with two rows. The column est
contains
the Mutual Information Index, M, and Theil's Entropy Index, H. The H is the
the M divided by the group
entropy. If within
was given,
M and H are weighted averages of the within-category segregation scores.
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.
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
# calculate school racial segregation
mutual_total(schools00, "school", "race", weight = "n") # M => .425
# note that the definition of groups and units is arbitrary
mutual_total(schools00, "race", "school", weight = "n") # M => .425
# if groups or units are defined by a combination of variables,
# vectors of variable names can be provided -
# here there is no difference, because schools
# are nested within districts
mutual_total(schools00, "race", c("district", "school"),
weight = "n"
) # M => .424
# estimate standard errors and 95% CI for M and H
## Not run:
mutual_total(schools00, "race", "school",
weight = "n",
se = TRUE, n_bootstrap = 1000
)
# estimate segregation within school districts
mutual_total(schools00, "race", "school",
within = "district", weight = "n"
) # M => .087
# estimate between-district racial segregation
mutual_total(schools00, "race", "district", weight = "n") # M => .338
# note that the sum of within-district and between-district
# segregation equals total school-race segregation;
# here, most segregation is between school districts
## End(Not run)