Skip to content

nhsn source does not respect as_of (and incorrect documentation?) #1653

Open
@damonbayer

Description

@damonbayer

As an extreme example, here I request an as of date of Jan 1, 1800. I would expect this to produce no results, but I get results with an issue date and time_values from a few weeks ago. The results are the same if I use an as_of date from the recent past, or even the future.

library(epidatr)
library(tidyverse)
library(waldo)

nhsn_1800 <- pub_covidcast(
  source = "nhsn",
  signals = "confirmed_admissions_covid_ew_prelim",
  geo_type = "nation",
  time_type = "week",
  as_of = as_date("1800-01-01"))

nhsn_1800 |> distinct(issue)
#> # A tibble: 1 × 1
#>   issue     
#>   <date>    
#> 1 2025-06-15
nhsn_1800 |> summarize(max(time_value))
#> # A tibble: 1 × 1
#>   `max(time_value)`
#>   <date>           
#> 1 2025-06-08

nhsn_2025 <- pub_covidcast(
  source = "nhsn",
  signals = "confirmed_admissions_covid_ew_prelim",
  geo_type = "nation",
  time_type = "week",
  as_of = as_date("2025-01-01"))

nhsn_2050 <- pub_covidcast(
  source = "nhsn",
  signals = "confirmed_admissions_covid_ew_prelim",
  geo_type = "nation",
  time_type = "week",
  as_of = as_date("2050-01-01"))

compare(nhsn_1800, nhsn_2025)
#> ✔ No differences
compare(nhsn_1800, nhsn_2050)
#> ✔ No differences

Created on 2025-06-23 with reprex v2.1.1

Per the documentation, the nhsn source has

Earliest issue available: November 19, 2024
Number of data revisions since 18 Nov 2024: 0
Date of last change: Never

This also does not agree with experience. It seems the data was updated as recently as two weeks ago.

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