Returns local segregation indices for each category defined by unit.

mutual_local(data, group, unit, weight = NULL, se = FALSE,
  n_bootstrap = 10, base = exp(1), wide = FALSE)



A data frame.


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


A categorical variable or a vector of variables contained in data. Defines the group for which local segregation indices are calculated.


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


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


Number of bootstrap iterations. (Default 10)


Base of the logarithm that is used in the calculation. Defaults to the natural logarithm.


Returns a wide dataframe instead of a long dataframe. (Default FALSE)


Returns a data frame 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, and the column est contains bootstrapped 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.


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.


# which racial groups are most segregated? (localseg = mutual_local(schools00, "school", "race", weight="n", wide = TRUE))
#> race ls p #> 1 asian 0.6287673 0.022553401 #> 2 black 0.8805413 0.190149919 #> 3 hisp 0.7766327 0.151696575 #> 4 white 0.1836393 0.628092178 #> 5 native 1.4342644 0.007507927
sum(localseg$p) # => 1
#> [1] 1
# the sum of the weighted local segregation scores equals # total segregation sum(localseg$ls * localseg$p) # => .425
#> [1] 0.425539
mutual_total(schools00, "school", "race", weight="n") # M => .425
#> stat est #> M M 0.42553898 #> H H 0.05642991