Skip to contents

[Stable] Takes the output of obs_opts() and converts it into a list understood by stan.

Usage

create_obs_model(obs = obs_opts(), dates)

Arguments

obs

A list of options as generated by obs_opts() defining the observation model. Defaults to obs_opts().

dates

A vector of dates used to calculate the day of the week.

Value

A list of settings ready to be passed to stan defining the Observation Model

See also

Examples

dates <- seq(as.Date("2020-03-15"), by = "days", length.out = 15)
# default observation model data
create_obs_model(dates = dates)
#> $model_type
#> [1] 1
#> 
#> $phi_mean
#> [1] 0
#> 
#> $phi_sd
#> [1] 1
#> 
#> $week_effect
#> [1] 7
#> 
#> $obs_weight
#> [1] 1
#> 
#> $obs_scale
#> [1] 0
#> 
#> $obs_scale_mean
#> [1] 1
#> 
#> $obs_scale_sd
#> [1] 0
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] 1
#> 
#> $return_likelihood
#> [1] 0
#> 
#> $day_of_week
#>  [1] 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7
#> 

# Poisson observation model
create_obs_model(obs_opts(family = "poisson"), dates = dates)
#> $model_type
#> [1] 0
#> 
#> $phi_mean
#> [1] 0
#> 
#> $phi_sd
#> [1] 1
#> 
#> $week_effect
#> [1] 7
#> 
#> $obs_weight
#> [1] 1
#> 
#> $obs_scale
#> [1] 0
#> 
#> $obs_scale_mean
#> [1] 1
#> 
#> $obs_scale_sd
#> [1] 0
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] 1
#> 
#> $return_likelihood
#> [1] 0
#> 
#> $day_of_week
#>  [1] 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7
#> 

# Applying a observation scaling to the data
create_obs_model(
 obs_opts(scale = list(mean = 0.4, sd = 0.01)), dates = dates
)
#> $model_type
#> [1] 1
#> 
#> $phi_mean
#> [1] 0
#> 
#> $phi_sd
#> [1] 1
#> 
#> $week_effect
#> [1] 7
#> 
#> $obs_weight
#> [1] 1
#> 
#> $obs_scale
#> [1] 1
#> 
#> $obs_scale_mean
#> [1] 0.4
#> 
#> $obs_scale_sd
#> [1] 0.01
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] 1
#> 
#> $return_likelihood
#> [1] 0
#> 
#> $day_of_week
#>  [1] 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7
#> 

# Apply a custom week week length
create_obs_model(obs_opts(week_length = 3), dates = dates)
#> $model_type
#> [1] 1
#> 
#> $phi_mean
#> [1] 0
#> 
#> $phi_sd
#> [1] 1
#> 
#> $week_effect
#> [1] 3
#> 
#> $obs_weight
#> [1] 1
#> 
#> $obs_scale
#> [1] 0
#> 
#> $obs_scale_mean
#> [1] 1
#> 
#> $obs_scale_sd
#> [1] 0
#> 
#> $accumulate
#> [1] 0
#> 
#> $likelihood
#> [1] 1
#> 
#> $return_likelihood
#> [1] 0
#> 
#> $day_of_week
#>  [1] 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2
#>