An interactive two-group SI model that shows how contact rates and assortative mixing generate, and fail to sustain, disparities in infection between groups. It is a teaching companion to concurrency.sim and part of the EpiModel ecosystem.
Available at: https://epimodel.github.io/mixing.sim/
The population is split into two groups, each with its own contact rate, and the mixing statistic Q sets how many contacts stay within the group (0 is proportional mixing, 1 is fully assortative, below 0 is disassortative). The app reports prevalence and the incidence rate per 100 person-time for each group, along with the mixing matrix implied by the settings. The central lesson: assortative mixing alone cannot sustain a pre-existing disparity between groups that otherwise behave alike, but combined with a real difference between the groups it keeps their epidemics apart and makes the disparity larger.
This is a rebuild of the 2017 Shiny app Impact of Assortative Mixing on HIV Prevalence and Incidence among MSM by Kevin M. Weiss, Maraia R. Tremarelli, Samuel M. Jenness, and Steven M. Goodreau (statnet/MSMmix), which ran on shinyapps.io. The model is unchanged and reproduces the original results. Differences from the original:
- It is a static page with no server and no dependencies, so it loads instantly in any browser and also works when
index.htmlis opened from disk. - Incidence is reported as the force of infection per 100 person-time at risk. The original plotted the per-step flow at a step size of 0.1, which was one tenth of the rate.
- Q can be set below 0, down to the lowest value the contact rates and group sizes allow.
- The original assigned Group 2's initial infections using Group 1's population size; this is fixed.
- The results table shows the mixing matrix and recovers Q from it, and Copy link saves the settings in the URL.
model.js: the model (ODEs, mixing matrix, fixed-step RK4 solver)app.js,index.html,style.css: the interfacetests/model.test.js: checks the model against the original app's results (node tests/model.test.js)tests/reference.R: regenerates those reference values with EpiModel
Pushing to main runs the tests and deploys to GitHub Pages.
GPL-3, consistent with the EpiModel ecosystem.