Skip to content

08. Analyzers

Nao Yamamoto edited this page Oct 18, 2025 · 1 revision

Analyzers are modules that track simulation outcomes during runtime. They collect, aggregate, and store information about agents and their health, service use, intervention exposure, and social determinants over time — enabling detailed post-simulation analysis, plotting, and cost-effectiveness evaluation.

This page provides an overview of all currently implemented analyzers in MIGHTI, their core functionality, and example use cases.


Overview Table

Analyzer Name Tracks Stored Data Source File
DeathsByAgeSexAnalyzer Age- and sex-specific deaths - Deaths by age and sex- Cumulative infant deaths analyzer_core.py
SurvivorshipAnalyzer Survivorship by age and sex - Age-specific population counts (alive) analyzer_core.py
ConditionAtDeathAnalyzer Conditions present at death - Agent-level death records with condition flags analyzer_core.py
PrevalenceAnalyzer_HIV Disease prevalence by HIV - Prevalence by HIV status, age, sex analyzer_prevalence.py
PrevalenceAnalyzer_SDoH Disease prevalence by social determinants - Stratified prevalence by housing, education, etc. analyzer_prevalence.py
InterventionAnalyzer Intervention delivery - Yearly records of who received what analyzer_intervention.py
AdherenceAnalyzer Adherence behavior - Agent-level adherence state logs analyzer_intervention.py
HousingStabilityAnalyzer Housing exposure - % stably housed by year analyzer_intervention.py
HospitalizationAnalyzer Hospitalizations - Annual hospitalization counts (by sex/intervention) analyzer_serviceuse.py
OutpatientVisitAnalyzer (planned) Clinic visits and outpatient care - Outpatient visit counts (future) analyzer_serviceuse.py
PreventiveServiceAnalyzer (planned) Preventive services (e.g., screenings) - Service usage logs analyzer_serviceuse.py
MicrocostingAnalyzer Cost and YLDs - Total cost and YLD per agent- Condition-specific breakdowns analyzer_cost.py

Adding a New Analyzer

To implement a new analyzer:

  1. Subclass starsim.Analyzer
  2. Define init_results() to register output data structures.
  3. Override step() to collect data at each timestep.
  4. Optionally implement to_df() or custom summary/plot functions.

Integration

To use analyzers in a simulation:

analyzers = [
    mi.DeathsByAgeSexAnalyzer(),
    mi.SurvivorshipAnalyzer(),
    mi.ConditionAtDeathAnalyzer(conditions=['t2d', 'hiv']),
    mi.InterventionAnalyzer(),
]
sim = ss.Sim(..., analyzers=analyzers)

Clone this wiki locally