Skip to contents

Reference date logit hazard reporting model module

Usage

enw_reference(
  parametric = ~1,
  distribution = c("lognormal", "none", "exponential", "gamma", "loglogistic"),
  non_parametric = ~0,
  data
)

Arguments

parametric

A formula (as implemented in enw_formula()) describing the parametric reference date delay model. This can use features defined by report date as defined in metareference as produced by enw_preprocess_data(). Note that this formula will be applied to all summary statistics of the chosen parametric distribution but each summary parameter will have separate effects. Use ~ 0 to not use a parametric model (note not recommended until the non_parametric model is implemented).

distribution

A character vector describing the parametric delay distribution to use. Current options are: "none", "lognormal", "gamma", "exponential", and "loglogistic", with the default being "lognormal".

non_parametric

A formula (as implemented in enw_formula()) describing the non-parametric logit hazard model. This can use features defined by reference date and by delay. It draws on a linked data.frame using metareference and metadelay as produced by enw_preprocess_data(). When an effect per delay is specified this approximates the cox proportional hazard model in discrete time with a single strata. Note that this model is currently not available for users.

data

Output from enw_preprocess_data().

Value

A list containing the supplied formulas, data passed into a list describing the models, a data.frame describing the priors used, and a function that takes the output data and priors and returns a function that can be used to sample from a tightened version of the prior distribution.

See also

Examples

enw_reference(data = enw_example("preprocessed"))
#> $formula
#> $formula$parametric
#> [1] "~1"
#> 
#> 
#> $data
#> $data$refp_fdesign
#>   (Intercept)
#> 1           1
#> 
#> $data$refp_fintercept
#> [1] 1
#> 
#> $data$refp_fnrow
#> [1] 1
#> 
#> $data$refp_findex
#>  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [39] 1 1 1
#> 
#> $data$refp_fnindex
#> [1] 41
#> 
#> $data$refp_fncol
#> [1] 0
#> 
#> $data$refp_rdesign
#>      (Intercept)
#> attr(,"assign")
#> [1] 0
#> 
#> $data$refp_rncol
#> [1] 0
#> 
#> $data$model_refp
#> [1] 2
#> 
#> 
#> $priors
#>             variable
#> 1:     refp_mean_int
#> 2:       refp_sd_int
#> 3: refp_mean_beta_sd
#> 4:   refp_sd_beta_sd
#>                                                       description
#> 1:         Log mean intercept for parametric reference date delay
#> 2: Log standard deviation for the parametric reference date delay
#> 3:    Standard deviation of scaled pooled parametric mean effects
#> 4:      Standard deviation of scaled pooled parametric sd effects
#>             distribution mean sd
#> 1:                Normal  1.0  1
#> 2: Zero truncated normal  0.5  1
#> 3: Zero truncated normal  0.0  1
#> 4: Zero truncated normal  0.0  1
#> 
#> $inits
#> function (data, priors) 
#> {
#>     priors <- enw_priors_as_data_list(priors)
#>     fn <- function() {
#>         init <- list(refp_mean_int = numeric(0), refp_sd_int = numeric(0), 
#>             refp_mean_beta = numeric(0), refp_sd_beta = numeric(0), 
#>             refp_mean_beta_sd = numeric(0), refp_sd_beta_sd = numeric(0))
#>         if (data$model_refp > 0) {
#>             init$refp_mean_int <- array(rnorm(1, priors$refp_mean_int[1], 
#>                 priors$refp_mean_int[2]/10))
#>         }
#>         if (data$model_refp > 1) {
#>             init$refp_sd_int <- array(abs(rnorm(1, priors$refp_sd_int[1], 
#>                 priors$refp_sd_int[2]/10)))
#>         }
#>         init$refp_mean <- rep(init$refp_mean_int, data$refp_fnrow)
#>         init$refp_sd <- rep(init$refp_sd_int, data$refp_fnrow)
#>         if (data$refp_fncol > 0) {
#>             init$refp_mean_beta <- array(rnorm(data$refp_fncol, 
#>                 0, 0.01))
#>             if (data$model_refp > 1) {
#>                 init$refp_sd_beta <- array(rnorm(data$refp_fncol, 
#>                   0, 0.01))
#>             }
#>         }
#>         if (data$refp_rncol > 0) {
#>             init$refp_mean_beta_sd <- array(abs(rnorm(data$refp_rncol, 
#>                 priors$refp_mean_beta_sd_p[1], priors$refp_mean_beta_sd_p[2]/10)))
#>             if (data$model_refp > 1) {
#>                 init$refp_sd_beta_sd <- array(abs(rnorm(data$refp_rncol, 
#>                   priors$refp_sd_beta_sd_p[1], priors$refp_sd_beta_sd_p[2]/10)))
#>             }
#>         }
#>         return(init)
#>     }
#>     return(fn)
#> }
#> <bytecode: 0x55927f15dbb0>
#> <environment: 0x559280451700>
#>