Skip to main content

A Categorical Framework for Modeling with Stock and Flow Diagrams

  • Chapter
  • First Online:
Mathematics of Public Health

Part of the book series: Fields Institute Communications ((FIC,volume 88))

  • 156 Accesses

Abstract

Stock and flow diagrams are already an important tool in epidemiology, but category theory lets us go further and treat these diagrams as mathematical entities in their own right. In this chapter we use communicable disease models created with our software, StockFlow.jl, to explain the benefits of the categorical approach. We first explain the category of stock-flow diagrams and note the clear separation between the syntax of these diagrams and their semantics, demonstrating three examples of semantics already implemented in the software: ODEs, causal loop diagrams, and system structure diagrams. We then turn to two methods for building large stock-flow diagrams from smaller ones in a modular fashion: composition and stratification. Finally, we introduce the open-source ModelCollab software for diagram-based collaborative modeling. The graphical user interface of this web-based software lets modelers take advantage of the ideas discussed here without any knowledge of their categorical foundations.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 119.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 159.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The code can also be found in the GitHub repository https://github.com/Xiaoyan-Li/applicationStockFlowMFPH.

References

  1. AlgebraicJulia: Bringing compositionality to technical computing. https://www.algebraicjulia.org

  2. Anderson, R.M., May, R.M.: Infectious Diseases of Humans: Dynamics and Control. Oxford University Press, Oxford (1992)

    Google Scholar 

  3. Andrieu, C., Doucet, A., Holenstein, R.: Particle Markov chain Monte Carlo methods. J. R. Stat. Soc. B (Statistical Methodology) 72(3), 269–342 (2010)

    Google Scholar 

  4. Arulampalam, M.S., Maskell, S., Gordon, N., Clapp, T.: A tutorial on particle filters for online nonlinear/non-Gaussian Bayesian tracking. IEEE Trans. Signal Process. 50(2), 174–188 (2002)

    Article  Google Scholar 

  5. Baez, J.C., Courser, K.: Structured cospans. Theor. Appl. Categ. 35(48), 1771–1822 (2020). arXiv:1911.04630

  6. Baez, J.C., Courser, K., Vasilakopoulou, C.: Structured versus decorated cospans. Compositionality 4(3) (2022). arXiv:2101.09363

  7. Baez, J.C., Li, X., Libkind, S., Osgood, n.d., Patterson, E.: Compositional modeling with stock and flow diagrams. To appear in Applied Category Theory 2022, Electronic Proceedings of Theoretical Computer Science (2022). arXiv:2205.08373

  8. ECMA-404: The JSON data interchange standard. https://www.json.org/json-en.html

  9. Fong, B.: Decorated cospans. Theor. Appl. Categ. 30(33), 1096–1120 (2015). arXiv:1502.00872

  10. Fong, B.: The Algebra of Open and Interconnected Systems. Ph.D. Thesis, Computer Science Department, University of Oxford (2016). arXiv:1609.05382

  11. Fong, B., Spivak, D.I.: Hypergraph categories (2018). arXiv:1305.0297

  12. Fong, B., Spivak, D.I.: An Invitation to Applied Category Theory: Seven Sketches in Compositionality. Cambridge University Press, Cambridge (2019)

    Book  Google Scholar 

  13. Gelb, A.: Applied Optimal Estimation. MIT Press, Cambridge (1974)

    Google Scholar 

  14. Hart, G.W.: Multidimensional Analysis: Algebras and Systems for Science and Engineering. Springer, Berlin (1995)

    Book  Google Scholar 

  15. Hovmand, P.S.: Community Based System Dynamics. Springer, Berlin (2014)

    Book  Google Scholar 

  16. Lawvere, F.W.: Functorial semantics of algebraic theories. Proc. Natl. Acad. Sci. 50(5), 869–872 (1963)

    Article  MathSciNet  Google Scholar 

  17. Leinster, T.: Basic Category Theory. Cambridge University Press, Cambridge (2014). arXiv:1612.09375

  18. Li, X., Doroshenko, A., Osgood, n.d.: Applying particle filtering in both aggregated and age-structured population compartmental models of pre-vaccination measles. PLoS ONE 13, e0206529 (2018)

    Google Scholar 

  19. Li, X., Keeler, B., Zahan, R., Duan, L., Safarishahrbijari, A., Goertzen, J., Tian, Y., Liu, J., Osgood, n.d.: Illuminating the hidden elements and future evolution of opioid abuse using dynamic modeling, big data and particle Markov chain Monte Carlo (2018)

    Google Scholar 

  20. Libkind, S., Baas, A., Halter, M., Patterson, E., Fairbanks, J.: An algebraic framework for structured epidemic modeling. Philos. Trans. R. Soc. A. 380(2233), 20210309 (2022). arXiv:2203.16345

  21. Libkind, S., Baas, A., Patterson, E., Fairbanks, J.: Operadic modeling of dynamical systems: mathematics and computation. EPTCS 372, 192–206 (2022). arXiv:2105.12282

  22. Meadows, N.: Hierarchical composition of stock & flow models. CEPHIL Technical Report (2022)

    Google Scholar 

  23. Osgood, N.: Representing progression and interactions of comorbidities in aggregate and individual-based systems models. In: Proceedings of the 27th International Conference of the System Dynamics Society. Albuquerque, New Mexico (2009)

    Google Scholar 

  24. Osgood, n.d., Eng, J.: Effective use of pmcmc for daily epidemiological monitoring and reporting: methodological lessons. Abstract & Conf. Publication, Ann. Meet. of the Statistical Society of Canada (2022)

    Google Scholar 

  25. Osgood, n.d., Liu, J.: Towards closed loop modeling: Evaluating the prospects for creating recurrently regrounded aggregate simulation models using particle filtering. In: Proceedings of the 2014 Winter Simulation Conference, WSC ’14, pp. 829–841. IEEE Press, Piscataway (2014)

    Google Scholar 

  26. Patterson, E., Lynch, O., Fairbanks, J.: Categorical data structures for technical computing. Compositionality 4(2) (2022). https://doi.org/10.32408/compositionality-4-5

  27. Qian, W., Osgood, n.d., Stanley, K.G.: Integrating epidemiological modeling and surveillance data feeds: a Kalman filter based approach. In: International Conference on Social Computing, Behavioral-Cultural Modeling, and Prediction, pp. 145–152. Springer, Berlin (2014). https://doi.org/10.1007/978-3-319-05579-4_18

  28. Safarishahrbijari, A., Teyhouee, A., Waldner, C., Liu, J., Osgood, n.d.: Predictive accuracy of particle filtering in dynamic models supporting outbreak projections. BMC Infect. Dis. 17(1), 1–12 (2017)

    Google Scholar 

  29. Spivak, D.I.: The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits (2013). arXiv:1305.0297

  30. Spivak, D.I.: Category Theory for the Sciences. MIT Press, Cambridge (2014). Preliminary version. arXiv:1302.6946

  31. Sterman, J.D.: Business Dynamics. McGraw-Hill, New York (2000)

    Google Scholar 

  32. Stockflow.jl. https://github.com/AlgebraicJulia/StockFlow.jl

Download references

Acknowledgements

We gratefully acknowledge the extensive insights, comments, and feedback from Evan Patterson of the Topos Institute. Co-author Osgood wishes to express his appreciation of support via NSERC via the Discovery Grants program (RGPIN 2017-04647), from the Mathematics for Public Health Network, and from SYK & XZO.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Xiaoyan Li .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Baez, J.C., Li, X., Libkind, S., Osgood, N.D., Redekopp, E. (2023). A Categorical Framework for Modeling with Stock and Flow Diagrams. In: David, J., Wu, J. (eds) Mathematics of Public Health. Fields Institute Communications, vol 88. Springer, Cham. https://doi.org/10.1007/978-3-031-40805-2_8

Download citation

Publish with us

Policies and ethics