Skip to content

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

@dshemetov

Description

@dshemetov

The line in question is here.

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)

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"
        ))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions