prepare.idbrms_convolution: Prepare data for fitting using a convolution model

View source: R/convolution.R

prepare.idbrms_convolutionR Documentation

Prepare data for fitting using a convolution model

Description

Prepare data for fitting using a convolution model

Usage

## S3 method for class 'idbrms_convolution'
prepare(
  data,
  location,
  primary,
  secondary,
  initial_obs = 14,
  max_convolution = 30,
  ...
)

Arguments

data

A data frame containing at least two integer observations and a date variable.

location

Character string, variable to use as the spatial location.

primary

Character string, variable to use as the primary observation.

secondary

Character string, variable to use as the secondary observation.

initial_obs

Integer, number of observations to hold out from the likelihood. This is useful as initially the outcome will depend on primary data outside of the range of the training set and including this could bias the estimated delay distribution. Defaults to 14 days.

max_convolution

Integer defining the maximum index to use for the convolution. Defaults to 30 days.

...

Additional arguments passed to model specific prepare functions

Author(s)

Sam Abbott

Examples

# define some example data
library(data.table)
dt <- data.table(
   region = "France", cases = seq(10, 500, by = 10),
   date = seq(as.Date("2020-10-01"), by = "days", length.out = 50)
   )
dt <- dt[, deaths := as.integer(shift(cases, 5) * 0.1)]
dt <- dt[is.na(deaths), deaths := 0]

dt <- prepare(
  dt, model = "convolution", location = "region",
  primary = "cases", secondary = "deaths",
  )
dt[]

epiforecasts/brms.id documentation built on Sept. 6, 2022, 3:40 a.m.