-
Notifications
You must be signed in to change notification settings - Fork 10
Djm/resids hotfix #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Djm/resids hotfix #294
Conversation
Interesting, a little surprised I haven't actually run into this problem. If we're not doing grouping by So I tried the test without the change and it seems to have passed; doing a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to extract the test case slightly differently. Looking at grab_residuals
, seems like it could only happen if ".resid"
is already in the residuals of the_fit
, which is returning a dataframe.
Were you maybe using a different engine than linear_reg
?
Here's the failure: library(epipredict)
#> Loading required package: epiprocess
#>
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#>
#> filter
#> Loading required package: parsnip
flat1 <- flatline_forecaster(case_death_rate_subset, "death_rate")
flat2 <- flatline_forecaster(
case_death_rate_subset, "death_rate",
args_list = flatline_args_list(quantile_by_key = "geo_value")
)
#> New names:
#> • `geo_value` -> `geo_value...1`
#> • `geo_value` -> `geo_value...2`
#> Error in `dplyr::group_by()`:
#> ! Must group by variables found in `.data`.
#> ✖ Column `geo_value` is not found. Created on 2024-02-20 with reprex v2.1.0 And on rebuilding with this fix: library(epipredict)
#> Loading required package: epiprocess
#>
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#>
#> filter
#> Loading required package: parsnip
flat1 <- flatline_forecaster(case_death_rate_subset, "death_rate")
flat2 <- flatline_forecaster(
case_death_rate_subset, "death_rate",
args_list = flatline_args_list(quantile_by_key = "geo_value")
) Created on 2024-02-20 with reprex v2.1.0 |
It's because of the |
That seems simple enough to include as the unit test maybe? I tried the straightforward
|
* avoids bug when requesting quantile_values close to existing ones but off by a small tolerance * never creates unsorted quantiles * extrapolates outside the existing range by linearly interpolating on the logistic scale
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Half of this is addressing a new issue right? Seems like you changed the extrapolation to use the same method regardless of region and refactored some functions?
I have lingering questions about things but I wouldn't let those block
l <- 1:9 / 10 | ||
v <- 1:9 | ||
distn <- dist_quantiles(list(v), list(l)) | ||
expect_equal(quantile(distn, c(.25, .75)), list(c(2.5, 7.5))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanity check, this is 2.5 because that's halfway between 2 and 3, which are the .2
and .3
quantile values?
expect_equal( | ||
unlist(quantile(distn, c(.01, .05))), | ||
tail_extrapolate(c(.01, .05), head(qv, 2)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I quite get how this is testing the tail behavior; is it just checking that quantile
is using tail_extrapolate
to calculate the values at those quantiles?
oh, I pushed the change for the styler, which seems to have been the only thing that was breaking the CI |
@dsweber2 Am I good to merge this? |
oh, I suppose I should've said that in addition to approving. Would you prefer I just merge if I approve when I'm tagged? But yes, lgtm! |
Ah, no problem. I think better for the PR creator to merge once satisfied, but I lost track of whether we were both satisfied! |
Checklist
Please:
dajmcdon.
DESCRIPTION
andNEWS.md
.Always increment the patch version number (the third number), unless you are
making a release PR from dev to main, in which case increment the minor
version number (the second number).
(backwards-incompatible changes to the documented interface) are noted.
Collect the changes under the next release number (e.g. if you are on
0.7.2, then write your changes under the 0.8 heading).
Change explanations for reviewer
If
grab_residuals()
returns a data frame with some keys, then theby_key
argument would cause an error. This is be cause, for example, ifgeo_value
was a key (it always is), and ther
object had the columnsc("geo_value", ".resid")
, thenbind_cols(key_cols, r)
renames the two geo_value columns to be distinct, and subsequent group_by operations failed.Magic GitHub syntax to mark associated Issue(s) as resolved when this is merged into the default branch