Splitting whole clusters between the halves (cluster in split_holdout())
leaves half the clusters for confirmation, which is too few when clusters
are few. This release adds the alternative: split participants within every
cluster, grow the tree on within-cluster variation, and confirm three ways.
center_outcome() centers the outcome on its group mean within each
imputed dataset; a two-level factor or logical is coded 0/1 first. It
accepts the outcome types the confirmation accepts: numeric, two-level
factor or logical, and several of these together.ctree_stacked() gains center_by, which applies center_outcome()
before the tree is grown, so cluster-level variables cannot stand in for
differences between clusters. The grouping column is removed from a .
formula.confirm_ctreeMI() gains fixed: a column entered as fixed effects in the
omnibus and per-split models, so each test and contrast is estimated from
variation within its levels. Only the node and side coefficients are
tested; node estimates are not adjusted.confirm_within() runs the confirmation three ways, with cluster-robust
variance, with cluster fixed effects, and within each cluster alone, and
lines the results up by split with a reading for each.discover_confirm() gains within. With cluster and within = TRUE
it stratifies the split on the cluster, keeps the cluster identifier in the
imputation model, grows the tree with center_by = cluster, and confirms
with confirm_within(). The returned object gains a within element; its
confirmation element is the cluster-robust confirmation on the raw
outcome, so prune_unconfirmed() and report_confirm() work as before.confirm_ctreeMI() now confirms every outcome type ctree_stacked() can
grow a tree on. An ordered factor with three or more levels is modeled by
proportional-odds logistic regression (MASS::polr()), so each split is one
log cumulative odds ratio; an unordered factor with three or more levels by
multinomial logistic regression (nnet::multinom()), so each split is a
joint test of one log odds ratio per non-reference level, with the largest
reported in contrast and its level in the new contrast_level column.
Node estimates for these outcomes are the proportions in each level, one
row per node and level (new level column in nodes). outcome_type
accepts "ordinal" and "nominal", and "auto" resolves them from the
factor. Because sandwich has no methods for multinom, the
cluster-robust covariance for a nominal outcome is assembled within the
package from the per-observation scores; it supports vcov_type "HC0"
and "HC1" and agrees with sandwich::vcovCL() on a two-level problem.
center_outcome() scores an ordinal outcome and expands a nominal one into
centered indicators, and ctree_stacked() with center_by grows a
multivariate tree on those while keeping the user's formula for the
confirmation. MASS and nnet are added to Suggests.
A simulation with 5 to 20 clusters, equal and unequal cluster sizes, and
null, moderate and weak within-cluster effects compared the design with the
alternatives on the same data. The script and results are in the
package's GitHub repository, under simulations/.
Two vignettes are added: "Discover, then confirm", on the workflow and the outcome types it handles, and "Few clusters: the within-cluster design".
No existing default behavior has changed.
split_holdout() and discover_confirm() gain a cluster argument. When
observations are nested in a higher-level unit such as a school or district,
the split now assigns whole units to one half or the other, so that no unit
contributes to both the discovery and confirmation samples. Stratification
by a cluster-level variable is supported. discover_confirm() also removes
the cluster identifier from the imputation model, where it would otherwise
be treated as a predictor.
confirm_ctreeMI() gains the same cluster argument. When given, every
fitted model's covariance matrix is replaced by a cluster-robust estimate
from sandwich::vcovCL() before pooling, so that the omnibus test, the
per-split tests, the contrasts and the node estimates all account for
within-cluster correlation. The number of clusters behind each node and
each split is reported. A warning is issued below twenty clusters.
The Li-Raghunathan-Rubin test and Rubin's rules are implemented within the
package rather than delegated to mice::D1() and mice::pool(), which
call vcov() on each model internally and so cannot accept a
cluster-robust covariance. The multivariate test carries the Reiter (2007)
small-sample adjustment and the scalar contrasts the Barnard-Rubin (1999)
adjustment, as mice does; with cluster = NULL the results are identical
to the mice implementation, and a test asserts this to six decimals. When
clustered, the complete-data degrees of freedom are taken as the number of
clusters minus one, so the reference distributions grow more conservative
as clusters become few. sandwich is a suggested rather than imported
dependency, required only when cluster is used.
Three functions implement the workflow recommended in the documentation of
ctree_stacked(): treat the tree as discovery, and test its partition on
independent data with a procedure that has valid error control.
split_holdout() partitions a data frame into discovery and confirmation
sets on original observations, before imputation, so that each half can
be imputed separately.confirm_ctreeMI() applies the terminal-node rules of a fitted tree to an
independently imputed confirmation sample and tests whether the outcome
differs across the resulting subgroups. The test pools across imputations
by the Li-Raghunathan-Rubin procedure (mice::D1()) rather than
stacking, so the between-imputation variance that miscalibrates the
stacked node-level test is properly accounted for. Two families of test
are returned: an omnibus test that the outcome differs across terminal
nodes at all, and a per-split test for every internal node, in which the
confirmation observations inside that node are divided by its own rule
and the children compared. The per-split tests identify which individual
splits survive independent data, and are Holm-adjusted across internal
nodes by default. Pooled per-node estimates are returned alongside.discover_confirm() runs the full sequence from a raw data frame.prune_unconfirmed() returns the tree with every split that failed to
confirm collapsed, so the partition that survived can be reported and
plotted directly.report_confirm() generates a methods paragraph describing the design,
in the idiom of report_ctreeMI().Each split is reported with the pooled difference between its children and a confidence interval, alongside the test. The package argues that node-level p-values should not be read as error rates; it would be inconsistent to report only p-values here.
The confirmation test addresses two problems at once: the selection effect of testing subgroups on the data used to find them, and the miscalibration of the stacked node-level test under outcome-conditioned imputation.
The roxygen comments throughout the package use markdown syntax for
emphasis, code, cross-references and section headings, but markdown
processing had never been enabled, so these rendered literally on CRAN.
It is now enabled. A percent sign in ?ctree_stacked that Rd read as a
comment marker, silently truncating a sentence in the 1.0.1 manual, is now
escaped.
?ctreeMI described the correction as dividing the significance threshold
by M. That is threshold rescaling, which versions 0.1.0 and 0.2.0
implemented and which under-corrects by an order of magnitude at M = 30;
the package has applied the correction to the statistic since 0.3.0, and
?ctree_stacked says so. The package-level page now describes the
mechanism correctly, no longer characterizes the node-level test as
conservative, and points to the confirmation workflow.
Documentation only. No function has changed and results are identical to 1.0.0.
?ctree_stacked reported sub-nominal, and therefore conservative, type-I
error under MCAR. That holds under the marginal imputation model used in the
simulations of Sherlock et al. (2026), which conditioned on neither the
outcome nor the remaining predictors. It does not hold under
outcome-conditioned imputation, which is recommended practice and is what
mice() does by default when the outcome is present in the data frame. In
that setting the node-level test rejects more often than alpha implies,
increasingly so as the missingness rate rises.
The documentation now states this, notes that omitting the outcome from the
imputation model reverses the direction rather than restoring calibration,
and points to node_table() and to refitting on independent imputations as
the checks to use in place of node-level p-values.
The package DESCRIPTION previously described the result as "a conservative but interpretable single tree". The word "conservative" has been removed for the same reason.
?ctree_stacked now states that the procedure assumes missingness at random,
and that recovery degrades under MNAR for every imputation-based approach.
Supporting simulations are archived at https://doi.org/10.5281/zenodo.21939940.
0.3.0 introduced the right correction. This release makes it survive contact with real stacked data, and derives the degrees of freedom instead of relying on a p-value that has usually underflowed by the time it is needed. Results will differ from 0.3.0.
partykit stores node-level p-values on the natural scale, and they underflow
to exactly 0 once the statistic passes roughly 1400 at df = 2. On stacked
data that is the normal case, not an edge case: 3,000 rows with M = 30 already
produces a root statistic above 5,000. 0.3.0 recovered the degrees of freedom
by inverting the stored p-value and, failing that, stopped with
could not recover degrees of freedom at node 1 (statistic = 5187.76,
p = 0). Refusing to prune on unverified statistics.
so the package could not fit the kind of dataset it was written for. 1.0.0
recovers df where the stored p-value is interior and falls back on the
structural rule (below) where it is not, and computes the corrected p-value as
-expm1(k * pchisq(stat, df, lower.tail = TRUE, log.p = TRUE)), which stays
accurate to about 1e-300 rather than collapsing to 0.
With teststat = "quadratic" the node-level statistic is chi-square with df
equal to the rank of the covariance matrix of the linear statistic:
df = the outcome dimension, so 1 for a
univariate outcome, 2 for a bivariate outcome, 3 for three outcomes;L levels present in that node: (L - 1) times
the outcome dimension, which changes from node to node as levels drop out of
a branch.0.3.0 recovered a single continuous df for the variable that was split on.
1.0.0 recovers an integer df for every candidate variable at every node and
cross-checks it against the structural rule. df = 2 (or any number) holds it
fixed, and df = "outcome" uses the outcome dimension throughout.
ctree splits a node when any candidate variable meets alpha, and that is
the rule the correction must reapply. Rescaling can reorder the candidates,
because they carry different degrees of freedom, so the variable with the
smallest p-value before the correction is not always the smallest after.
node_stats gains p_min and variable_min recording the decisive candidate,
and the full per-candidate table is attached as
attr(node_stats, "candidates").
An internal node is now collapsed only once all of its own internal
descendants have been collapsed. A node whose descendant survives the
correction keeps its split even if it would fail on its own. 0.3.0 deleted
every failing node outright, taking any surviving descendants with it, which
is more aggressive than the procedure used for the paper. With df held
fixed, prune_stackM() now reproduces that procedure exactly; this is
asserted in the test suite for M = 2, 5, 10 and 30.
ctree_stacked() grows with testtype = "Univariate" so that the stored
p-values are raw, but prune_stackM() is documented as accepting any tree
fitted on stacked data, and partykit's default is testtype = "Bonferroni",
where the stored p-values already carry the multiplicity adjustment. Inverting
those as if they were raw returned a plausible but wrong df (2.32 instead of
2; 12.05 instead of 8 in testing) and the internal verification could not
detect it, because it re-solved the same equation it had just inverted.
1.0.0 reads the multiplicity setting from the fitted control and inverts the
matching relationship, and check_stackM_extraction() now exercises both
settings and checks the recovered df against the structural rule rather than
against itself.
minsplit and minbucket are multiplied by M (scale_minsize = TRUE), so
they refer to original rather than stacked observations. The partykit
defaults previously allowed terminal nodes holding fewer than one original
observation.y ~ . formula can no longer split on imputation number. The
documented usage in 0.3.0 invited exactly that.NAMESPACE was out of date: prune_stackM(), rescale_statistic() and
check_stackM_extraction() had @export tags but were not exported, so
they were unreachable despite being advertised in DESCRIPTION.ctree_stacked() gains df and scale_minsize arguments. formula,
data, m, alpha and verbose are unchanged.teststat = "maximum", testtype = "MonteCarlo" or
splittest = TRUE are rejected with an explanatory error rather than
silently rescaled: those settings do not use a chi-square reference
distribution.summary.ctreeMI() by name; the method is
registered for S3 dispatch but not exported, so the call failed and
R CMD check did not pass on 0.3.0.README.md still described the alpha / M rule from 0.1.0-0.2.0 and
pointed at a repository URL that does not exist; both corrected.R/zzz.R. The .onLoad() / registerS3method() workaround is
unnecessary now that NAMESPACE carries the S3method() entries, and it
registered only two of the four methods.Versions 0.1.0 and 0.2.0 did not implement the Stack/M correction of
Sherlock et al. (2026). They divided the significance threshold by M and
passed alpha / M to ctree_control(). The published and validated method
divides the node-level chi-square statistic by M and recomputes the
p-value.
These are not equivalent. Writing q(p, df) for the chi-square quantile
function, the statistic rule rejects when X > M * q(1 - alpha, df) while
the threshold rule rejects when X > q(1 - alpha / M, df). They coincide
only at M = 1. At df = 1 and alpha = 0.05:
| M | statistic rule | threshold rule | |----|----------------|----------------| | 5 | X > 19.2 | X > 6.63 | | 10 | X > 38.4 | X > 7.88 | | 30 | X > 115.2 | X > 9.88 | | 50 | X > 192.1 | X > 10.83 |
Threshold rescaling therefore under-corrects severely, and trees fitted with 0.1.0-0.2.0 contain more splits than the published method supports. Refit any such tree with 0.3.0 and re-check any reported subgroups.
ctree_stacked() now grows the tree at the nominal alpha and then
applies the correction post hoc: node statistics are divided by M,
p-values recomputed, the multiplicity adjustment reapplied, and failing
nodes collapsed. Split selection in partykit does not depend on alpha,
and the correction is strictly stricter than the nominal threshold, so
this yields the same tree as growing under the corrected criterion.rescale_statistic(): divides a statistic by M and recomputes its
p-value.prune_stackM(): applies the correction to any party object
fitted on stacked data; returns the pruned tree and a per-node table of
raw and rescaled statistics.check_stackM_extraction(): diagnostic confirming node statistics
and degrees of freedom can be recovered from the installed partykit.rescale_alpha() is deprecated and now warns. It never implemented the
published correction.ctreeMI_info replaces alpha_nominal/alpha_applied with alpha,
correction, node_stats, n_splits_before and n_splits_after.report_ctreeMI() now describes the statistic-based correction and
reports how many candidate splits survived it.node_table(): returns a data frame of tree nodes with the split
path defining each node, its size in the stacked data, and its
effective sample size on the original scale (stacked size / M).report_ctreeMI(): generates a methods paragraph describing the
fitted model, populated with the actual M, sample sizes, significance
thresholds, and tree size.ctree_stacked(): fit a conditional inference tree on stacked multiply
imputed data with the Stack/M significance-threshold correction
(Sherlock et al., 2026).stack_imputations(): stack a list of imputed data frames vertically.rescale_alpha(): compute the Stack/M corrected significance threshold.print.ctreeMI() and summary.ctreeMI() S3 methods.mids objects from mice, lists of data frames, or plain data
frames (falls back to standard ctree with a warning).