View source: R/decide_variable_type_iterative.R
decide_variable_type_iterative | R Documentation |
A stepwise variable-selection method that iteratively chooses each variable's best form:
"linear"
, single-split "dummy"
, or double-split ("middle=1") dummy,
based on AIC/BIC improvement. Supports "forward", "backward", or "both" strategies.
decide_variable_type_iterative(
X,
Y,
minsplit = 5,
direction = c("backward", "forward", "both"),
criterion = c("AIC", "BIC"),
exclude_vars = NULL,
verbose = FALSE,
...
)
X |
A data frame of predictors (no response). |
Y |
A numeric vector (the response). |
minsplit |
Minimum number of observations in a node to consider splitting. Default = 5. |
direction |
Stepwise strategy: |
criterion |
A character string: either |
exclude_vars |
A character vector of variable names to exclude from dummy transformations.
These variables will always be treated as linear. Default = |
verbose |
Logical; if |
... |
Additional arguments (currently unused). |
Dummy forms come from a shallow (maxdepth = 2
) rpart
tree fit to the partial
residuals of the current model. We extract up to two splits:
Single cutoff dummy (e.g., x >= c
)
Double cutoff dummy (e.g., c1 < x < c2
)
The function then picks the form (linear, single-split dummy, or double-split dummy)
that yields the lowest AIC/BIC. Variables listed in exclude_vars
will be forced to remain
linear (dummy transformations are never attempted).
A named list of decisions, where each element is a list with:
Either "linear"
or "dummy"
.
A numeric vector of length 1 or 2 (the chosen split points).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.