Learn R Programming

segregation (version 0.0.1)

mutual_total: Calculate the total mutual information index

Description

Returns the total segregation between unit and group.

Usage

mutual_total(data, unit, group, within = NULL, weight = NULL, se = FALSE,
  n_bootstrap = 10)

Arguments

data

A data frame.

unit

A categorical variable or a vector of variables contained in data. Defines the first dimension over which segregation is computed.

group

A categorical variable or a vector of variables contained in data. Defines the second dimension over which segregation is computed.

within

A categorical variable or a vector of variables contained in data. The variable(s) should be a superset of either the unit or the group for the calculation to be meaningful. If provided, segregation is computed within the groups defined by the variable, and then averaged. (Default NULL)

weight

Numeric. Only frequency weights are allowed. (Default NULL)

se

If TRUE, standard errors are estimated via bootstrap. (Default FALSE)

n_bootstrap

Number of bootstrap iterations. (Default 10)

Value

Returns a data frame with three rows. The column est contains in the first row total segregation. The second and third rows contain the lower and upper bounds of M, respectively. If se is set to TRUE, an additional column se contains the associated bootstrapped standard errors, and the column est contains bootstrapped 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<U+2013>194.

Examples

Run this code
# NOT RUN {
# calculate school racial segregation
mutual_total(schools00, "school", "race", weight="n") # => .425

# note that the definition of units and groups is arbitrary
mutual_total(schools00, "race", "school", weight="n") # => .425

# if units or groups 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") # => .424

# estimate a standard error of M
mutual_total(schools00, "race", "school", weight="n", se=TRUE)

# estimate segregation within school districts
mutual_total(schools00, "race", "school",
             within="district", weight="n") # => .087

# estimate between-district racial segregation
mutual_total(schools00, "race", "district", weight="n") # => .338
# note that the sum of within-district and between-district
# segregation equals total school-race segregation;
# here, most segregation is between school districts
# }

Run the code above in your browser using DataLab