A primary objective of the Hospital-TTD-Mod is to evaluate the distributional impacts of the intervention.
To achieve this, the model explicitly tracks and dynamically adjusts probabilities for every patient profile across defined demographic strata:
Age group (mapped internally to young, older, and retirement age categories)
Sex
Index of Multiple Deprivation (IMD) quintiles
8.0.1 Configuring equity gradients (user inputs)
Handling multiple overlapping demographics can often lead to a combinatorial explosion of data entry for users (e.g., having to manually type in a separate screening probability for young deprived males, older wealthy females, etc.).
To keep the model highly intuitive for new users and stakeholders, users define the overall baseline averages for their service in the main scenarios_control_panel.csv, and then apply specific “Relative Risk” modifiers in a secondary file called equity_multipliers_panel.csv.
The equity control panel is structured in a wide format, allowing users to define equity modifiers that either apply to the whole model, or change dynamically across different scenarios (for example, if testing a targeted intervention designed to close an inequality gap).
Example user input structure:
Parameter_Name
Demographic_Variable
Level
Basecase
Targeted_IMD_Intervention
pr_screened
age_group
16-24
1.00
1.00
pr_seen_by_adviser
imd_quintile
5_most_deprived
0.85
1.15
quit_rate_4w_csss
sex
female
1.05
1.05
How it works:
Targeted modifiers: A user specifies a parameter (e.g., pr_seen_by_adviser), a demographic variable (imd_quintile), and the specific group level (5_most_deprived).
Relative multipliers: The user inputs a multiplier. A value of 0.85 means this specific group is 15% less likely to achieve the baseline rate. A value of 1.15 means they are 15% more likely.
Defaults: If a user leaves a cell blank, or if a specific demographic group (like IMD 1) is not listed in the file, the model safely defaults to a multiplier of 1.0 (meaning no equity penalty is applied).
Scenario side-by-sides: In the example above, the user has modelled a scenario where deprived groups historically have poorer uptake (Basecase = 0.85), but tests an alternate scenario where extra community resources boost their engagement (Targeted_IMD_Intervention = 1.15).
8.0.2 Unstratified modeling
The model architecture includes a graceful fallback mechanism for standard, unstratified “average cohort” simulations. To run the model without equity adjustments, users can simply clear the data rows beneath the headers in equity_multipliers_panel.csv or leave the scenario multiplier cells blank. The engine recognizes the empty inputs, bypasses the equity loop, and safely defaults all demographic modifiers to 1.0. Note: The .csv file itself must remain in the user_inputs/ directory; deleting it will cause the initialization script to auto-generate a fresh template with illustrative penalties.
8.0.3 The internal matrix engine
The model protects users from the mathematical complexity of overlapping multipliers. When the 00_build_scenarios.R script executes, it takes the baseline rates and the equity multipliers and automatically generates a fully-crossed, multi-dimensional probability matrix (spanning hundreds of possible patient combinations).
The internal model enforces strict mathematical ceiling rules—ensuring that stacked multipliers (e.g., being young and female) never push an event probability above 100% or below 0%. This matrix is then seamlessly joined to the patient cohort, applying exact, equity-adjusted probabilities to every individual passing through the clinical pathway.
8.0.4 Evaluating subgroup economics
Because every simulated patient retains their demographic markers throughout the simulation, the final outputs can be cleanly stratified.
The build_subgroup_economics.R script dynamically aggregates the net quits generated by the clinical pathway model and aligns them with the long-term admissions prevented and costs saved from the epidemiological model: