Add report to a g3 model

g3a_report_stock(report_stock, input_stock, report_f,
    include_adreport = FALSE,
    run_f = TRUE,
    run_at = g3_action_order$report)

g3a_report_history(
        actions,
        var_re = "__num$|__wgt$",
        out_prefix = "hist_",
        run_f = TRUE,
        run_at = g3_action_order$report)

g3a_report_detail(actions,
    run_f = quote( g3_param('report_detail', optimise = FALSE, value = 1L,
        source = "g3a_report_detail") == 1 ),
    abundance_run_at = g3_action_order$report_early,
    run_at = g3_action_order$report)

Arguments

report_stock

The g3_stock to aggregate into

input_stock

The g3_stock that will be aggregated

report_f

formula specifying what to collect, for instance g3_formula( stock_ss(input_stock__num) ) or g3_formula( stock_ss(input_stock__wgt) ).

actions

List of actions that model will consist of.

var_re

Regular expression specifying variables to log history for.

out_prefix

Prefix to add to history report output, e.g. hist_ling_imm__num.

include_adreport

Should the aggregated value get ADREPORT'ed?

abundance_run_at

Integer order that abundance will be collected within the model. Note that by default it's collected at the start, not the end

run_f

formula specifying a condition for running this action, default always runs.

run_at

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

Details

The g3a_report_detail defines a selection of default reports from your model, using g3a_report_history:

*_surveyindices_*__params

The slope/intercept as used by g3l_distribution_surveyindices_log

step_lengths
*_weight

The weighting of likelihood components

nll_*

Breakdown of nll for each likelihood component

dstart_*__num

Abundance in numbers, at start of each model step

dstart_*__wgt

Mean weight of individuals, at start of each model step

detail_*__renewalnum

Numbers produced by renewal at each model step

detail_*__spawnednum

Numbers produced by spawning at each model step

detail_*_*__cons

Total biomass of prey consumed by predator, at each model step

detail_*_*__suit

Total suitable biomass of prey for predator, at each model step

The reports produced by g3a_report_history will vary based on the provided inputs. A model can have any number of g3a_report_* actions, so long as the calling arguments are different. For instance, run_f = ~age == 5 and run_f = ~age == 7.

Value

g3a_report_stock

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

  1. Iterate over input_stock, collecting data into report_stock

  2. Add the contents of report_stock__instance_name to the model report

g3a_report_history

An action (i.e. list of formula objects) that will store the current state of each variable found matching var_re.

g3a_report_detail

Uses g3a_report_history to generate detailed reports suitable for use in g3_fit.

See also

Examples

ling_imm <- g3_stock('ling_imm', seq(20, 156, 4)) %>% g3s_age(3, 10)

# Report that aggregates ages together
agg_report <- g3_stock('agg_report', c(1)) %>%
    g3s_agegroup(list(young = 1:3, old = 4:5)) %>%
    g3s_time(year = 2000:2002)
# Generate dissaggregated report by cloning the source stock, adding time
raw_report <- g3s_clone(ling_imm, 'raw_report') %>%
    g3s_time(year = 2000:2002)

actions <- list(
    g3a_age(ling_imm),
    g3a_report_stock(agg_report, ling_imm, g3_formula( stock_ss(ling_imm__num) ),
        include_adreport = TRUE),
    g3a_report_stock(raw_report, ling_imm, g3_formula( stock_ss(ling_imm__num) )))
# "raw_report__num" and "agg_report__num" will be available in the model report
# In addition, agg_report__num will be included in TMB::sdreport() output

# Report history of all "__num" and "__wgt" variables
actions <- c(actions, list(g3a_report_history(actions)))

# Report history of just "ling_imm__num"
actions <- c(actions, list(g3a_report_history(actions, "^ling_imm__num$")))

# Add a detail report suitable for g3_fit
actions <- c(actions, list(g3a_report_detail(actions)))