| prune_stackM | R Documentation |
Applies the Stack / M correction of Sherlock et al. (2026) to a conditional
inference tree fitted on stacked multiply imputed data. Every node-level
test statistic is divided by M, the p-values are recomputed from the
chi-square reference distribution ctree uses, the multiplicity adjustment
over candidate splitting variables is reapplied, and the tree is compressed
bottom-up.
prune_stackM(tree, m, alpha = 0.05, verbose = TRUE)
tree |
A |
m |
Integer. Number of imputations. |
alpha |
Numeric. Nominal significance threshold. |
verbose |
Logical. Report how many splits were retained. |
A list with the pruned tree and a node_stats data frame with one
row per internal node of the unpruned tree, recording the variable split
on, its raw and rescaled statistics, the degrees of freedom and how they
were obtained, the p-values before and after correction, the smallest
corrected p-value over all candidates at that node, and whether the split
was retained. The full per-candidate table is attached as
attr(node_stats, "candidates").
ctree splits a node when any candidate variable meets alpha, so that
is the rule reapplied here: all candidates tested at the node are rescaled
and the smallest corrected p-value decides. Testing only the variable that
was split on would not be equivalent, because candidates carry different
degrees of freedom and rescaling can reorder them.
Pruning is bottom-up, as in the analysis for the paper. An internal node is collapsed only once all of its own internal descendants have been collapsed, so a node whose descendant survives the correction keeps its split.
With teststat = "quadratic" the node-level statistic is chi-square with
df equal to the rank of the covariance matrix of the linear statistic:
the outcome dimension for a numeric or ordered predictor (1 for a
univariate outcome, 2 for a bivariate outcome, and so on), and (L - 1)
times the outcome dimension for an unordered factor with L levels present
in the node. These are derived for every node and every candidate variable,
by inverting the (statistic, p-value) pairs partykit stored and falling
back on the structural rule where the stored p-value has underflowed to
zero, which happens routinely on stacked data.
Sherlock, P., et al. (2026). Beyond linear risk: A machine learning approach to understanding perinatal depression in context. Multivariate Behavioral Research, 1-16. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00273171.2026.2661244")}
set.seed(1)
n <- 300
d <- data.frame(x = stats::rnorm(n))
d$y1 <- stats::rnorm(n) + 1.2 * (d$x > 0)
d$y2 <- stats::rnorm(n) + 0.9 * (d$x > 0)
grown <- partykit::ctree(y1 + y2 ~ x, data = d)
out <- prune_stackM(grown, m = 5, verbose = FALSE)
out$node_stats
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.