Skip to content

Commit 7cc4a8f

Browse files
authored
Merge pull request #382 from cmu-delphi/ndefries/epidatasets-migration
Ndefries/epidatasets migration
2 parents e9f5924 + 4001e19 commit 7cc4a8f

File tree

124 files changed

+275
-596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+275
-596
lines changed

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ URL: https://github.com/cmu-delphi/epipredict/,
2525
BugReports: https://github.com/cmu-delphi/epipredict/issues/
2626
Depends:
2727
epiprocess (>= 0.9.0),
28+
epidatasets,
2829
parsnip (>= 1.0.0),
2930
R (>= 3.5.0)
3031
Imports:
@@ -49,7 +50,6 @@ Imports:
4950
workflows (>= 1.0.0)
5051
Suggests:
5152
data.table,
52-
epidatasets,
5353
epidatr (>= 1.0.0),
5454
fs,
5555
grf,
@@ -69,6 +69,7 @@ Suggests:
6969
VignetteBuilder:
7070
knitr
7171
Remotes:
72+
cmu-delphi/epidatasets,
7273
cmu-delphi/epidatr,
7374
cmu-delphi/epiprocess,
7475
dajmcdon/smoothqr

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export(update_model)
215215
export(validate_layer)
216216
export(weighted_interval_score)
217217
import(distributional)
218+
import(epidatasets)
218219
import(epiprocess)
219220
import(parsnip)
220221
import(recipes)

NEWS.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
44

55
# epipredict 0.2
66

7-
## features
7+
## Breaking changes
8+
9+
- Moved example datasets from being hosted in the package to being loaded
10+
from the `epidatasets` package. The datasets can no longer be loaded with
11+
`data(<dataset name>)`, but can be accessed with
12+
`data(<dataset name>, package = "epidatasets")`, `epidatasets::<dataset name>`
13+
or, after loading the package, the name of the dataset alone (#382).
14+
15+
## Improvements
16+
817
- Add `step_adjust_latency`, which give several methods to adjust the forecast if the `forecast_date` is after the last day of data.
918
- (temporary) ahead negative is allowed for `step_epi_ahead` until we have `step_epi_shift`
1019

11-
## bugfixes
12-
- shifting no columns results in no error for either `step_epi_ahead` and `step_epi_lag`
20+
## Bug fixes
21+
- Shifting no columns results in no error for either `step_epi_ahead` and `step_epi_lag`
1322
- Quantiles produced by `grf` were sometimes out of order.
1423

1524
# epipredict 0.1

R/arx_classifier.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#'
2828
#' @examples
2929
#' library(dplyr)
30-
#' jhu <- case_death_rate_subset %>%
30+
#' jhu <- covid_case_death_rates %>%
3131
#' filter(time_value >= as.Date("2021-11-01"))
3232
#'
3333
#' out <- arx_classifier(jhu, "death_rate", c("case_rate", "death_rate"))
@@ -104,7 +104,7 @@ arx_classifier <- function(
104104
#' @seealso [arx_classifier()]
105105
#' @examples
106106
#' library(dplyr)
107-
#' jhu <- case_death_rate_subset %>%
107+
#' jhu <- covid_case_death_rates %>%
108108
#' filter(time_value >= as.Date("2021-11-01"))
109109
#'
110110
#' arx_class_epi_workflow(jhu, "death_rate", c("case_rate", "death_rate"))

R/arx_forecaster.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @seealso [arx_fcast_epi_workflow()], [arx_args_list()]
2626
#'
2727
#' @examples
28-
#' jhu <- case_death_rate_subset %>%
28+
#' jhu <- covid_case_death_rates %>%
2929
#' dplyr::filter(time_value >= as.Date("2021-12-01"))
3030
#'
3131
#' out <- arx_forecaster(
@@ -96,7 +96,7 @@ arx_forecaster <- function(
9696
#'
9797
#' @examples
9898
#' library(dplyr)
99-
#' jhu <- case_death_rate_subset %>%
99+
#' jhu <- covid_case_death_rates %>%
100100
#' filter(time_value >= as.Date("2021-12-01"))
101101
#'
102102
#' arx_fcast_epi_workflow(

R/autoplot.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ggplot2::autoplot
2929
#' @name autoplot-epipred
3030
#' @examples
3131
#' library(dplyr)
32-
#' jhu <- case_death_rate_subset %>%
32+
#' jhu <- covid_case_death_rates %>%
3333
#' filter(time_value >= as.Date("2021-11-01"))
3434
#'
3535
#' r <- epi_recipe(jhu) %>%
@@ -70,7 +70,7 @@ ggplot2::autoplot
7070
#'
7171
#' # ------- Plotting canned forecaster output
7272
#'
73-
#' jhu <- case_death_rate_subset %>%
73+
#' jhu <- covid_case_death_rates %>%
7474
#' filter(time_value >= as.Date("2021-11-01"))
7575
#' flat <- flatline_forecaster(jhu, "death_rate")
7676
#' autoplot(flat, .max_facets = 4)

R/cdc_baseline_forecaster.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#'
2424
#' @examples
2525
#' library(dplyr)
26-
#' weekly_deaths <- case_death_rate_subset %>%
26+
#' weekly_deaths <- covid_case_death_rates %>%
2727
#' select(geo_value, time_value, death_rate) %>%
2828
#' left_join(state_census %>% select(pop, abbr), by = c("geo_value" = "abbr")) %>%
2929
#' mutate(deaths = pmax(death_rate / 1e5 * pop * 7, 0)) %>%

R/data.R

-87
This file was deleted.

R/epi_recipe.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ epi_recipe.default <- function(x, ...) {
4343
#' @examples
4444
#' library(dplyr)
4545
#' library(recipes)
46-
#' jhu <- case_death_rate_subset %>%
46+
#' jhu <- covid_case_death_rates %>%
4747
#' filter(time_value > "2021-08-01") %>%
4848
#' arrange(geo_value, time_value)
4949
#'
@@ -263,7 +263,7 @@ is_epi_recipe <- function(x) {
263263
#' library(dplyr)
264264
#' library(recipes)
265265
#'
266-
#' jhu <- case_death_rate_subset %>%
266+
#' jhu <- covid_case_death_rates %>%
267267
#' filter(time_value > "2021-08-01") %>%
268268
#' arrange(geo_value, time_value)
269269
#'
@@ -347,7 +347,7 @@ update_epi_recipe <- function(x, recipe, ..., blueprint = default_epi_recipe_blu
347347
#' library(dplyr)
348348
#' library(workflows)
349349
#'
350-
#' jhu <- case_death_rate_subset %>%
350+
#' jhu <- covid_case_death_rates %>%
351351
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
352352
#' r <- epi_recipe(jhu) %>%
353353
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%

R/epi_workflow.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' @importFrom generics augment
2121
#' @export
2222
#' @examples
23-
#' jhu <- case_death_rate_subset
23+
#' jhu <- covid_case_death_rates
2424
#'
2525
#' r <- epi_recipe(jhu) %>%
2626
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
@@ -84,7 +84,7 @@ is_epi_workflow <- function(x) {
8484
#' @name fit-epi_workflow
8585
#' @export
8686
#' @examples
87-
#' jhu <- case_death_rate_subset %>%
87+
#' jhu <- covid_case_death_rates %>%
8888
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
8989
#'
9090
#' r <- epi_recipe(jhu) %>%
@@ -142,7 +142,7 @@ fit.epi_workflow <- function(object, data, ..., control = workflows::control_wor
142142
#' @name predict-epi_workflow
143143
#' @export
144144
#' @examples
145-
#' jhu <- case_death_rate_subset
145+
#' jhu <- covid_case_death_rates
146146
#'
147147
#' r <- epi_recipe(jhu) %>%
148148
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%

R/epipredict-package.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## usethis namespace: start
2-
#' @import epiprocess parsnip
2+
#' @import epiprocess parsnip epidatasets
33
#' @importFrom checkmate assert_class assert_numeric
44
#' @importFrom checkmate test_character test_date test_function
55
#' @importFrom checkmate test_integerish test_logical

R/flatline_forecaster.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#' @export
2525
#'
2626
#' @examples
27-
#' jhu <- case_death_rate_subset %>%
27+
#' jhu <- covid_case_death_rates %>%
2828
#' dplyr::filter(time_value >= as.Date("2021-12-01"))
2929
#'
3030
#' out <- flatline_forecaster(jhu, "death_rate")

R/flusight_hub_formatter.R

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
location_to_abbr <- function(location) {
22
dictionary <-
33
state_census %>%
4-
mutate(fips = sprintf("%02d", fips)) %>%
54
dplyr::transmute(
65
location = dplyr::case_match(fips, "00" ~ "US", .default = fips),
76
abbr
@@ -12,7 +11,6 @@ location_to_abbr <- function(location) {
1211
abbr_to_location <- function(abbr) {
1312
dictionary <-
1413
state_census %>%
15-
mutate(fips = sprintf("%02d", fips)) %>%
1614
dplyr::transmute(
1715
location = dplyr::case_match(fips, "00" ~ "US", .default = fips),
1816
abbr
@@ -57,7 +55,7 @@ abbr_to_location <- function(abbr) {
5755
#'
5856
#' @examples
5957
#' library(dplyr)
60-
#' weekly_deaths <- case_death_rate_subset %>%
58+
#' weekly_deaths <- covid_case_death_rates %>%
6159
#' filter(
6260
#' time_value >= as.Date("2021-09-01"),
6361
#' geo_value %in% c("ca", "ny", "dc", "ga", "vt")

R/frosting.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#'
1010
#' @examples
1111
#' library(dplyr)
12-
#' jhu <- case_death_rate_subset %>%
12+
#' jhu <- covid_case_death_rates %>%
1313
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
1414
#' r <- epi_recipe(jhu) %>%
1515
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
@@ -128,7 +128,7 @@ update_frosting <- function(x, frosting, ...) {
128128
#' @export
129129
#' @examples
130130
#' library(dplyr)
131-
#' jhu <- case_death_rate_subset %>%
131+
#' jhu <- covid_case_death_rates %>%
132132
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
133133
#' r <- epi_recipe(jhu) %>%
134134
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
@@ -268,7 +268,7 @@ new_frosting <- function() {
268268
#' wf <- epi_workflow() %>% add_frosting(f)
269269
#'
270270
#' # A more realistic example
271-
#' jhu <- case_death_rate_subset %>%
271+
#' jhu <- covid_case_death_rates %>%
272272
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
273273
#'
274274
#' r <- epi_recipe(jhu) %>%

R/get_test_data.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#' keys, as well other variables in the original dataset.
2020
#' @examples
2121
#' # create recipe
22-
#' rec <- epi_recipe(case_death_rate_subset) %>%
22+
#' rec <- epi_recipe(covid_case_death_rates) %>%
2323
#' step_epi_ahead(death_rate, ahead = 7) %>%
2424
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
2525
#' step_epi_lag(case_rate, lag = c(0, 7, 14))
26-
#' get_test_data(recipe = rec, x = case_death_rate_subset)
26+
#' get_test_data(recipe = rec, x = covid_case_death_rates)
2727
#' @importFrom rlang %@%
2828
#' @importFrom stats na.omit
2929
#' @export

R/layer_add_forecast_date.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#' @export
2323
#' @examples
2424
#' library(dplyr)
25-
#' jhu <- case_death_rate_subset %>%
25+
#' jhu <- covid_case_death_rates %>%
2626
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
2727
#' r <- epi_recipe(jhu) %>%
2828
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%

R/layer_add_target_date.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @export
2626
#' @examples
2727
#' library(dplyr)
28-
#' jhu <- case_death_rate_subset %>%
28+
#' jhu <- covid_case_death_rates %>%
2929
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
3030
#' r <- epi_recipe(jhu) %>%
3131
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%

R/layer_cdc_flatline_quantiles.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@
5656
#'
5757
#' @examples
5858
#' library(dplyr)
59-
#' r <- epi_recipe(case_death_rate_subset) %>%
59+
#' r <- epi_recipe(covid_case_death_rates) %>%
6060
#' # data is "daily", so we fit this to 1 ahead, the result will contain
6161
#' # 1 day ahead residuals
6262
#' step_epi_ahead(death_rate, ahead = 1L, skip = TRUE) %>%
6363
#' recipes::update_role(death_rate, new_role = "predictor") %>%
6464
#' recipes::add_role(time_value, geo_value, new_role = "predictor")
6565
#'
66-
#' forecast_date <- max(case_death_rate_subset$time_value)
66+
#' forecast_date <- max(covid_case_death_rates$time_value)
6767
#'
6868
#' f <- frosting() %>%
6969
#' layer_predict() %>%
7070
#' layer_cdc_flatline_quantiles(aheads = c(7, 14, 21, 28), symmetrize = TRUE)
7171
#'
7272
#' eng <- linear_reg(engine = "flatline")
7373
#'
74-
#' wf <- epi_workflow(r, eng, f) %>% fit(case_death_rate_subset)
74+
#' wf <- epi_workflow(r, eng, f) %>% fit(covid_case_death_rates)
7575
#' preds <- forecast(wf) %>%
7676
#' select(-time_value) %>%
7777
#' mutate(forecast_date = forecast_date)
@@ -91,7 +91,7 @@
9191
#' geom_ribbon(aes(ymin = `0.25`, ymax = `0.75`), fill = blues9[6]) +
9292
#' geom_line(aes(y = .pred), color = "orange") +
9393
#' geom_line(
94-
#' data = case_death_rate_subset %>% filter(geo_value %in% four_states),
94+
#' data = covid_case_death_rates %>% filter(geo_value %in% four_states),
9595
#' aes(x = time_value, y = death_rate)
9696
#' ) +
9797
#' scale_x_date(limits = c(forecast_date - 90, forecast_date + 30)) +

0 commit comments

Comments
 (0)