Shortcuts to parameterise a model with g3_param

g3_parameterized(
        name,
        by_stock = FALSE,
        by_predator = FALSE,
        by_year = FALSE,
        by_step = FALSE,
        by_age = FALSE,
        exponentiate = FALSE,
        avoid_zero = FALSE,
        scale = 1,
        offset = 0,
        ...)

Arguments

name

Suffix for parameter name.

by_stock

Should there be individual parameters per-stock?

FALSE

No

TRUE

Produce a "stock_name.name" parameter

character vector

Select the stock name_part(s) to use, e.g. to produce "stock_species.name" parameter with "species"

List of g3_stock objects

Produce a parameter that applies to all given stocks

by_predator

Should there be individual parameters per-predator (read: per-fleet) stock?

FALSE

No

TRUE

Produce a "fleet_stock_name.name" parameter

character vector

Select the stock name_part(s) to use, e.g. to produce "fleet_country.name" parameter with "country"

List of g3_stock objects

Produce a parameter that applies to all given stocks

by_year

Should there be individual parameters per model year?

FALSE

No

TRUE

Produce a "name.1998" parameter for each year the model runs

1998:2099

Override the year range, so when projecting there will be sufficient parameters available.

by_step

Should there be individual parameters per step within years?

FALSE

No

TRUE

Produce a "name.1" seasonal parameter for each step, or "name.1998.1" for every timestep in the model if combined with by_year.

by_age

Should there be individual parameters per stock age?

FALSE

No

TRUE

Produce a "name.4" parameter for each age of the stock(s) in by_stock

exponentiate

Use exp(value) instead of the raw parameter value. Will add "_exp" to the parameter name.

avoid_zero

If TRUE, wrap parameter with avoid_zero

scale

Use scale * value instead of the raw parameter value. Either a numeric constant or character. If character, add another parameter for scale, using the same by_stock value.

offset

Use value + offset instead of the raw parameter value Either a numeric constant or character. If character, add another parameter for offset, using the same by_stock value.

...

Additional parameters passed through to g3_param, e.g. optimise, random, ...

Details

The function provides shortcuts to common formulas used when parameterising a model.

Value

A formula object defining the given parameters

Examples

library(magrittr)
stock_a <- g3_stock(c(species = 'stock', 'aaa'), seq(10, 35, 5)) %>% g3s_age(1, 10)
stock_b <- g3_stock(c(species = 'stock', 'bbb'), seq(10, 35, 5)) %>% g3s_age(1, 10)

# Not by anything, so just a regular parameter
g3_parameterized('K')
#> g3_param("K")

# by_stock, so will use stock_prepend() to rename variables
g3_parameterized('K', by_stock = TRUE)
#> stock_prepend(stock, g3_param("K"), name_part = NULL)

# Adding by_year or by_age turns it into a table
g3_parameterized('K', by_stock = TRUE, by_year = TRUE, by_age = TRUE)
#> stock_prepend(stock, g3_param_table("K", expand.grid(cur_year = seq(start_year, 
#>     end_year), age = seq(stock__minage, stock__maxage))), name_part = NULL)

# Can specify the name parts you want
g3_parameterized('K', by_stock = 'species', by_year = TRUE)
#> stock_prepend(stock, g3_param_table("K", expand.grid(cur_year = seq(start_year, 
#>     end_year))), name_part = "species")

# Can give a list of stocks, in which case it works out name parts for you
g3_parameterized('K', by_stock = list(stock_a, stock_b))
#> stock_prepend("stock", g3_param("K"))
g3_parameterized('K', by_stock = list(stock_a, stock_b), by_age = TRUE)
#> stock_prepend("stock", g3_param_table("K", expand.grid(age = seq(min(stock_aaa__minage, 
#>     stock_bbb__minage), max(stock_aaa__maxage, stock_bbb__maxage)))))