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) == 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 actions will define the following variables in your model:

report_stock__instance_name

Results of collating input_stock__instance_name, where instance_name is defined by the first instance variable in report_f. For example, if report_f is ~input_stock__num, then we will report report_stock__num.

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_detailed

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)))