Repository navigation
Keep zero estimates in impact plots - #19
Open
david-mears-2 wants to merge 1 commit into
Open
david-mears-2 wants to merge 1 commit into
david-mears-2 wants to merge 1 commit into
Conversation
Retain zero-valued observations in mixed impact series while preserving the existing no-nonzero-estimates error. Add coordinate regressions for both views and update the patch release notes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
This is AI generated. TODO:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
plot_impact()shows the estimated health benefit of vaccination over time, such as the number of cases averted each year. It also supports grouping estimates by birth cohort.The function removes estimates equal to zero before drawing the plot. For example, estimates of 10 cases averted in 2020, 0 in 2021, and 10 in 2022 become just the two points for 2020 and 2022. The line joins those points at 10, hiding the year with no estimated benefit. The same problem affects the birth-cohort view.
A zero estimate is a value to plot, not a missing observation.
The fix
Keep zero estimates in the plotting data so that the line drops to zero and rises again in this example. Continue removing missing (
NA) estimates.Preserve the existing error when the filtered data has no nonzero estimates, including all-zero inputs. That check now happens separately from filtering the plotting data. Negative estimates remain supported.
This PR addresses only zero removal; it does not change country selection or other plotting behavior. It also updates the patch version to 0.0.7 and records the fix in
NEWS.md, as required byCONTRIBUTING.md.Tests
The regression checks the actual coordinates of both the line and point layers, not just whether a plot is returned. It covers year and birth-cohort views, a
10, 0, 10trajectory, a negative-to-positive trajectory through zero, and missing estimates. A second test checks that all-zero or absent outcomes still raise an error even when another outcome has nonzero estimates.R CMD INSTALLsucceeds, and both new tests pass against the installed package.main; this patch adds no lint findings.