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",
  with_epiweek_start_date = FALSE,
  with_epiweek_end_date = FALSE,
  epiweek_start_date_name = "epiweek_start_date",
  epiweek_end_date_name = "epiweek_end_date",
  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".

with_epiweek_start_date

Annotate the result with a column giving the epiweek start date? Boolean, default FALSE.

with_epiweek_end_date

Annotate the result with a column giving the epiweek end date? Boolean, default FALSE.

epiweek_start_date_name

Name to use for the column reporting the epiweek start date. Default "epiweek_start_date".

epiweek_end_date_name

Name to use for the column reporting the epiweek end date. Default "epiweek_end_date".

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.