The maihdaR package provides specialized tools for conducting Multilevel Analysis of Individual Heterogeneity and Discriminatory Accuracy (MAIHDA) in R. MAIHDA is an innovative intersectional approach that uses multilevel models to examine health disparities across multiple intersecting social identities while avoiding the "curse of dimensionality" that affects traditional interaction-based methods.
MAIHDA is a quantitative intersectional methodology that:
- π Examines health outcomes across multiple intersecting identities (e.g., race Γ gender Γ class Γ age)
- π― Quantifies both individual heterogeneity and discriminatory accuracy of social categorizations
- π Uses multilevel models to handle high-dimensional intersectional strata
- π Provides measures of how much health variation exists between vs. within social strata
This approach is particularly valuable for health equity research, allowing researchers to move beyond single-axis analyses (examining only race OR gender OR class) to understand how multiple identities interact to shape health outcomes.
-
π§ Stratum Creation: Automated generation of intersectional strata from multiple identity variables
-
π Model Fitting: Streamlined workflows for fitting MAIHDA models with appropriate random effect structures
-
π Diagnostic Metrics:
- Intraclass Correlation Coefficient (ICC) for between-stratum variation
- Proportional Change in Variance (PCV) for understanding fixed-effect contributions
- Area Under the Curve (AUC) for discriminatory accuracy
- Variance Partition Coefficient (VPC) calculations
-
π Visualization Tools:
- Caterpillar plots for stratum-specific effects
- Interaction plots for intersectional disparities
- Diagnostic plots for model assessment
-
π Reporting Functions: Generate publication-ready tables and summaries
Install the development version of maihdaR from GitHub:
# install.packages("devtools")
devtools::install_github(
"yiyang-gao-1/maihda-r-package",
dependencies = TRUE,
build_vignettes = TRUE
)library(maihdaR)
# Load example data (simulated health survey data)
data("health_intersections")
# Create intersectional strata
health_intersections$strata <- create_strata(
data = health_intersections,
identity_vars = c("race", "gender", "education", "age_group")
)
# Fit a MAIHDA model
model <- fit_maihda(
data = health_intersections,
outcome = "self_rated_health",
fixed_effects = c("race", "gender", "education", "age_group"),
strata_var = "strata",
family = gaussian() # or binomial() for binary outcomes
)
# Calculate key diagnostics
icc_value <- calculate_icc(model)
print(paste("ICC:", round(icc_value, 3)))
# Visualize stratum effects
plot_strata_effects(model)# More complex analysis with binary outcome
health_intersections$poor_health <- ifelse(
health_intersections$self_rated_health < 3, 1, 0
)
# Fit model with binary outcome
model_binary <- fit_maihda(
data = health_intersections,
outcome = "poor_health",
fixed_effects = c("race", "gender", "education", "age_group", "income"),
strata_var = "strata",
family = binomial()
)
# Calculate comprehensive diagnostics
diagnostics <- maihda_diagnostics(model_binary)
print(diagnostics)
# Generate report
maihda_report(model_binary, output_format = "html")MAIHDA builds on intersectionality theory (Crenshaw, 1989) and multilevel modeling to address key questions:
- Between-stratum variation: How much do health outcomes vary between different intersectional groups?
- Discriminatory accuracy: How well do social identities predict individual health outcomes?
- Interaction effects: Are intersectional effects more than the sum of their parts?
Key references:
- Evans, C. R., Leckie, G., Subramanian, S. V., Bell, A., & Merlo, J. (2024). A tutorial for conducting intersectional multilevel analysis of individual heterogeneity and discriminatory accuracy (MAIHDA). SSM β Population Health, 26, 101664.
- Merlo, J. (2018). Multilevel analysis of individual heterogeneity and discriminatory accuracy (MAIHDA) within an intersectional framework. Social Science & Medicine, 203, 74β80.
While multilevel models can be fit using existing packages like lme4, maihdaR provides:
- β Specialized functions designed specifically for intersectional analysis
- β Automated calculations of MAIHDA-specific metrics not readily available elsewhere
- β Consistent workflows that follow best practices from the MAIHDA literature
- β Built-in visualizations tailored for presenting intersectional findings
- β Helper functions for common data preparation tasks in intersectional analysis
- β Interpretive guides for understanding MAIHDA output in context
- Basic stratum creation
- Model fitting wrapper
- ICC calculation
- Basic visualization
- PCV and AUC calculations
- Comprehensive diagnostic functions
- Advanced plotting capabilities
- Vignettes with real-world examples
- Power calculation tools
- Model comparison functions
- Integration with tidyverse workflows
- Shiny app for interactive analysis
- Support for longitudinal MAIHDA
We welcome contributions! Please see our Contributing Guide for details on:
- Reporting bugs
- Suggesting enhancements
- Submitting pull requests
- Code of conduct
- π Package documentation: https://yiyang-gao-1.github.io/maihda-r-package/
- π Report issues: https://github.com/yiyang-gao-1/maihda-r-package/issues
- π¬ Discussion forum: https://github.com/yiyang-gao-1/maihda-r-package/discussions
- π§ Contact: y.gao@sheffield.ac.uk
If you use maihdaR in your research, please cite:
citation("maihdaR")Example (to be updated by your packageβs CITATION file at release):
To cite package 'maihdaR' in publications use:
Y Gao (2025). maihdaR: Multilevel Analysis of Individual
Heterogeneity and Discriminatory Accuracy. R package version 0.1.0.
https://github.com/yiyang-gao-1/maihda-r-package
A BibTeX entry for LaTeX users is
@Manual{,
title = {maihdaR: Multilevel Analysis of Individual Heterogeneity and Discriminatory Accuracy},
author = {Yiyang Gao},
year = {2025},
note = {R package version 0.1.0},
url = {https://github.com/yiyang-gao-1/maihda-r-package},
}
This project is licensed under the MIT License β see the LICENSE file for details.
- The MAIHDA methodology was developed by Clare R. Evans, Juan Merlo and colleagues
- This package builds upon the excellent
lme4package for multilevel modeling - Inspired by the growing community of intersectional health researchers
Package Status: This package is under active development. Features and interfaces may change. We encourage you to try it out and provide feedback!