title: Partisan Epidemic Simulator
emoji: π¦
colorFrom: blue
colorTo: red
sdk: docker
pinned: false
Partisan Epidemic Simulator
An interactive Shiny application for simulating and visualizing how partisan differences in health behaviors affect epidemic outcomes using a three-party SIR (Susceptible-Infected-Recovered) model.
Overview
This simulator models how differences in protective behaviors (e.g., mask-wearing, social distancing, vaccination) between Republicans, Democrats, and Independents can influence the spread and outcomes of an epidemic. The model incorporates:
- Partisan-specific contact rates: Different average contact rates for each political group
- Protective behavior adoption: Varying rates of adopting protective measures
- Responsiveness to deaths: How groups adjust behavior based on mortality
- Vaccination uptake: Differential vaccination rates across groups
- Contact homophily: The tendency for individuals to interact more with those of similar political affiliation
Features
- Interactive parameter adjustment via sliders and inputs
- Multiple visualization options:
- Prevalence (proportion infected over time)
- Incidence (new cases over time)
- Mortality outcomes
- Contact patterns
- Population composition sensitivity analysis
- Homophily sensitivity analysis
- Multi-panel SIR compartment plots
- Preset scenarios for different US locales (Berkeley, Philadelphia, Seattle, Wyoming, etc.)
- Counterfactual comparisons (null model, cautious behavior scenarios)
- AI-powered chat assistant to explain model parameters and results
- Downloadable plots and simulation data
Live Demo
The app is deployed on HuggingFace Spaces: https://huggingface.co/spaces/chrissoria/partisan-epidemic-simulator
Running Locally
Prerequisites
- R (>= 4.0)
- Required R packages:
install.packages(c( "shiny", "shinyjs", "shinyalert", "shinyWidgets", "ggplot2", "ggstream", "dplyr", "cowplot", "reshape2", "httr", "jsonlite", "deSolve", "MESS", "gridExtra" ))
Running the App
# From RStudio or R console
rmarkdown::run("app.Rmd")
Project Structure
.
βββ app.Rmd # Main Shiny application
βββ R/
β βββ data_processing.R # Data processing functions
β βββ models.R # Model runner functions
β βββ plot_utils.R # Plotting utilities
β βββ sir_model.R # Core SIR model implementation
β βββ plots/ # Individual plot functions
β βββ plot_prevalence.R
β βββ plot_incidence.R
β βββ plot_mortality.R
β βββ plot_contacts.R
β βββ plot_homophily.R
β βββ plot_panels.R
β βββ plot_population.R
β βββ plot_sensitivity.R
β βββ plot_sir_combined.R
βββ hf_space/ # HuggingFace Spaces deployment files
Authors
Chris Soria (Lead Developer & Corresponding Author) Email: chrissoria@berkeley.edu
Contributors: Audrey DorΓ©lien, Ayesha Mahmud, Dennis Feehan
License
This project is part of ongoing research. Please contact the authors for usage permissions.