Learn R Programming

rtemis (version 1.4.3)

setup_GLMTree: Setup GLMTree Hyperparameters

Description

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
)

Value

GLMTreeHyperparameters object.

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.

How it splits

A node is split when a parameter-instability test, a structural change test at significance level alpha, rejects constancy of its model's coefficients across a candidate partitioning variable. Consequences:

It has a hypothesis-testing foundation

Splits carry p-values, and alpha is a significance level with a direct interpretation.

It detects a slope change with no shift in the mean

A tree that splits on the response mean does not.

It needs statistical power

With few cases, many partitioning variables, or both, the tests do not reach alpha and the tree does not split at all -- returning a single global model.

When it will not split, check <code>minsize</code> before <code>alpha</code>

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, for any alpha. On a wide design, a single-leaf tree results from this bound rather than from alpha. Set minsize directly, or narrow regressors.

regressors and partitioning_variables are set independently: the model in each leaf may use features other than those the tree splits on. Both default to every feature.

Interpretability

Every leaf carries a full model over regressors, with no selection or shrinkage: one coefficient per regressor. Restrict regressors to reduce the number of coefficients.

What it does not provide

partykit provides variable importance for cforest and for constant-fit trees, not for a model-based tree. get_varimp() returns NULL; get_varimp(explain(mod, newdata)) returns a per-feature measure.

Author

EDG

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.

References

Zeileis A, Hothorn T, Hornik K (2008). Model-Based Recursive Partitioning. Journal of Computational and Graphical Statistics, 17(2), 492-514. tools:::Rd_expr_doi("10.1198/106186008X319331")

Examples

Run this code
glmtree_hyperparams <- setup_GLMTree(alpha = 0.01)
glmtree_hyperparams

Run the code above in your browser using DataLab