cmu-delphi / cmu-delphi/epipredict

Bug: get_test_data uses na.omit() on all data table columns, rather than just predictors/outcomes

Open
#468 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
18
Forks
13
Avg merge
21d 58m
Merged PRs (30d)
1

Description

The line in question is [here](https://github.com/cmu-delphi/epipredict/blob/dev/R/get_test_data.R#L60-L63).

I realize we have consensus that `get_test_data()` will be re-written, but
- it's been that way for over a year now, so a temp fix might still be worth it here
- if a temp fix is not worth it, figured I'd report this so we don't re-create this bug in the new implementation

(Sorry this reprex isn't very minified)

```r
library(epipredict)
library(epiprocess)
library(epidatr)
library(data.table)
library(dplyr)
library(tidyr)
library(ggplot2)
library(magrittr)
library(purrr)

#Fetch data from Delphi Epidata API
nhsn <- pub_covidcast(
source = "nhsn",
signals = "confirmed_admissions_covid_ew_prelim",
geo_type = "state",
time_type = "week",
geo_values = "*",
time_values = epirange(202001, 202601),
issues = epirange(202001, 202601)
) |>
# The version date column is called `issue` in the Epidata API. Rename it.
rename(version = issue, confirmed_covid_adm = value) |>
as_epi_archive(compactify = TRUE)

nhsn_original <- nhsn
nhsn <- nhsn_original
#Plot of monthly snapshots of the data
geo_choose <- "ca"

forecast_dates <- as.Date("2025-03-09")

covid_adm_data <- bind_rows(
# Snapshotted data for the version-faithful forecasts
map(
forecast_dates,
~ nhsn |>
epix_as_of(.x) |>
mutate(version = .x)
) |>
bind_rows() |>
mutate(version_faithful = "Version faithful"),
# Latest data for the version-un-faithful forecasts
nhsn |>
epix_as_of(nhsn$versions_end) |>
mutate(version_faithful = "Version un-faithful")
)

# Enter debug mode here
debug(epipredict::get_test_data)
archive_cases_dv_subset_faux %>%
epix_as_of(as.Date("2025-03-09")) %>%
arx_forecaster("confirmed_covid_adm", "confirmed_covid_adm", args_list = arx_args_list(
ahead = 7,
lags = c(0, 7, 14, 21),
adjust_latency = "extend_ahead"
))

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.