decide_variable_type_iterative {SplitWise} | R Documentation |
Decide Variable Type (Iterative)
Description
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.
Usage
decide_variable_type_iterative(
X,
Y,
minsplit = 5,
direction = c("backward", "forward", "both"),
criterion = c("AIC", "BIC"),
exclude_vars = NULL,
verbose = FALSE,
...
)
Arguments
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). |
Details
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).
Value
A named list of decisions, where each element is a list with:
- type
Either
"linear"
or"dummy"
.- cutoff
A numeric vector of length 1 or 2 (the chosen split points).