# 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