Convert a named list of parameter values and a corresponding `map_words` specification into a list of factor maps suitable for TMB's `map` argument. Supports fixing all elements, tying elements, leaving parameters free, or providing explicit numeric/factor patterns.

make_tmb_map(params, map_words)

Arguments

params

Named list of model parameters (vectors or matrices) as used when building a TMB model.

map_words

Named list specifying mapping rules for parameters. Supported values include: - "all" or "fixed": fix all elements of the parameter - "tied", "shared", or "constant": tie all elements to a single level - "none" or "free": leave parameter free (no map entry created) - numeric/factor vector or matrix: explicit pattern defining groups/levels

Value

A named list of factor objects (one per parameter) representing the mapping to be passed to TMB's `map` argument. Parameters with "none"/"free" are omitted (left free).

Examples

params <- list(beta = rep(0, 3), Sigma = matrix(0, 2, 2))
make_tmb_map(params, list(beta = "shared", Sigma = "none"))
#> $beta
#> [1] 1 1 1
#> Levels: 1
#>