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 one or more columns that uniquely identify individual trajectories (e.g. a 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 location timeseries or 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 column containing a set of timepoints coercible to dates.