Skip to content

Add impact diagnostics functions#17

Merged
pratikunterwegs merged 34 commits into
mainfrom
dev-zoe
Jul 21, 2026
Merged

Add impact diagnostics functions#17
pratikunterwegs merged 34 commits into
mainfrom
dev-zoe

Conversation

@pratikunterwegs

@pratikunterwegs pratikunterwegs commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This PR replaces #15. Since this branch contains an earlier merge commit (from develop) it cannot be rebased and will be squash-merged.

PR desc copied over:

This PR adds additional functions from [https://github.com/vimc/montagu-reports/tree/main/src/rapid-model-run-impact] a key report for the VIMC Science & Policy team. Functions added generate central estimate impact plots and coverage and fvp plots per year, country and view. First attempt at ensuring functions are package-ready/ utilising roxygen etc. so any comment welcome.

@pratikunterwegs
pratikunterwegs marked this pull request as ready for review July 9, 2026 14:37
Comment thread R/fn_plotting_impact.R Outdated
Comment thread R/fn_plotting_impact.R
Comment thread R/fn_plotting_impact.R
#' @export
plot_impact <- function(
data,
country = PINE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will fail for certain diseases. Although we use PINE as a default for a quick glace at estimates instead of running every country, there will not be some diseases in PINE countries, for example YF.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add something like, if some or any of PINE present, plot those? Likely at least one PINE country will be present in all disease datasets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a failure for a disease-country mismatch is okay, we provide PINE as a sensible default but there's no expectation that country is always present - the function will error informatively, and the user can change either data or country.

Comment thread R/fn_plotting_impact.R Outdated
ggplot2::geom_line(aes(colour = .data$short_name), linewidth = 0.5) +
ggplot2::geom_point(aes(colour = .data$short_name), size = 0.5) +
theme_vimc() +
facet_wrap(ggplot2::vars("country"), scales = "free_y") +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the facet_wrap should be facet_wrap(ggplot2::vars(country), scales = "free_y") to correctly facet the plots into countries

Comment thread R/fn_plotting_impact.R
labs(
x = x_lab,
y = glue::glue("{burden_type} averted"),
title = title

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add two labs to make the legend title more intuitive:
fill = "Vaccination activity", colour = "Vaccination activity"

Comment thread R/fn_plotting_impact.R
labs(
x = "Year",
y = ylab,
title = title

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment re tidying up legend title:
fill = "Vaccination acitivty", colour = "Vaccination activity"

Comment thread R/fn_plotting_impact.R
ggplot(
data,
aes(
x = .data$year,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Years are being plotted with 2 dp. not sure what the easiest way to deal with it is, force as.integer?

@pratikunterwegs pratikunterwegs changed the title WIP impact diagnostics fns Add impact diagnostics functions Jul 21, 2026
@pratikunterwegs
pratikunterwegs merged commit 822ad66 into main Jul 21, 2026
11 checks passed
@pratikunterwegs
pratikunterwegs deleted the dev-zoe branch July 21, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants