combine_predictors {cvms} | R Documentation |
Generate model formulas by combining predictors
Description
Create model formulas with every combination
of your fixed effects, along with the dependent variable and random effects.
259,358
formulas have been precomputed with two- and three-way interactions
for up to 8
fixed effects, with up to 5
included effects per formula.
Uses the +
and *
operators, so lower order interactions are
automatically included.
Usage
combine_predictors(
dependent,
fixed_effects,
random_effects = NULL,
max_fixed_effects = 5,
max_interaction_size = 3,
max_effect_frequency = NULL
)
Arguments
dependent |
Name of dependent variable. (Character) |
fixed_effects |
Max. limit of A fixed effect name cannot contain: white spaces, Effects in sublists will be interchanged. This can be useful, when
we have multiple versions of a predictor (e.g. Example of interchangeable effects:
|
random_effects |
The random effects structure. (Character) Is appended to the model formulas. |
max_fixed_effects |
Maximum number of fixed effects in a model formula. (Integer) Max. limit of |
max_interaction_size |
Maximum number of effects in an interaction. (Integer) Max. limit of Use this to limit the A model formula can contain multiple interactions. |
max_effect_frequency |
Maximum number of times an effect is included in a formula string. |
Value
list
of model formulas.
E.g.:
c("y ~ x1 + (1|z)", "y ~ x2 + (1|z)",
"y ~ x1 + x2 + (1|z)", "y ~ x1 * x2 + (1|z)")
.
Author(s)
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
Examples
# Attach packages
library(cvms)
# Create effect names
dependent <- "y"
fixed_effects <- c("a", "b", "c")
random_effects <- "(1|e)"
# Create model formulas
combine_predictors(
dependent, fixed_effects,
random_effects
)
# Create effect names with interchangeable effects in sublists
fixed_effects <- list("a", list("b", "log_b"), "c")
# Create model formulas
combine_predictors(
dependent, fixed_effects,
random_effects
)