Overhaul severe and mortality outcomes#8
Conversation
…by current ft_sev estimates to ensure total inc is always plausible
|
|
||
| rates <- x |> | ||
| dplyr::select(dplyr::all_of(c("timestep", "ft", clinical_cols, severe_cols, denominator_cols))) |> | ||
| dplyr::select(dplyr::all_of(c("timestep", "ft", "ft_sev", clinical_cols, severe_cols, denominator_cols))) |> |
There was a problem hiding this comment.
How will the ft_sev be defined? I can see it gets set to 0.8 in the absence of other inputs, but would it be anticipated to be an output of malaria simulation? Or is it possible to input it as a parameter in get_rates (I may have misunderstood!)
There was a problem hiding this comment.
I suppose it means you can assign the proportion quite flexibly and through time, but it just means that it needs to be done actively before the get_rates function is called, right?
There was a problem hiding this comment.
Exactly, yes, the user can specify the ft_sev column prior to running get rates manual if they so wish, if not, it will default to the 0.8.
…n-downscaled) severe inc was lost, and simplified algebra
Co-authored-by: RJSheppard <73181123+RJSheppard@users.noreply.github.com>
Co-authored-by: RJSheppard <73181123+RJSheppard@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
===========================================
+ Coverage 98.37% 100.00% +1.62%
===========================================
Files 5 5
Lines 123 201 +78
===========================================
+ Hits 121 201 +80
+ Misses 2 0 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ionality-demonstration Expand rates vignette
Resolve DESCRIPTION conflict: keep R (>= 3.5) and add VignetteBuilder: knitr. Make the new severe-mortality vignette and the existing rates vignette (analysing_malaria_output) work together: - Add ggplot2 to Suggests. The PR enables VignetteBuilder, so the rates vignette is now actually built and needs ggplot2 (which it uses). - Cross-reference the two vignettes: the rates tutorial points to severe-mortality for the methodology, and severe-mortality points to the rates tutorial for a runnable end-to-end example. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Also update the matching test expectation so the ft warning assertion still passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Build-ignore .claude and AGENTS.md (non-package files). - Use the .data pronoun for `severe` in severe_incidence_mortality() to remove the "no visible binding for global variable" NOTE. R CMD check now passes with Status: OK (0 errors, 0 warnings, 0 notes), including re-building both vignettes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
P. vivax model output has no `n_inc_severe_...` columns, which previously caused get_rates() to error. Instead of erroring, when severe incidence columns are absent we now create them to match the clinical incidence age groups and fill with NA, emitting a warning that the severe, mortality and DALY (yld/yll/dalys) output columns will be NA as a result. - Replace the hard stop with a create-and-warn path. - Document the behaviour in get_rates(). - Replace the obsolete error test with a test asserting the warning and that severe/mortality/DALY columns come back NA while clinical is kept. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The severe-to-death scaler (0.215) in Griffin et al (2016) was estimated with the model run at an assumed baseline treatment coverage f0. Per the Griffin SI, severe incidence and mortality at coverage f1 are expressed relative to f0 by multiplying by ((1-chi)*f1 + (1-f1)) / ((1-chi)*f0 + (1-f0)), where chi is the treatment_scaler. The raw model severe output therefore represents severe incidence at f0, so dropping the denominator (as the branch previously did) left results inconsistent with the 0.215 calibration. - Re-introduce the f0 normaliser in severe_incidence_mortality(), hard-coded to a representative f0 = 0.1 (not exposed as an argument), with a comment citing the Griffin SI. This makes severe_hospital/mortality/yll match the main branch exactly under defaults. - Add a regression test locking in the f0 = 0.1 normalisation. - Fix the severe-mortality vignette: the treatment term inverted averted vs not-averted (using nu = 0.42 as the retained fraction rather than the averted proportion), giving s_m*(1-0.58*tx) instead of the correct s_m*(1-0.42*tx). Rewrite the formula to match the code and the Griffin SI, including the f0 baseline term and the 1/rho0 hospitalised->total gross-up. Note: yld/dalys still differ from main because YLD now weights total (hospital + community) severe rather than hospitalised-only - a separate, intentional DALY change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@ Latest changes on
|
|
closes #11 |
Coverage dropped from 98.4% to 88.2% on this branch, failing the codecov/project and codecov/patch checks. Restore it to 100%: - Delete R/age.R. Its fexp/cexp/ea/expected_age are dead duplicates of the integrand/ea/expected_age defined in R/dalys.R; since files load alphabetically, dalys.R overwrites ea/expected_age and age.R's fexp/cexp are never reachable. Regenerate docs to drop the orphaned fexp.Rd/cexp.Rd (ea/expected_age remain, documented from dalys.R). - Add tests for rates_aggregate() and prevalence_aggregate(). - Add get_rates() tests for the inferred-ft_sev warning and the mismatched clinical/severe age-group error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Aim: to make assumptions about severe treatment (hospitalisation) coverage and resulting probability of death more transparent and flexible.
The refactor replaces the hard‑wired Griffin‑2016 shortcut, where all malaria deaths were simply taken as 0.215 times the modelled incidence of hospital‑treated severe cases, with an explicit two‑stream calculation that first separates severe episodes into hospital and community compartments, then applies setting‑specific case‑fatality ratios to each stream. A new column, ft_sev, lets users supply (and vary over time) the proportion of severe cases that reach hospital. A warning‑backed default of 0.8 preserves backward compatibility - when this default is used the original 0.215 deaths‑to‑hospitalised‑cases ratio is recovered.
The flow is as follows:
ft_sevparameter that defines the proportion of severe cases that are hospitalised.The same treatment‑coverage multiplier that used to be applied is still applied to both severe streams before mortality is derived, making the algebra transparent and allowing referral improvements to be explored independently of first‑line treatment scale‑up.
Adding derivation of the 80% for reference
Let
mH = severe case fatality hospital: 0.065
mC= severe case fatality community: 0.6
λH= severe incidence hospital
λC= severe incidence community
ν = scaling factor linking hospitalised severe incidence to total malaria deaths: 0.215
Total deaths (predicted two ways) are:
Solving for the ratio of non‑hospitalised to hospitalised severe cases gives:

Coverage (ρ): the share of severe episodes treated in hospital, is therefore:

Which = 80%