Skip to content

testing forecasters on simple datasets #32

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

Merged
merged 18 commits into from
Oct 25, 2023
Merged

Conversation

dsweber2
Copy link
Contributor

@dsweber2 dsweber2 commented Oct 11, 2023

addresses #23 and #20. I ended up not actually using targets for the simple data tests b/c it ended up too awkward and distributed. I should probably do a little cleanup of the repo and check for edge cases before we actually merge this.

@dsweber2 dsweber2 marked this pull request as ready for review October 12, 2023 20:06
@dsweber2
Copy link
Contributor Author

I also added the flatline forecaster and made the necessary changes to get that working. Should be ready for review (pending the tests passing on the remote).

@dsweber2
Copy link
Contributor Author

To be clear, the tests this adds are:

  • 2 states with different constants (technically normally distributed with sd=1e-5, to avoid problems with linear_reg)
  • single state with white noise (sd=2 while the mean is 25)
  • 2 states, one of which has latency varying between 0-3 days (poisson mean 0.5)
  • linearly increasing by 1 each day (the flatline is exempt from passing this test)

@dsweber2 dsweber2 requested a review from dshemetov October 12, 2023 21:11
@dsweber2 dsweber2 added this to the initial exploration milestone Oct 12, 2023
@dsweber2 dsweber2 requested review from nmdefries and removed request for nmdefries October 16, 2023 20:57
@nmdefries nmdefries self-requested a review October 16, 2023 21:40
@dsweber2 dsweber2 force-pushed the forecaster_testing_init branch from 7a6e0d1 to b60b500 Compare October 18, 2023 17:20
Copy link
Contributor

@nmdefries nmdefries left a comment

Choose a reason for hiding this comment

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

Comments are mostly for formatting/structure, still looking at this for content.

There are a lot of objs being printed out, I assume for debugging. Test code should be removed. I marked some of them, probably not all.

Generally, it'd be good to have more descriptive "test_that" names and/or comments about what the goal of a particular test is.

Copy link
Contributor

@nmdefries nmdefries left a comment

Choose a reason for hiding this comment

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

Confused about the reasoning behind a couple of the checks.

Other tests that might be useful to include:

  • Which dates predicted values are available for/making sure that preds are on days where we have enough data
  • Right now, looks like predictions are only for dates that are included in the input dataset. Might be useful to check behavior when making true forecasts (again, that output dates are what we expect, etc)

mutate(
diff_from_exp =
(value - qnorm(quantile, mean = synth_mean, sd = synth_sd)) /
as.integer(target_end_date - forecast_date)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why are we normalizing by days ahead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc the variance should be increasing linearly with the number of days into the future? It's probably a complication we don't need to include, since ahead=1 for all of these tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

the variance should be increasing linearly with the number of days into the future

Oh, I see what you mean. A prediction for ahead_i will have error within synth_sd around the prediction for ahead_i - 1, which also has error. So the error accumulates and is ~bounded by synth_sd * days ahead for each ahead. Sound approximately correct? 😄

Copy link
Contributor

@nmdefries nmdefries Oct 25, 2023

Choose a reason for hiding this comment

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

maybe leave this in case we want add more aheads later, but add a comment about the normalization? But no strong feelings on my part.

@dsweber2
Copy link
Contributor Author

output date correctness is checked here in the "basics" section, rather than the "data" section:

expect_true(all(
res$target_end_date ==
as.Date("2022-01-01")
))

as well as somewhat indirectly in the latency adjusting specific functions:
expect_no_error(epidataAhead <- extend_ahead(case_death_rate_subset, 1))

Copy link
Contributor

@dshemetov dshemetov left a comment

Choose a reason for hiding this comment

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

Looks good for a first pass.

@dsweber2 dsweber2 mentioned this pull request Oct 24, 2023
5 tasks
@dsweber2 dsweber2 self-assigned this Oct 24, 2023
Copy link
Contributor

@nmdefries nmdefries left a comment

Choose a reason for hiding this comment

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

Looks good!

@dsweber2 dsweber2 merged commit 109d9ce into main Oct 25, 2023
@nmdefries nmdefries deleted the forecaster_testing_init branch October 25, 2023 18:20
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.

3 participants