Setup hyperparameters for GLMTree: model-based recursive partitioning, a tree carrying a generalized linear model in each leaf.
Usage
setup_GLMTree(
alpha = 0.05,
minsize = NULL,
maxdepth = NULL,
mtry = NULL,
trim = 0.1,
prune = NULL,
numsplit = "left",
catsplit = "binary",
ordinal = "chisq",
ifw = FALSE,
regressors = NULL,
partitioning_variables = NULL,
bonferroni = TRUE,
breakties = FALSE,
restart = TRUE,
dfsplit = TRUE,
vcov = "opg",
nrep = 10000L
)Arguments
- alpha
(Tunable) Numeric (0, 1]: Significance level a parameter-instability test must reach before a node is split.
- minsize
(Tunable) Optional Integer [1, Inf): Fewest cases a node may hold. NULL uses ten times the number of parameters in a leaf's model.
- maxdepth
(Tunable) Optional Integer [1, Inf): Deepest the tree may grow. NULL is unlimited.
- mtry
(Tunable) Optional Integer [1, Inf): Partitioning variables sampled at each node. NULL tests every one.
- trim
(Tunable) Numeric [0, Inf): Trimming for the split-point search; a fraction of cases below 1, a count at or above it.
- prune
(Tunable) Optional Character {"AIC", "BIC"}: Post-prune the grown tree by an information criterion. NULL keeps every split.
- numsplit
(Tunable) Character {"left", "center"}: Where a numeric split is placed.
- catsplit
(Tunable) Character {"binary", "multiway"}: How a categorical variable is split.
- ordinal
(Tunable) Character {"chisq", "max", "L2"}: Test statistic for an ordered partitioning variable.
- ifw
(Tunable) Logical: If TRUE, use Inverse Frequency Weighting in classification.
- regressors
Optional Character vector: Features entering the linear model in each leaf. NULL uses every feature.
- partitioning_variables
Optional Character vector: Features the tree may split on. NULL uses every feature.
- bonferroni
Logical: If TRUE, Bonferroni-adjust the test p-values for the number of partitioning variables.
- breakties
Logical: If TRUE, break ties in numeric partitioning variables by adding noise.
- restart
Logical: If TRUE, restart each leaf's model from scratch rather than from its parent's fit.
- dfsplit
Logical: If TRUE, count each split against the degrees of freedom when pruning.
- vcov
Character {"opg", "info", "sandwich"}: Covariance estimator the instability test is built on.
- nrep
Integer [1, Inf): Simulation replicates for the p-value of an ordinal split statistic.
Details
Where a decision tree predicts a constant in each leaf, a GLMTree fits a
regression there, so the model reads as "in this subgroup, these are the
coefficients". partykit::lmtree() fits a regression, partykit::glmtree()
a binary logistic one; rtemis selects between them from the outcome.
How it splits
Not by loss reduction. A node is split when a parameter-instability test
says its model's coefficients are not constant across a candidate
partitioning variable – a structural change test, at significance level
alpha. That is the method's distinguishing feature and the source of both
its strengths and its limits:
- It has a hypothesis-testing foundation
Splits carry p-values, and
alphais a significance level with a direct interpretation.- It sees a slope change with no shift in the mean
Which a tree splitting on the response cannot: there is nothing in the mean to find.
- It needs statistical power
With few cases, many partitioning variables, or both, the tests do not reach
alphaand the tree does not split at all – returning a single global model.
When it will not split, check minsize before alpha
The default minsize is ten times the number of parameters in a leaf's
model, and that scales with the number of regressors. A split has to leave
minsize cases on each side, so with p regressors no split is possible
below n = 20 * (p + 1) – 420 cases at 20 regressors, whatever alpha
says. A tree that returns one leaf on a wide design has usually hit this,
not the significance level, and raising alpha will not move it. Set
minsize directly, or narrow regressors.
regressors and partitioning_variables are separable, and the separation
is the point: the model in each leaf need not read the variables the tree
splits on. Both default to every feature.
Interpretability
Every leaf carries a full model over regressors – there is no selection or
shrinkage, so a leaf holds one coefficient per regressor whether or not it
earned one. Restrict regressors to keep that number down.
What it does not provide
No variable-importance measure: partykit has one for cforest and for
constant-fit trees, and none for a model-based tree. get_varimp() therefore
returns NULL, and get_varimp(explain(mod, newdata)) is the route to a
per-feature measure.
References
Zeileis A, Hothorn T, Hornik K (2008). Model-Based Recursive Partitioning. Journal of Computational and Graphical Statistics, 17(2), 492-514. doi:10.1198/106186008X319331
Examples
glmtree_hyperparams <- setup_GLMTree(alpha = 0.01)
glmtree_hyperparams#> <GLMTreeHyperparameters>
#> hyperparameters:
#> alpha: <nmr> 0.01
#> bonferroni: <lgc> TRUE
#> trim: <nmr> 0.10
#> breakties: <lgc> FALSE
#> restart: <lgc> TRUE
#> dfsplit: <lgc> TRUE
#> numsplit: <chr> left
#> catsplit: <chr> binary
#> ordinal: <chr> chisq
#> vcov: <chr> opg
#> nrep: <int> 10000
#> ifw: <lgc> FALSE
#> unset: <chr> regressors, partitioning_variables, minsize, maxdepth, mtry, prune
#> tunable_hyperparameters: <int> 10
#> fixed_hyperparameters: <int> 8
#> tuned: <int> -1
#> resampled: <int> 0
#> n_workers: <int> 1
#>
#> No search values defined for tunable hyperparameters.