Skip to contents

[Stable] Defines a list specifying the structure of the observation model. Custom settings can be supplied which override the defaults.

Usage

obs_opts(
  family = c("negbin", "poisson"),
  phi = list(mean = 0, sd = 0.25),
  weight = 1,
  week_effect = TRUE,
  week_length = 7,
  scale = 1,
  na = c("missing", "accumulate"),
  likelihood = TRUE,
  return_likelihood = FALSE
)

Arguments

family

Character string defining the observation model. Options are Negative binomial ("negbin"), the default, and Poisson.

phi

Overdispersion parameter of the reporting process, used only if familiy is "negbin". Can be supplied either as a single numeric value (fixed overdispersion) or a list with numeric elements mean (mean) and standard deviation (sd) defining a normally distributed prior. Internally parameterised such that the overdispersion is one over the square of this prior overdispersion. Defaults to a list with elements mean = 0 and sd = 0.25.

weight

Numeric, defaults to 1. Weight to give the observed data in the log density.

week_effect

Logical defaulting to TRUE. Should a day of the week effect be used in the observation model.

week_length

Numeric assumed length of the week in days, defaulting to 7 days. This can be modified if data aggregated over a period other than a week or if data has a non-weekly periodicity.

scale

Scaling factor to be applied to map latent infections (convolved to date of report). Can be supplied either as a single numeric value (fixed scale) or a list with numeric elements mean (mean) and standard deviation (sd) defining a normally distributed scaling factor. Defaults to 1, i.e. no scaling.

na

Character. Options are "missing" (the default) and "accumulate". This determines how NA values in the data are interpreted. If set to "missing", any NA values in the observation data set will be interpreted as missing and skipped in the likelihood. If set to "accumulate", modelled observations will be accumulated and added to the next non-NA data point. This can be used to model incidence data that is reported at less than daily intervals. If set to "accumulate", the first data point is not included in the likelihood but used only to reset modelled observations to zero.

likelihood

Logical, defaults to TRUE. Should the likelihood be included in the model.

return_likelihood

Logical, defaults to FALSE. Should the likelihood be returned by the model.

Value

An <obs_opts> object of observation model settings.

Examples

# default settings
obs_opts()
#> $family
#> [1] "negbin"
#> 
#> $phi
#> $phi$mean
#> [1] 0
#> 
#> $phi$sd
#> [1] 0.25
#> 
#> 
#> $weight
#> [1] 1
#> 
#> $week_effect
#> [1] TRUE
#> 
#> $week_length
#> [1] 7
#> 
#> $scale
#> $scale$mean
#> [1] 1
#> 
#> $scale$sd
#> [1] 0
#> 
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] TRUE
#> 
#> $return_likelihood
#> [1] FALSE
#> 
#> attr(,"class")
#> [1] "obs_opts" "list"    

# Turn off day of the week effect
obs_opts(week_effect = TRUE)
#> $family
#> [1] "negbin"
#> 
#> $phi
#> $phi$mean
#> [1] 0
#> 
#> $phi$sd
#> [1] 0.25
#> 
#> 
#> $weight
#> [1] 1
#> 
#> $week_effect
#> [1] TRUE
#> 
#> $week_length
#> [1] 7
#> 
#> $scale
#> $scale$mean
#> [1] 1
#> 
#> $scale$sd
#> [1] 0
#> 
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] TRUE
#> 
#> $return_likelihood
#> [1] FALSE
#> 
#> attr(,"class")
#> [1] "obs_opts" "list"    

# Scale reported data
obs_opts(scale = list(mean = 0.2, sd = 0.02))
#> $family
#> [1] "negbin"
#> 
#> $phi
#> $phi$mean
#> [1] 0
#> 
#> $phi$sd
#> [1] 0.25
#> 
#> 
#> $weight
#> [1] 1
#> 
#> $week_effect
#> [1] TRUE
#> 
#> $week_length
#> [1] 7
#> 
#> $scale
#> $scale$mean
#> [1] 0.2
#> 
#> $scale$sd
#> [1] 0.02
#> 
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] TRUE
#> 
#> $return_likelihood
#> [1] FALSE
#> 
#> attr(,"class")
#> [1] "obs_opts" "list"