params.Rd
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,
...)
Suffix for parameter name.
Should there be individual parameters per-stock?
No
Produce a "stock_name.name"
parameter
Select the stock name_part(s) to use, e.g. to produce "stock_species.name"
parameter with "species"
g3_stock
objectsProduce a parameter that applies to all given stocks
Should there be individual parameters per-predator (read: per-fleet) stock?
No
Produce a "fleet_stock_name.name"
parameter
Select the stock name_part(s) to use, e.g. to produce "fleet_country.name"
parameter with "country"
g3_stock
objectsProduce a parameter that applies to all given stocks
Should there be individual parameters per model year?
No
Produce a "name.1998"
parameter for each year the model runs
Override the year range, so when projecting there will be sufficient parameters available.
Should there be individual parameters per step within years?
No
Produce a "name.1"
seasonal parameter for each step, or "name.1998.1"
for every timestep in the model if combined with by_year.
Should there be individual parameters per stock age?
No
Produce a "name.4"
parameter for each age of the stock(s) in by_stock
Use exp(value)
instead of the raw parameter value. Will add "_exp" to the parameter name.
If TRUE, wrap parameter with avoid_zero
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.
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, ...
The function provides shortcuts to common formulas used when parameterising a model.
A formula object defining the given parameters
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)))))