idbrm.idbrms_convolution: Delay Convolution Model

View source: R/convolution.R

idbrm.idbrms_convolutionR Documentation

Delay Convolution Model

Description

A model that assumes that a secondary observations can be predicted using a convolution of a primary observation multipled by some scaling factor. An example use case of this model is to estimate the case fatality rate (with the primary observation being cases and the secondary observation being deaths) and then explore factors that influence it.

Usage

## S3 method for class 'idbrms_convolution'
idbrm(
  data,
  formula = id_formula(data),
  family = negbinomial(link = "identity"),
  priors = id_priors(data),
  custom_stancode = id_stancode(data),
  dry = FALSE,
  ...
)

Arguments

data

A data.frame as produced by prepare that must contain the date, location (as loc), primary (the data that the outcome is a convolution of) and secondary (the observation of interest. Should have class "idbrms_convolution".

formula

A formula as defined using id_formula or as supported by brms::brm.

family

A observation model family as defined in brms.

priors

A list of priors as defined using brms or id_priors. Defaults to the the id_priors defined for the model class being fit.

custom_stancode

A list of stanvars used to define custom stancode in brms. By default uses the code designed for the model class being fit (as specified using id_stancode).

dry

Logical, defaults to TRUE. For testing purposes should just the stan code be output with not fitting done.

...

Additional parameters passed to brms::brm.

Value

A "brmsfit" object or stan code (if dry = TRUE).

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[, deaths := as.integer(shift(cases, 5) * 0.1)]
dt[is.na(deaths), deaths := 0]

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

# fit the convolution model using a Poisson observation model
fit <- idbrm(data = dt, family = poisson(link = "identity"))


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