Code from: Epidemic dynamics under variable compliance with interventions
Data files
May 27, 2026 version files 110.02 KB
-
01_generate_parameter_set.R
1.44 KB
-
data_for_fig4_and_fig5.R
5.71 KB
-
data_for_fig6_and_figSI2.R
9.71 KB
-
data_for_fig7.R
2.22 KB
-
data_for_fig8.R
3.38 KB
-
data_for_figSI3.R
5.22 KB
-
data_for_figSI4.R
5.16 KB
-
data_for_figSI5.R
3.34 KB
-
data_for_figSI6.R
3.69 KB
-
data_for_figSI7.R
4.78 KB
-
Fig_2.R
1.11 KB
-
Fig_3.R
6.17 KB
-
Fig_4.R
1.86 KB
-
Fig_5.R
3.44 KB
-
Fig_6.R
5.39 KB
-
Fig_7.R
3.46 KB
-
Fig_8.R
1.80 KB
-
Fig_SI_1.R
2.87 KB
-
Fig_SI_2.R
3.74 KB
-
Fig_SI_3.R
3.10 KB
-
Fig_SI_4.R
2.94 KB
-
Fig_SI_5.R
1.36 KB
-
Fig_SI_6.R
2.41 KB
-
Fig_SI_7.R
3.42 KB
-
helper_functions.R
4.48 KB
-
model.R
7.36 KB
-
README.md
10.48 KB
Abstract
Behavioral non-pharmaceutical interventions, such as mask-wearing and social distancing, can reduce the spread of infectious diseases, although not all members of a population may comply with public policies.
We developed a compartmental model to understand the spread of an infectious disease within a population comprising compliant and non-compliant groups. The model takes into account various behavioral factors influencing flows between compliant and non-compliant groups, such as peer pressure, risk perception or fear of infection, and severity of the policy. The coupled social-disease system under various social mechanisms exhibits distinct disease dynamics, revealing the important role of social mechanisms in controlling disease spread in a mixed population. Further, our results show that social mechanisms and the initial state of the population affect the time delay before outbreaks occur and peak prevalence. Our findings emphasize that dynamic social factors may significantly affect outbreaks and we suggest that models incorporating coupled social mechanisms warrant further investigation.
PIPP Demonstration Project 4
Interdisciplinary team leads:
John Drake & Bogdan Epureanu
Contributors
Pej Rohani
Sukanta Sarkar
Amin Ghadami
Eric Marty
Abstract
DP4 contributes to the grand challenge of heterogeneous model integration by advancing mathematical theory of pathogen transmission through formally codifying the role of human social behaviors and responses. The proposed model accounts for the effect of policy on policy compliant and non-compliant individuals’ choices.
Background. There is ample anecdotal evidence that during the COVID-19 pandemic in the US individual decisions about mask-wearing and vaccination were highly politicised based on agreement with particularly visible spokespeople. Due to the two-party political system of the US and the election year, the tendency to affiliate was probably greater than normal. A transmission model may classify all individuals in the population as either compliant or non-compliant with policies such as shelter-in-place, mask-wearing, or vaccination to explore long-term dynamics and identify “social tipping points” in infectious disease transmission, i.e. conditions under which a combination of interventions, including public messaging, may lead to either rapid containment or a major outbreak (Phillips et al. 2020). In keeping with the epidemiology of influenza, we further assume that individuals are either Susceptible ($S$), Infectious ($I$), or Recovered and immune ($R$), although this model may be generalized to consider latent or asymptomatic infections, loss of immunity, age structure, vaccination, vaccine efficacy, etc. In our model, agency is reflected in the fact that the force of infection on compliant and non-compliant individuals is different. Moreover, agents may convert between compliance states. Our model differs from the standard approach in that we also express a state variable ($0 ≤ P ≤ 1$) that expresses the severity of Policy, e.g. lockdowns are more severe than gathering bans which are more severe than mask-wearing mandates. Importantly, key rates such as the force of infection and conversion are dependent both on information that may be available to the agents (e.g., the number of infected individuals and deaths in the population, which are related to case and death reports in news broadcasts) and the policy.
Expected outcomes include characterizing the transient and long-term behavior of HPAI dynamics in response to variation in human response to outbreaks and to outbreak-related interventions. In particular, we will investigate recently proposed early warning signals that appear in the vicinity of such dynamic bifurcations (O’Regan et al. 2013, Brett et al. 2017, Miller et al. 2017, Brett et al. 2018, O’Dea & Drake 2019). Beyond the HPAI system, this project will mathematically formalize the role of human social behaviors to advance transmission theory more generally.
Manuscript
Sukanta Sarkar, Éric Marty, Pejman Rohani, John M. Drake. 2025. “Epidemic dynamics under variable compliance with interventions.”
Manuscript data and figures
Figures
Figure 1 in the manuscript is an illustration of the model created with design software. There is no code for Figure 1.
The files R/Fig_*.R recreate figures 2-8 in the manuscript and all figures in the supplemental materials. Each can be run independently using data files stored with this repo. If the data are missing and need to be recreated, this can be done using the data generation scripts in the next subsection.
01_generate_parameter_set.R can be run independently, and generates the file data/params_set.rds
R/Fig_2.R can be run independently, and generates the file Fig_2.pdf.
R/Fig_3.R can be run independently, and generates the file Fig_3.pdf.
R/Fig_4.R can be run independently, and generates the file Fig_4.pdf. This file relies on data file data/metrics_equalSn_Sc_lhs1000.rds, which can be generated by running the file R/data_for_fig4_and_fig5.R.
R/Fig_5.R can be run independently, and generates the file Fig_5.pdf. This file relies on data file data/data_fig5_equalSn_Sc_lhs1000.rds, which can be generated by running the file R/data_for_fig4_and_fig5.R.
R/Fig_6.R can be run independently, and generates the file Fig_6.pdf. This file relies on data file data/data_fig6_P04_lhs1000.rds, which can be generated by running the file R/data_for_fig6_and_figSI2.R.
R/Fig_7.R can be run independently, and generates the file Fig_7.pdf. This file relies on data file data/outbreak_size_P06_alpha_lhs1000_Sc0_lhs1000.rds, which can be generated by running the file R/data_for_fig7.R.
R/Fig_8.R can be run independently, and generates the file Fig_8.pdf. This file relies on data file data/prcc_P06_alpha_lhs1000.rds, which can be generated by running the file R/data_for_fig8.R.
R/Fig_SI_1.R can be run independently, and generates the file SI_Fig_1.pdf.
R/Fig_SI_2.R can be run independently, and generates the file SI_Fig_2.pdf. This file relies on data file data/data_figSI2_P04_lhs1000.rds, which can be generated by running the file R/data_for_fig6_and_figSI2.R.
R/Fig_SI_3.R can be run independently, and generates the file SI_Fig_3.pdf. This file relies on data file data/data_figSI3_P0_lhs1000.rds, which can be generated by running the file R/data_for_figSI3.R.
R/Fig_SI_4.R can be run independently, and generates the file SI_Fig_4.pdf. This file relies on data file data/data_figSI4_alpha_lhs1000_P_lhs1000.rds, which can be generated by running the file R/data_for_figSI4.R.
R/Fig_SI_5.R can be run independently, and generates the file SI_Fig_5.pdf. This file relies on data files data/metrics_notional_alpha.rds and data/data_figSI5.rds, which can be generated by running the file R/data_for_figSI5.R.
R/Fig_SI_6.R can be run independently, and generates the file SI_Fig_6.pdf. This file relies on data file data/metrics_varying_phi_notional_alpha.rds, which can be generated by running the file R/data_for_figSI6.R.
R/Fig_SI_7.R can be run independently, and generates the file SI_Fig_7.pdf. This file relies on data file data/data_figSI7_varying_phi_alpha_lhs50.rds, which can be generated by running the file R/data_for_figSI7.R.
Data
WARNING: recreating all the data is time consuming and should be done on a linux or MacOS machine with multiple cores to take advantage of parallel processing. For example, running R/data_for_fig4_and_fig5.R may take over 5 hours using 35 cores.
The file R/helper_functions.R contains helper functions called by other scripts. This file is called by model.R.
The file R/model.R contains functions for the model, rates, and parameters, as well functions for various metrics of this model including reproductive numbers, extinction times (outbreak duration), peak prevalence, and outbreak size, called by other scripts. This file is called by the data creation scripts and figure creation scripts below.
The file R/data_for_fig4_and_fig5.R runs the model for all 79 values of policy strength p defined in model.R and a Latin hypercube sample of 18 alpha parameters (n = 1000). Creates one file for each policy level p: data/simulations_equalSn_Sc_P*_lhs1000.rds where “*” is the policy level (without the decimal place). Example: policy level p = 0.2 gives data/my_data_equalSn_Sc_P02_lhs1000.rds. This file then computes summaries of the simulation data used in figures 4 and 5. It also extracts subsets of the simulation trajectories for plotting in fig 5. The data files needed for fig 4 and 5 are data/metrics_equalSn_Sc_lhs1000.rds and data/data_fig5_equalSn_Sc_lhs1000.rds, respectively.
The remaining files R/data*.R follow the same pattern as above. Each data script may create intermediate data files (which are not retained in this repository) that are in turn used to generate the data files required by the figure generation files.
Notes
To run the scripts in this workflow, it is recommended to organize the project into the following subdirectories:
/data— all data files (.rds)/R— all R scripts (.R)
The file data/params_set.rds is not included in the repository because it is generated programmatically. It is produced by running R/01_generate_parameter_set.R, which writes the parameter set to data/params_set.rds. This script must therefore be run before R/data_for_fig4_and_fig5.R, which depends on that file as an input.
References
Phillips, B., Anand, M. & Bauch, C. T. Spatial early warning signals of social and epidemiological tipping points in a coupled behaviour-disease network. Sci. Rep. 10, 7611 (2020).
Poovorawan, Y., Pyungporn, S., Prachayangprecha, S. & Makkoch, J. Global alert to avian influenza virus infection: from H5N1 to H7N9. Pathog. Glob. Health 107, 217–223 (2013).
Epstein, J. M., Hatna, E. & Crodelle, J. Triple contagion: a two-fears epidemic model. J. R. Soc. Interface 18, 20210186 (2021).
Epstein, J. M., Parker, J., Cummings, D. & Hammond, R. A. Coupled contagion dynamics of fear and disease: mathematical and computational explorations. PLoS One 3, e3955 (2008).
Bedson, J. et al. A review and agenda for integrated disease models including social and behavioural factors. Nat Hum Behav 5, 834–846 (2021).
Funk, S., Salathé, M. & Jansen, V. A. A. Modelling the influence of human behaviour on the spread of infectious diseases: a review. J. R. Soc. Interface 7, 1247–1256 (2010).
O’Regan, S. M. & Drake, J. M. Theory of early warning signals of disease emergence and leading indicators of elimination. Theor. Ecol. 6, 333–357 (2013).
Brett, T. S., Drake, J. M. & Rohani, P. Anticipating the emergence of infectious diseases. J. R. Soc. Interface 14, (2017).
Miller, P. B., O’Dea, E. B., Rohani, P. & Drake, J. M. Forecasting infectious disease emergence subject to seasonal forcing. Theor. Biol. Med. Model. 14, 17 (2017).
Brett, T. S. et al. Anticipating epidemic transitions with imperfect data. PLoS Comput. Biol. 14, e1006204 (2018).
O’Dea, E. B. & Drake, J. M. Disentangling reporting and disease transmission. Theor. Ecol. 12, 89–98 (2019).
Chen, S., O’Dea, E. B., Drake, J. M. & Epureanu, B. I. Eigenvalues of the covariance matrix as early warning signals for critical transitions in ecological systems. Sci. Rep. 9, 2572 (2019).
In a pending application, we have proposed to study the dynamics of this model under time- varying transmission. As a demonstration project in the current proposal, we will link this model to information to be collected under DP3 to empirically parameterize the model for application to a pandemic of influenza. Most importantly, we hypothesize that there will be local tipping points resulting from the intrinsic dynamics of this model. Our idea is that an epidemic will begin due to supercritical transmission under the baseline compliance. But, because HPAI is a highly lethal infection (Poovorawan et al. 2013) we expect the ensuing “epidemic of fear” (Epstein et al 2020, Epstein et al 2008, Bedson et al. 2021, Funk et al. 2010) to result in rapid changes in compliant behavior as the number of infections (or deaths) accumulate in a local population. Importantly, the effectiveness of this behavior change will depend on the relative speed at which behavior change occurs and the incubation period of the infection. Under conditions where behavior change is sufficient the effective reproduction number will drop below one, resulting in temporary containment. Of course, relaxed compliance may cause the system to switch to a supercritical situation again, yielding multi-wave epidemics as we have also seen with COVID-19.
