Add likelihood components for random effects

g3l_random_dnorm(
        nll_name,
        param_f,
        mean_f = 0,
        sigma_f = 1,
        log_f = TRUE,
        period = 'auto',
        nll_breakdown = FALSE,
        weight = g3_parameterized(paste0(nll_name, "_weight"),
            optimise = FALSE, value = 1),
        run_at = g3_action_order$likelihood)

g3l_random_walk(
        nll_name,
        param_f,
        sigma_f = 1,
        log_f = TRUE,
        period = 'auto',
        nll_breakdown = FALSE,
        weight = g3_parameterized(paste0(nll_name, "_weight"),
            optimise = FALSE, value = 1),
        run_at = g3_action_order$likelihood)

Arguments

param_f

A formula representing the value to apply dnorm to. Invariably a g3_param for g3l_random_dnorm, a g3_param_table with cur_year for g3l_random_walk.

mean_f

A formula representing mean in dnorm.

sigma_f

A formula representing sigma in dnorm.

log_f

A formula representing log in dnorm.

period

When dnorm should be recalculated. Once per year every step, or single for once. The default, auto, will assume the input is generated by g3_parameterized and will derive the most appropriate option.

nll_name

Character string, used to define the variable name for dnorm output.

nll_breakdown

Should the nll report be broken down by time? TRUE / FALSE

weight

Weighting applied to this likelihood component.

run_at

Integer order that actions will be run within model, see g3_action_order.

Details

The model report will contain nll_random_dnorm_dnorm_lin__dnorm, the results of applying dnorm. If nll_breakdown is TRUE, this will be an array with one entry per timestep.

Value

g3l_random_dnorm

An action (i.e. list of formula objects) that will...

  1. On the final model step, calculate dnorm(param_f, mean_f, sigma_f) & add to nll

g3l_random_walk

An action (i.e. list of formula objects) that will...

  1. Calculate dnorm(param_f, previous param_f, sigma_f) (at final year if period = year)

  2. Add to nll.

Examples


likelihood_actions <- list(
    # Calculate dnorm() for the dnorm_log parameter
    g3l_random_dnorm('dnorm_log',
        g3_parameterized('dnorm_log', value = 0, random = TRUE),
        mean_f = 0),

    # Treat the walk_year.xxxx parameters as a random walk
    g3l_random_walk('walk_year',
        g3_parameterized('walk_year', by_year = TRUE, value = 0, random = TRUE))
)