Skip to contents

Given a set of daily timeseries / time trajectories in tidy long-form format (i.e. with one row per day per trajectory, with a .draws or other trajectory id column), aggregate it to the scale of epiweeks.

Usage

daily_to_epiweekly(
  tidy_daily_trajectories,
  value_col = "value",
  date_col = "date",
  id_cols = ".draw",
  weekly_value_name = "weekly_value",
  strict = TRUE
)

Arguments

tidy_daily_trajectories

tibble of trajectories, with dates, trajectory ids, and observeable values to aggregate

value_col

name of the column containing trajectory values. Default "value".

date_col

name of the column containing dates. Default "date".

id_cols

name(s) of the column(s) that uniquely identify a single timeseries (e.g. a single posterior trajectory). Default ".draw" (as the output of tidybayes::spread_draws()).

weekly_value_name

name to use for the output coluqmn containing weekly trajectory values. Default "weekly_value".

strict

Boolean. If TRUE only aggregate an epiweek if all seven days are represented in the trajectory. If FALSE, allow partial weeks. Default TRUE.

Value

tibble of aggregated epiweekly trajectories.

Details

This requires a date column that is a set of timepoints coercible to dates.