e_model_all_subsets_formula: All model subsets

View source: R/e_model_all_subsets_formula.R

e_model_all_subsets_formulaR Documentation

All model subsets

Description

Return all possible model subsets based on specified model scopes.

Usage

e_model_all_subsets_formula(
  x_var_names = NULL,
  y_var_name = NULL,
  var_formula = NULL,
  max_scope = c("always", "FO", "TWI", "PQ", "SO", "one_TWI", "only_TWI", "only_PQ",
    "only_SO", "only_one_TWI")[3],
  sw_return = c("both", "formula", "table")[1]
)

Arguments

x_var_names

a character list of variable names or list of character lists. If a list of multiple formulas or character lists is provided, then each is subject to the max_scope independently, or each can have it's own max_scope.

y_var_name

a character string

var_formula

NOT YET IMPLEMENTED

max_scope

one of or a list (corresponding to x_var_names) of "always" to always keep this full list (no binary subsets), "FO" for first-order (main) effects, "TWI" for two-way interactions, "PQ" for pure quadratic terms (squares of the "FO"), "SO" for all terms in "FO", "TWI", and "PQ", and "one_TWI" for two-way interactions with only the first in the list. The options that start with "only_" must be used with the same x_var_names variables as a subset in an "always" list. For example, c("a", "b") specified as both "always" and "only_TWI" will always keep the main effects performing selection only on the TWIs.

sw_return

return a list of "formula", or a "table" of x-variable combinations, or a list of "both"

Value

         a list of functions

Examples

# Two-way interaction model, return formulas
e_model_all_subsets_formula(
    x_var_names = c("a", "b", "c")
  , y_var_name  = "z"
  , var_formula = NULL
  , max_scope   = "TWI"
  , sw_return   = c("both", "formula", "table")[2]
  )
# Two-way interaction model, return table of x-variable combinations
e_model_all_subsets_formula(
    x_var_names = c("a", "b", "c")
  , y_var_name  = "z"
  , var_formula = NULL
  , max_scope   = "TWI"
  , sw_return   = c("both", "formula", "table")[3]
  )

# Two variables always in the model with a second-order model of two others
e_model_all_subsets_formula(
    x_var_names = list(c("a", "b"), c("c", "d"))
  , y_var_name  = "z"
  , var_formula = NULL
  , max_scope   = list("always", "SO")
  , sw_return   = c("both", "formula", "table")[3]
  )
# One variable in two-way interactions with the other variables
e_model_all_subsets_formula(
    x_var_names = list(c("a", "b", "c", "d"))
  , y_var_name  = "z"
  , var_formula = NULL
  , max_scope   = list("one_TWI")
  , sw_return   = c("both", "formula", "table")[3]
  )
# Four variables always in the model (a, b, c, d)
#   with selection only on the two second-order variables (c, d),
#   with TWI on the two variables (e, f)
e_model_all_subsets_formula(
    x_var_names = list(c("a", "b", "c", "d"), c("c", "d"), c("e", "f"))
  , y_var_name  = "z"
  , var_formula = NULL
  , max_scope   = list("always", "only_SO", "TWI")
  , sw_return   = c("both", "formula", "table")[3]
  )
## Not run: 
# Large example showing all options
e_model_all_subsets_formula(
    x_var_names = list(letters[1:2], letters[4:5], letters[7:8], letters[10:11], letters[13:14])
  , y_var_name  = "z"
  , var_formula = NULL
  , max_scope   = list("always", "FO", "TWI", "PQ", "SO")
  , sw_return   = c("both", "formula", "table")[3]
  )

## End(Not run)


erikerhardt/erikmisc documentation built on April 17, 2025, 10:48 a.m.