| node_table | R Documentation |
Summarizes the nodes of a fitted ctree_stacked tree as a
data frame, giving for each node the sequence of splits that defines it,
its size in the stacked data, and its effective sample size on the
original scale (stacked size divided by the number of imputations
M).
Because a stacked dataset repeats every observation M times, node
sizes printed by print() and plot() are M times
larger than the number of observations they represent. Reporting those
numbers directly overstates precision. This function performs the
division so that node sizes can be reported and interpreted correctly.
node_table(object, terminal_only = TRUE, max_levels = NULL, digits = 3)
object |
An object of class |
terminal_only |
Logical. If |
max_levels |
Integer or |
digits |
Integer. Number of decimal places for outcome summaries. |
Note that effective_n is exact at the root and is an
observation-scale rescaling elsewhere. Because imputed values differ
across imputations, an individual's M rows are not guaranteed to
follow the same path down the tree, so effective_n should be read
as the node's size expressed on the original scale rather than as a
count of distinct individuals.
A data frame of class "ctreeMI_nodes" with one row per node and
the following columns:
node_idNode identifier, matching print() and
plot() output.
depthNumber of splits from the root to this node.
n_stackedNumber of rows in the stacked data.
effective_nn_stacked / M: the node size on the
scale of the original data. This is the number to report.
Node means for numeric responses, or the proportion in the second level for binary factor responses. One column per response variable, so multivariate outcomes are supported.
pathThe split conditions leading to the node, joined
by " & ", suitable for pasting into a manuscript table.
conditionsA list-column holding the same conditions as a character vector, for programmatic use.
Sherlock, P., Mansolf, M., Hofheimer, J., Hockett, C. W., O'Connor, T. G., Roubinov, D., Graff, J. C., Lai, J.-S., Bush, N. R., Wright, R. J., & Chiu, Y.-H. M. (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")}
ctree_stacked, report_ctreeMI
set.seed(1)
make_df <- function(i) {
set.seed(i)
n <- 200
x1 <- rnorm(n)
x2 <- factor(sample(c("A", "B", "C"), n, TRUE))
y <- 2 * (x1 > 0) + 1.5 * (x2 == "A") + rnorm(n)
data.frame(y = y, x1 = x1, x2 = x2)
}
imp_list <- lapply(1:10, make_df)
fit <- ctree_stacked(y ~ x1 + x2, data = imp_list, verbose = FALSE)
# Terminal nodes with effective sample sizes
node_table(fit)
# Truncate long factor level sets
node_table(fit, max_levels = 2)
# Include inner nodes
node_table(fit, terminal_only = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.