Microsimulation Modeling for Health Decision Sciences Using C++: A Tutorial.

Saved in:
Bibliographic Details
Title: Microsimulation Modeling for Health Decision Sciences Using C++: A Tutorial.
Authors: Lehtimäki AV; School of Pharmacy, Faculty of Health Sciences, Kuopio Campus, University of Eastern Finland, 70211, Kuopio, Finland. aku-ville.lehtimaki@uef.fi., Martikainen J; School of Pharmacy, Faculty of Health Sciences, Kuopio Campus, University of Eastern Finland, 70211, Kuopio, Finland.
Source: PharmacoEconomics [Pharmacoeconomics] 2026 Apr; Vol. 44 (4), pp. 379-387. Date of Electronic Publication: 2025 Jul 26.
Publication Type: Journal Article; Review
Language: English
Journal Info: Publisher: Adis, Springer International Country of Publication: New Zealand NLM ID: 9212404 Publication Model: Print-Electronic Cited Medium: Internet ISSN: 1179-2027 (Electronic) Linking ISSN: 11707690 NLM ISO Abbreviation: Pharmacoeconomics Subsets: MEDLINE
Imprint Name(s): Publication: Auckland : Adis, Springer International
Original Publication: Auckland ; Philadelphia : Adis International, c1992-
MeSH Terms: Computer Simulation* , Decision Support Techniques* , Programming Languages* , Software*, Humans ; Markov Chains
Abstract: Microsimulation models have become increasingly common in the field of decision modeling for health. Because microsimulation models are computationally more demanding than traditional Markov cohort models, the use of computer programming languages in their development has become more common. C++ is a programming language that has gained widespread recognition in computationally intensive fields, including systems modeling and performance-critical applications. It offers powerful tools for building high-performance microsimulation models, outpacing many traditional modeling software solutions, such as native R, in terms of speed and control over memory management. However, there is limited accessible guidance for implementing microsimulation models in C++. This tutorial offers a step-by-step approach to constructing microsimulation models in C++ and demonstrates its application through simplified but adaptable example decision models. We walk the reader through essential steps and provide generic C++ code that is flexible and suitable for adapting to a range of models. Finally, we present the standalone C++ models and their Rcpp counterparts run within R, and compare their performance to equivalent R implementations in terms of speed and memory efficiency.
(© 2025. The Author(s).)
Competing Interests: Declarations. Funding: Open access funding provided by University of Eastern Finland (including Kuopio University Hospital). Author contributions: A.V.L.: Conceptualization, methodology, software development, validation, formal analysis, investigation, data curation, writing—original draft preparation, writing—review and editing, and visualization. J.M.: Conceptualization, methodology, validation, writing—review and editing, and supervision. Conflict of interest: A.V.L. declares no competing interests. J.M. is a founding partner of ESiOR Oy. This company was not involved in carrying out this research. Data availability: The datasets generated and analyzed during the current study are not publicly deposited due to their synthetic nature as tutorial examples. However, all source code, implementation examples, and scripts used to generate the performance comparisons are available as Online Supplementary Material. Ethics approval: Not applicable. Consent to participate / for publication: Not applicable.
References: Caro JJ, Briggs AH, Siebert U, Kuntz KM. Modeling good research practices—overview: a report of the ISPOR-SMDM modeling good research practices task force–1. Value Health. 2012;15(6):796–803. (PMID: 10.1016/j.jval.2012.06.01222999128)
Standfield L, Comans T, Scuffham P. Markov modeling and discrete event simulation in health care: a systematic comparison. Int J Technol Assess Health Care. 2014;30(2):165–72. (PMID: 10.1017/S026646231400011724774101)
Rutter CM, Zaslavsky AM, Feuer EJ. Dynamic microsimulation models for health outcomes: a review. Med Decis Mak. 2011;31(1):10–8. (PMID: 10.1177/0272989X10369005)
Siebert U, Alagoz O, Bayoumi AM, Jahn B, Owens DK, Cohen DJ, Kuntz KM. State-transition modeling: a report of the ISPOR-SMDM modeling good research practices task force-3. Value Health. 2012;15(6):812–20. https://doi.org/10.1016/j.jval.2012.06.014 . (PMID: 10.1016/j.jval.2012.06.01422999130)
Kim D, Wang L, Lauren B, Liu J, Marklund M, Lee Y, Micha R, Mozaffarian D, Wong J. Development and validation of the US diabetes, obesity, cardiovascular disease microsimulation (DOC-M) model: health disparity and economic impact model. Med Decis Mak. 2023;43:930–48. https://doi.org/10.1177/0272989X231196916 . (PMID: 10.1177/0272989X231196916)
Kazemian P, Costantini S, Neilan A, Resch S, Walensky R, Weinstein M, Freedberg K. A novel method to estimate the indirect community benefit of HIV interventions using a microsimulation model of HIV disease. J Biomed Inform. 2020. https://doi.org/10.1016/j.jbi.2020.103475 . (PMID: 10.1016/j.jbi.2020.103475325262807374016)
Wu R, Williams C, Zhou J, Schlackow I, Emberson J, Reith C, Keech A, Robson J, Armitage J, Gray A, Simes J, Baigent C, Mihaylova B. Long-term cardiovascular risks and statin treatment impact on socioeconomic inequalities: microsimulation model. Br J Gen Pract. 2023. https://doi.org/10.3399/bjgp.2023.0198 . (PMID: 10.3399/bjgp.2023.0198)
Rasella D, Richiardi L, Brachowicz N, Jara H, Hanson M, Boccia D, Richiardi M, Pizzi C. Developing an integrated microsimulation model for the impact of fiscal policies on child health in Europe: the example of childhood obesity in Italy. BMC Med. 2021. https://doi.org/10.1186/s12916-021-02155-6 . (PMID: 10.1186/s12916-021-02155-6348445968629597)
Katikireddi S, Kopasker D, Pearce A, Leyland A, Rostila M, Richiardi M. Health equity and its economic determinants (HEED): protocol for a pan-European microsimulation model for health impacts of income and social security policies. BMJ Open. 2022;12: e062405. https://doi.org/10.1136/bmjopen-2022-062405 . (PMID: 10.1136/bmjopen-2022-0624059301818)
Günal MM, Pidd M. Discrete event simulation for performance modelling in health care: a review of the literature. J Simul. 2010;4(1):42–51. (PMID: 10.1057/jos.2009.25)
Jackson CH. Multi-state models for panel data: the msm package for R. J Stat Softw. 2011;38(8):1–29. (PMID: 10.18637/jss.v038.i08)
Filipović-Pierucci A, Zarca K, Durand-Zaleski I. Markov models for health economic evaluation: the R package heemod [Preprint]. 2017. arXiv:1702.03252.
Incerti D, Jansen JP. hesim: health economic simulation modeling and decision analysis. 2021. arXiv:2102.09437.
Clements M, Jauhiainen A, Karlsson A. microsimulation: discrete event simulation in R and C++, with tools for cost-effectiveness analysis (R package version 1.4.4). 2024. https://CRAN.R-project.org/package=microsimulation .
Enns EA, Cipriano LE, Simons CT, Kong CY. Identifying best-fitting inputs in health-economic model calibration: a Pareto frontier approach. Med Decis Mak. 2015;35(2):170–82. (PMID: 10.1177/0272989X14528382)
Krijkamp EM, Alarid-Escudero F, Enns EA, Jalal HJ, Hunink MM, Pechlivanoglou P. Microsimulation modeling for health decision sciences using R: a tutorial. Med Decis Mak. 2018;38(3):400–22. https://doi.org/10.1177/0272989X18754513 . (PMID: 10.1177/0272989X18754513)
Matsumoto M, Nishimura T. Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator. ACM Trans Model Comput Simul. 1998;8(1):3–30. https://doi.org/10.1145/272991.272995 . (PMID: 10.1145/272991.272995)
Eddelbuettel D, Francois R, Allaire J, Ushey K, Kou Q, Russell N, Ucar I, Bates D, Chambers J. Rcpp: seamless R and C++ integration (R package version 1.0.11). 2023. https://CRAN.R-project.org/package=Rcpp .
Hester J, Vaughan D. bench: high precision timing of R expressions (R package version 1.1.3). 2023. https://CRAN.R-project.org/package=bench .
OpenMP Architecture Review Board. OpenMP application programming interface version 5.2. 2021. https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5-2.pdf .
Flynn MJ. Some computer organizations and their effectiveness. IEEE Trans Comput. 1972;C–21(9):948–60. https://doi.org/10.1109/TC.1972.5009071 . (PMID: 10.1109/TC.1972.5009071)
Mytton OT, Jackson C, Steinacher A, Goodman A, Langenberg C, Griffin S, Wareham N, Woodcock J. The current and potential health benefits of the National Health Service Health Check cardiovascular disease prevention programme in England: a microsimulation study. PLoS Med. 2018;15(3):1–32. https://doi.org/10.1371/journal.pmed.1002517 . (PMID: 10.1371/journal.pmed.1002517)
Kypridemos C, Collins B, McHale P, Bromley H, Parvulescu P, Capewell S, O’Flaherty M. Future cost-effectiveness and equity of the NHS Health Check cardiovascular disease prevention programme: Microsimulation modelling using data from Liverpool, UK. PLOS Med. 2018;15(5):1–20. https://doi.org/10.1371/journal.pmed.1002573 . (PMID: 10.1371/journal.pmed.1002573)
Lustig N, Martinez Pabon V, Sanz F, Younger SD. The impact of COVID-19 on living standards: addressing the challenges of nowcasting unprecedented macroeconomic shocks with scant data and uncharted economic behavior. Int J Microsimul. 2023;16(1):1–27. https://doi.org/10.34196/ijm.00273 . (PMID: 10.34196/ijm.00273)
Guennebaud G, Jacob B et al. Eigen v3. 2024. https://eigen.tuxfamily.org/ .
Sanderson C, Curtin R. Armadillo: a template-based C++ library for linear algebra. J Open Source Softw. 2016;1(2):26. https://doi.org/10.21105/joss.00026 . (PMID: 10.21105/joss.00026)
Eom H, Li Y. Developing high-quality microsimulation models using R in health decision sciences. In: 2020 Winter simulation conference (WSC). 2020. p. 1167–77. https://doi.org/10.1109/WSC48552.2020.9384037 .
Stroustrup B, Sutter H. C++ core guidelines. 2025. https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines .
Smith RA, Samyshkin Y, Mohammed W, Lamrock F, Ward T, Smith J, Martin A, Schneider P, Lee D, Baio G, Thom H, Green N, Richardson M, El Alili M, Pouwels X, Deniz B. assertHE: an R package to improve quality assurance of HTA models [version 1; peer review: awaiting peer review]. Wellcome Open Res. 2024;9:701. (PMID: 10.12688/wellcomeopenres.23180.1)
Entry Date(s): Date Created: 20250727 Date Completed: 20260324 Latest Revision: 20260327
Update Code: 20260403
PubMed Central ID: PMC13013250
DOI: 10.1007/s40273-025-01526-8
PMID: 40715941
Database: MEDLINE
Description
Abstract:Microsimulation models have become increasingly common in the field of decision modeling for health. Because microsimulation models are computationally more demanding than traditional Markov cohort models, the use of computer programming languages in their development has become more common. C++ is a programming language that has gained widespread recognition in computationally intensive fields, including systems modeling and performance-critical applications. It offers powerful tools for building high-performance microsimulation models, outpacing many traditional modeling software solutions, such as native R, in terms of speed and control over memory management. However, there is limited accessible guidance for implementing microsimulation models in C++. This tutorial offers a step-by-step approach to constructing microsimulation models in C++ and demonstrates its application through simplified but adaptable example decision models. We walk the reader through essential steps and provide generic C++ code that is flexible and suitable for adapting to a range of models. Finally, we present the standalone C++ models and their Rcpp counterparts run within R, and compare their performance to equivalent R implementations in terms of speed and memory efficiency.<br /> (© 2025. The Author(s).)
ISSN:1179-2027
DOI:10.1007/s40273-025-01526-8