Skip to contents

Helper function to construct covariate model matrices from a list of two-sided formulas.

Usage

par_model_matrix(par_models, fish_data, center = TRUE, scale = TRUE)

Arguments

par_models

A list of two-sided formulas of the form theta ~ t1 + ... + tK, where theta is a parameter or state in a salmonIPM model that accepts covariates and t1 ... tK are terms involving variables in fish_data; see salmonIPM() for details.

fish_data

See salmonIPM(). In particular, the columns ... may be used on the right-hand side of formulas in par_models.

center

Logical indicating whether the terms in model matrices constructed from fish_data using the formulas in par_models should be centered. It is usually recommended to use the default (TRUE) so the baseline parameter estimate applies when predictors are at their sample means, but in some cases such as factor predictors center = FALSE may be appropriate.

scale

Logical indicating whether the terms in model matrices constructed from fish_data using the formulas in par_models should be scaled to have column SDs of 1.

Value

A named list of model matrices corresponding to the elements of par_models.

See also

salmonIPM() for specifying covariate effects via par_models, stan_data() for assembling input data including covariate model matrices