Skip to content

Ndefries/epidatasets migration #382

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 37 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0db442a
import epidatasets package
nmdefries Sep 19, 2024
5c79439
replace state_census with epidatasets version
nmdefries Sep 19, 2024
d289e81
replace grad_employ_subset with epidatasets version
nmdefries Sep 19, 2024
b04855a
replace case_death_rate_subset with epidatasets::covid_case_death_rates
nmdefries Sep 19, 2024
7b6895d
replace all case_death_rate_subset references
nmdefries Sep 19, 2024
80baf40
add counts_subset dataset
nmdefries Sep 19, 2024
63699ac
add ctis_covid_behaviours dataset
nmdefries Sep 19, 2024
45aa4d5
move datasets to epidatasets and use in vignettes
nmdefries Sep 21, 2024
64929e0
reexport can_prov_covid from epidatasets
nmdefries Sep 27, 2024
741b96d
remove territories from all_states archive example code to match orig…
nmdefries Sep 27, 2024
b50d6df
redocument
nmdefries Sep 27, 2024
ef55df1
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Sep 30, 2024
d158b11
redocument
nmdefries Sep 30, 2024
d3abd33
state_census fips column is now chr, doesn't need 0-padding
nmdefries Sep 30, 2024
bf9c101
wrap example dataset failures in dontrun
nmdefries Sep 30, 2024
e210607
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Oct 1, 2024
8ff0ea0
import checkmate::test_ fns
nmdefries Oct 1, 2024
5487986
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Oct 1, 2024
dc41493
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Oct 1, 2024
0a5819e
replace case_death_rate_subset with epidatasets::covid_case_death_rat…
nmdefries Oct 2, 2024
00d0dd7
attribution
nmdefries Oct 2, 2024
f85d6d8
news and version
nmdefries Oct 2, 2024
be608ca
jhu_csse_daily_subset -> cases_deaths_subset
nmdefries Oct 15, 2024
2768552
use case_when to avoid converting numeric -> Date
nmdefries Oct 15, 2024
b536e82
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Oct 15, 2024
4598ffe
styler
nmdefries Oct 15, 2024
133c03f
update snaps
nmdefries Oct 16, 2024
4897cd3
revert step_epi_slide snaps
nmdefries Oct 16, 2024
58b61ee
Revert "attribution"
nmdefries Oct 28, 2024
48866ff
bake updates
nmdefries Oct 28, 2024
5267a71
undo styling on purr import
nmdefries Oct 28, 2024
1305af7
depend on epidatasets, but don't reexport
nmdefries Oct 28, 2024
65b79e3
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Oct 28, 2024
4a89419
test snap
nmdefries Oct 28, 2024
ceaeeec
news
nmdefries Oct 28, 2024
d6769fd
Merge branch 'dev' into ndefries/epidatasets-migration
nmdefries Oct 28, 2024
4001e19
change wording to specify datasets are in epidatasets only
nmdefries Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ Authors@R: c(
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),
person("Dmitry", "Shemetov", email = "[email protected]", role = "aut"),
person("David", "Weber", email = "[email protected]", role = "aut"),
person("CMU's Delphi Research Group", role = c("cph", "fnd")),
person("CMU's Delphi Research Group", role = c("cph", "fnd", "dtc"),
comment = "Owner of masking, social-distancing, and CLI data from the COVID-19 Trends and Impacts Survey. Owner of claims-based CLI data from the Delphi Epidata API"),
person("Logan", "Brooks", role = "aut"),
person("Rachel", "Lobay", role = "aut"),
person("Maggie", "Liu", role = "ctb"),
person("Ken", "Mawer", role = "ctb"),
person("Chloe", "You", role = "ctb"),
person("Jacob", "Bien", role = "ctb")
person("Jacob", "Bien", role = "ctb"),
person("Johns Hopkins University Center for Systems Science and Engineering", role = "dtc", comment = "Owner of COVID-19 cases and deaths data from the COVID-19 Data Repository"),
person("Johns Hopkins University", role = "cph", comment = "Copyright holder of COVID-19 cases and deaths data from the COVID-19 Data Repository"),
person("The COVID-19 Canada Open Data Working Group", role = "dtc", comment = "Owner of Canadian COVID-19 cases rates from the Covid19Canada data repository"),
person("Statistics Canada", role = "dtc", comment = "Owner of Canadian graduate employment income data from the Statistics Canada website"),
person("Google", role = "dtc", comment = "Collaborator on CLI data from the Google symptom surveys")
)
Description: A forecasting "framework" for creating epidemiological
forecasts from versioned data. The framework is designed to be modular
Expand All @@ -32,6 +38,7 @@ Imports:
cli,
distributional,
dplyr,
epidatasets,
generics,
ggplot2,
glue,
Expand Down Expand Up @@ -69,6 +76,7 @@ Suggests:
VignetteBuilder:
knitr
Remotes:
cmu-delphi/epidatasets,
cmu-delphi/epidatr,
cmu-delphi/epiprocess,
dajmcdon/smoothqr
Expand Down
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export(add_model)
export(adjust_epi_recipe)
export(adjust_frosting)
export(apply_frosting)
export(archive_cases_dv_subset_all_states)
export(arx_args_list)
export(arx_class_args_list)
export(arx_class_epi_workflow)
Expand All @@ -147,10 +148,17 @@ export(arx_fcast_epi_workflow)
export(arx_forecaster)
export(autoplot)
export(bake)
export(can_prov_cases)
export(case_death_rate_archive)
export(cases_deaths_subset)
export(cdc_baseline_args_list)
export(cdc_baseline_forecaster)
export(check_enough_train_data)
export(clean_f_name)
export(counts_subset)
export(county_smoothed_cli_comparison)
export(covid_case_death_rates)
export(ctis_covid_behaviours)
export(default_epi_recipe_blueprint)
export(detect_layer)
export(dist_quantiles)
Expand All @@ -169,6 +177,7 @@ export(flusight_hub_formatter)
export(forecast)
export(frosting)
export(get_test_data)
export(grad_employ_subset)
export(is_epi_recipe)
export(is_epi_workflow)
export(is_layer)
Expand Down Expand Up @@ -198,6 +207,7 @@ export(remove_frosting)
export(remove_model)
export(slather)
export(smooth_quantile_reg)
export(state_census)
export(step_adjust_latency)
export(step_epi_ahead)
export(step_epi_lag)
Expand All @@ -215,6 +225,7 @@ export(update_model)
export(validate_layer)
export(weighted_interval_score)
import(distributional)
import(epidatasets)
import(epiprocess)
import(parsnip)
import(recipes)
Expand Down
14 changes: 11 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat

# epipredict 0.2

## features
## Breaking changes

- Moved example datasets from being hosted in the package to being reexported
from the `epidatasets` package. The datasets can no longer be loaded with
`data()` but can be accessed with `epipredict::` or, after loading the package,
the name of the dataset alone (#382).

## Improvements

- Add `step_adjust_latency`, which give several methods to adjust the forecast if the `forecast_date` is after the last day of data.
- (temporary) ahead negative is allowed for `step_epi_ahead` until we have `step_epi_shift`

## bugfixes
- shifting no columns results in no error for either `step_epi_ahead` and `step_epi_lag`
## Bug fixes
- Shifting no columns results in no error for either `step_epi_ahead` and `step_epi_lag`

# epipredict 0.1

Expand Down
4 changes: 2 additions & 2 deletions R/arx_classifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#'
#' @examples
#' library(dplyr)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"))
#'
#' out <- arx_classifier(jhu, "death_rate", c("case_rate", "death_rate"))
Expand Down Expand Up @@ -104,7 +104,7 @@ arx_classifier <- function(
#' @seealso [arx_classifier()]
#' @examples
#' library(dplyr)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"))
#'
#' arx_class_epi_workflow(jhu, "death_rate", c("case_rate", "death_rate"))
Expand Down
4 changes: 2 additions & 2 deletions R/arx_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' @seealso [arx_fcast_epi_workflow()], [arx_args_list()]
#'
#' @examples
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' dplyr::filter(time_value >= as.Date("2021-12-01"))
#'
#' out <- arx_forecaster(
Expand Down Expand Up @@ -96,7 +96,7 @@ arx_forecaster <- function(
#'
#' @examples
#' library(dplyr)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-12-01"))
#'
#' arx_fcast_epi_workflow(
Expand Down
4 changes: 2 additions & 2 deletions R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ggplot2::autoplot
#' @name autoplot-epipred
#' @examples
#' library(dplyr)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"))
#'
#' r <- epi_recipe(jhu) %>%
Expand Down Expand Up @@ -70,7 +70,7 @@ ggplot2::autoplot
#'
#' # ------- Plotting canned forecaster output
#'
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"))
#' flat <- flatline_forecaster(jhu, "death_rate")
#' autoplot(flat, .max_facets = 4)
Expand Down
2 changes: 1 addition & 1 deletion R/cdc_baseline_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#'
#' @examples
#' library(dplyr)
#' weekly_deaths <- case_death_rate_subset %>%
#' weekly_deaths <- covid_case_death_rates %>%
#' select(geo_value, time_value, death_rate) %>%
#' left_join(state_census %>% select(pop, abbr), by = c("geo_value" = "abbr")) %>%
#' mutate(deaths = pmax(death_rate / 1e5 * pop * 7, 0)) %>%
Expand Down
87 changes: 0 additions & 87 deletions R/data.R

This file was deleted.

6 changes: 3 additions & 3 deletions R/epi_recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ epi_recipe.default <- function(x, ...) {
#' @examples
#' library(dplyr)
#' library(recipes)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-08-01") %>%
#' arrange(geo_value, time_value)
#'
Expand Down Expand Up @@ -263,7 +263,7 @@ is_epi_recipe <- function(x) {
#' library(dplyr)
#' library(recipes)
#'
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-08-01") %>%
#' arrange(geo_value, time_value)
#'
Expand Down Expand Up @@ -347,7 +347,7 @@ update_epi_recipe <- function(x, recipe, ..., blueprint = default_epi_recipe_blu
#' library(dplyr)
#' library(workflows)
#'
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
Expand Down
6 changes: 3 additions & 3 deletions R/epi_workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @importFrom generics augment
#' @export
#' @examples
#' jhu <- case_death_rate_subset
#' jhu <- covid_case_death_rates
#'
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
Expand Down Expand Up @@ -84,7 +84,7 @@ is_epi_workflow <- function(x) {
#' @name fit-epi_workflow
#' @export
#' @examples
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#'
#' r <- epi_recipe(jhu) %>%
Expand Down Expand Up @@ -142,7 +142,7 @@ fit.epi_workflow <- function(object, data, ..., control = workflows::control_wor
#' @name predict-epi_workflow
#' @export
#' @examples
#' jhu <- case_death_rate_subset
#' jhu <- covid_case_death_rates
#'
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/epipredict-package.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## usethis namespace: start
#' @import epiprocess parsnip
#' @import epiprocess parsnip epidatasets
#' @importFrom checkmate assert_class assert_numeric
#' @importFrom checkmate test_character test_date test_function
#' @importFrom checkmate test_integerish test_logical
Expand Down
2 changes: 1 addition & 1 deletion R/flatline_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' @export
#'
#' @examples
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' dplyr::filter(time_value >= as.Date("2021-12-01"))
#'
#' out <- flatline_forecaster(jhu, "death_rate")
Expand Down
4 changes: 1 addition & 3 deletions R/flusight_hub_formatter.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
location_to_abbr <- function(location) {
dictionary <-
state_census %>%
mutate(fips = sprintf("%02d", fips)) %>%
dplyr::transmute(
location = dplyr::case_match(fips, "00" ~ "US", .default = fips),
abbr
Expand All @@ -12,7 +11,6 @@ location_to_abbr <- function(location) {
abbr_to_location <- function(abbr) {
dictionary <-
state_census %>%
mutate(fips = sprintf("%02d", fips)) %>%
dplyr::transmute(
location = dplyr::case_match(fips, "00" ~ "US", .default = fips),
abbr
Expand Down Expand Up @@ -57,7 +55,7 @@ abbr_to_location <- function(abbr) {
#'
#' @examples
#' library(dplyr)
#' weekly_deaths <- case_death_rate_subset %>%
#' weekly_deaths <- covid_case_death_rates %>%
#' filter(
#' time_value >= as.Date("2021-09-01"),
#' geo_value %in% c("ca", "ny", "dc", "ga", "vt")
Expand Down
6 changes: 3 additions & 3 deletions R/frosting.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @examples
#' library(dplyr)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
Expand Down Expand Up @@ -128,7 +128,7 @@ update_frosting <- function(x, frosting, ...) {
#' @export
#' @examples
#' library(dplyr)
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
Expand Down Expand Up @@ -268,7 +268,7 @@ new_frosting <- function() {
#' wf <- epi_workflow() %>% add_frosting(f)
#'
#' # A more realistic example
#' jhu <- case_death_rate_subset %>%
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#'
#' r <- epi_recipe(jhu) %>%
Expand Down
4 changes: 2 additions & 2 deletions R/get_test_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#' keys, as well other variables in the original dataset.
#' @examples
#' # create recipe
#' rec <- epi_recipe(case_death_rate_subset) %>%
#' rec <- epi_recipe(covid_case_death_rates) %>%
#' step_epi_ahead(death_rate, ahead = 7) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
#' step_epi_lag(case_rate, lag = c(0, 7, 14))
#' get_test_data(recipe = rec, x = case_death_rate_subset)
#' get_test_data(recipe = rec, x = covid_case_death_rates)
#' @importFrom rlang %@%
#' @importFrom stats na.omit
#' @export
Expand Down
Loading
Loading