Skip to content
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

pseudo-code or proof of concept implementation of updated time handling #392

Open
dylanhmorris opened this issue Mar 19, 2025 · 1 comment
Assignees

Comments

@dylanhmorris
Copy link
Contributor

dylanhmorris commented Mar 19, 2025

Needs

  • All three signals can fit to arbitrary timeseries (with missing observed days, etc).
  • Consistent, safe conversion between model time ("days since $t_0$") and human time (dates)
  • Posterior prediction of full timeseries (including any days with missing values from the fitting timeseries and any requested forecast days).

To-do once implemeneted

  • Simplify application of day-of-week effects, right truncation adjustments, etc accordingly.

What exists

Right now, H and E expect complete timeseries (i.e. no missing observations) and are keyed by a first observation date:

observed_hospital_admissions = hospital_admissions_obs_rv(
mu=predicted_weekly_admissions[offset_first_obs_weeks:],
obs=data_observed,
)

W, in contrast, has nullable data, and takes an explicit vector of observed times:

expected_obs_log_v_site = (
expected_obs_viral_genomes[ww_observed_times, ww_observed_subpops]
+ mode_ww_site[ww_observed_lab_sites]
)

What we want

The same system for H and E as W

  • user passes in two vectors of equal length: one representing the observed dates (dates_obs_hospital_admissions, dates_obs_ed_visits, etc) and one representing the observed values (values_obs_hospital_admissions, values_obs_ed_visits etc).
  • Model generates predictions for all dates from the earliest observation date across signals to the last observation date across signals, but only performs the observation process for the user-specified observed dates for each signal.

Details

  • Model determines what date corresponds to model $t_0$. By convention, this is the date of the first observation across all available signals. Note that some vectors in the model will not begin at $t_0$ including the vector of infections. This should be a @property (named model_t0_date) of PyrenewHEWData

  • Model determines the model time indices (rel to $t_0$, zero indexed) of the observed dates for all three signals. This should be a class method of PyrenewHEWData (named, e.g. date_to_model_time()) that uses the value of model_t0_date to perform the computation. Name these vectors model_t_obs_hospital_admissions, model_t_obs_ed_visits etc.

  • Model computes the latent_infections vector. Model computes the time index of the first entry of the latent_infections vector (in model time, i.e. relative to $t_0$. It will be negative.

  • Model computes the predicted signal value vectors (i.e. latent_hospital_admissions, latent_ed_visits, etc.) via the compute_delay_ascertained_incidence() or wastewater equivalent. Model uses offsets of the start of these predicted signal vectors relative to the latent_infections vector to compute the (integer) time indices in model time of those vectors' first entries (model_t_first_latent_ed_visit, etc).

  • Model indexes latent_{signal} vectors by model_t_obs_{signal} vectors with the appropriate offset given by model_t_first_latent_{signal} integer, and performs the observation, e.g.

        which_obs_ed_visits = model_t_obs_ed_visits - model_t_first_latent_ed_visit  
       # minus because the first entry of the latent_ed_visits vector corresponds to model_t >= 0
        observed_ed_visits_admissions = ed_visits_obs_rv(
            mu=latent_ed_visits[which_obs_ed_visits],
            obs=data_observed_ed_visits,
        )
  • For posterior prediction (including forecasting), indexing by which_obs_{signal} should return all the values of latent_{signal} (i.e. which_obs_{signal} should be the vector range(latent_{signal}.size) and data_observed_{signal} should be None. The to_forecast_data() method of PyrenewHEWData should be configured accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant