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 list of fixed effects. (Character) Max. limit of 8 effects when interactions are included! A fixed effect name cannot contain: white spaces, "*" or "+". Effects in sublists will be interchanged. This can be useful, when we have multiple versions of a predictor (e.g. x1 and log(x1)) that we do not wish to have in the same formula. Example of interchangeable effects: list( list( "x1", "log_x1" ), "x2", "x3" ) 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 5 when interactions are included! max_interaction_size Maximum number of effects in an interaction. (Integer) Max. limit of 3. Use this to limit the n-way interactions allowed. 0 or 1 excludes interactions all together. 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
)



[Package cvms version 1.3.3 Index]