Skip to contents

Calculates the negative sum of log prior densities for model parameters.

Usage

evaluate_priors(parameters, priors)

Arguments

parameters

A named list of parameter values to be passed to MakeADFun. Can be generated using the get_parameters function.

priors

A named list of prior specifications for the parameters. Each element should be a list with elements type, par1, par2, and index. Can be generated using the get_priors function.

Value

A numeric scalar containing the negative sum of log prior densities.

Details

Supported type values are "normal", "student", "lognormal", and "beta". Prior indices refer to positions in parameters. Each prior must be named, and its name must match the parameter at its stored index. This causes stale prior lists to fail closed if parameters are reordered. Scale parameters must be positive; beta means must lie strictly between zero and one.

Examples

parameters <- list(par_log_m4 = log(0.167))
priors <- list(
  par_log_m4 = list(type = "normal", par1 = log(0.12), par2 = 0.4, 
                    index = which("par_log_m4" == names(parameters)))
)
evaluate_priors(parameters = parameters, priors = priors)
#> [1] 0.3439966