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)

## Arguments

data |
A data frame. |

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

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

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` ) |

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 `FALSE` ) |

## Value

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.

## 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 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

#> [1] 1

#> [1] 0.425539

#> stat est
#> M M 0.42553898
#> H H 0.05642991