get_formulas {enmpa} | R Documentation |
Get GLM formulas according to defined response types
Description
Generate GLM formulas for independent variables predicting a dependent variable, taking into account response types required. All possible combinations of variables can be created using arguments of the function.
Usage
get_formulas(dependent, independent, type = "l", mode = "moderate",
minvar = 1, maxvar = NULL)
get_formulas_main(dependent, independent, type = "l",
complex = FALSE, minvar = 1, maxvar = NULL)
aux_var_comb(var_names, minvar = 2, maxvar = NULL)
aux_string_comb(string)
Arguments
dependent |
(character) name of dependent variable. |
independent |
(character) vector of name(s) of independent variable(s). |
type |
(character) a character string that must contain "l", "p", "q" or a combination of them. l = lineal, q = quadratic, p = interaction between two variables. Default = "l". |
mode |
(character) (character) a character string to indicate the strategy to create the formulas for candidate models. Options are: "light", "moderate", "intensive", or "complex". Default = "moderate". |
minvar |
(numeric) minimum number of independent variables in formulas. |
maxvar |
(numeric) maximum number of independent variables in formulas. |
complex |
(logical) whether to return the most complex formula. |
var_names |
sames as |
string |
same as |
Details
mode
options determine what strategy to iterate the predictors
defined in type
for creating models:
-
light.– returns simple iterations of complex formulas.
-
moderate.– returns a comprehensive number of iterations.
-
intensive.– returns all possible combination. Very time-consuming for 6 or more independent variables.
-
complex.– returns only the most complex formula.
Value
A character vector containing the resulting formula(s).
Examples
# example variables
dep <- "sp"
ind <- c("temp", "rain", "slope")
# The most complex formula according to "type"
get_formulas(dep, ind, type = "lqp", mode = "complex")
# mode = 'light', combinations according to type
get_formulas(dep, ind, type = "lqp", mode = "light")
# mode = 'light', combinations according to type
get_formulas(dep, ind, type = "lqp", mode = "intensive")