Skip to contents

Generates all possible linear models for a given set of predictor variables using the distance matrix as a response variable. The function allows for the user to specify the maximum number of variables in a model, which can be useful in cases where there are many predictors. The output is a data frame containing all the possible models, which can be passed to the fit_models function for fitting using a PERMANOVA approach.

Usage

make_models(vars, ncores = 2, k = NULL, verbose = TRUE)

Arguments

vars

A character vector of variables to use for modeling

ncores

An integer specifying the number of cores to use for parallel processing

k

maximum number of variables in a model, default is NULL

verbose

logical, defaults TRUE, sends messages about processing times

Value

A data frame containing all the possible linear permanova models

References

Anderson, M. J. (2001). A new method for non-parametric multivariate analysis of variance. Austral Ecology, 26(1), 32-46.

Examples

# \donttest{
make_models(
  vars = c("A", "B", "C", "D"),
  ncores = 2, verbose = FALSE
)
#>                        form
#> 1              Distance ~ A
#> 2              Distance ~ B
#> 3              Distance ~ C
#> 4              Distance ~ D
#> 5          Distance ~ A + B
#> 6          Distance ~ A + C
#> 7          Distance ~ A + D
#> 8          Distance ~ B + C
#> 9          Distance ~ B + D
#> 10         Distance ~ C + D
#> 11     Distance ~ A + B + C
#> 12     Distance ~ A + B + D
#> 13     Distance ~ A + C + D
#> 14     Distance ~ B + C + D
#> 15 Distance ~ A + B + C + D
#> 16             Distance ~ 1

# using k as a way to limit number of variables
make_models(
  vars = c("A", "B", "C", "D"),
  ncores = 2, k = 2, verbose = FALSE
)
#>                form
#> 1      Distance ~ A
#> 2      Distance ~ B
#> 3      Distance ~ C
#> 4      Distance ~ D
#> 5  Distance ~ A + B
#> 6  Distance ~ A + C
#> 7  Distance ~ A + D
#> 8  Distance ~ B + C
#> 9  Distance ~ B + D
#> 10 Distance ~ C + D
#> 11     Distance ~ 1
# }