chrissoria's picture
Add HuggingFace Spaces configuration to README
9f2c82b
metadata
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.