
Simple Wilcoxon Rank-Sum (Hodges-Lehmann) Inference
Source:R/inference_all_simple_wilcox.R
InferenceAllSimpleWilcox.RdFits a non-parametric treatment-effect estimator based on the two-sample
Wilcoxon rank-sum test: the point estimate is the Hodges-Lehmann
location-shift estimate (the median of all pairwise treatment-minus-control
differences \(y_{T,i} - y_{C,j}\)), and both the confidence interval and
two-sided p-value are the standard rank-based Wilcoxon quantities from
stats::wilcox.test() (normal approximation with continuity correction),
not Wald intervals/tests built around the point estimate and a separately
estimated standard error. Robust to outliers and does not assume normality or
equal arm variances. Not supported for incidence (binary) responses (the
Hodges-Lehmann estimator degenerates on 0/1 data — use
InferenceAllSimpleAverageDiff or a
conditional-logistic estimator instead) or censored survival data (use
InferenceSurvivalGehanWilcox
instead). This class has no likelihood tier (likelihood_tier = "none")
and does not support the Bayesian bootstrap; its jackknife methods all report
explicit non-estimability rather than computing a (statistically unreliable)
delete-1 jackknife of the Hodges-Lehmann functional.
Initialize simple Wilcoxon inference and prepare the
rank-based treatment statistic used by
InferenceAllSimpleWilcox.
Rejects response_type = "incidence" (Hodges-Lehmann degenerates
on binary data) and rejects censored survival data at construction; see
the class-level documentation for recommended alternatives in both
cases. Legal response_type values are "continuous",
"count", "proportion", "survival" (uncensored
only), and "ordinal".
Returns the Hodges-Lehmann estimate of location
shift: the median of all pairwise treatment-minus-control differences
\(y_{T,i} - y_{C,j}\) (via wilcox_hl_point_estimate_cpp()), the
standard point estimate associated with the Wilcoxon rank-sum test.
Robust to outliers and does not assume normality or equal variances.
Wilcoxon rank-sum test two-sided p-value testing
\(H_0: \beta_T = \code{delta}\) (via stats::wilcox.test(yT, yC -
delta, exact = FALSE)$p.value, the normal approximation with
continuity correction) — a genuine rank-based test, not a
Wald test built from the Hodges-Lehmann estimate and its standard
error, despite living alongside $compute_asymp_confidence_interval()
in this class's "asymptotic" method family. For delta != 0, the
control arm's values are shifted by delta before testing, so the
test checks whether \(y_T\) and \(y_C + \code{delta}\) come from
the same distribution.
Returns the Hodges-Lehmann confidence interval directly from
stats::wilcox.test(yT, yC, conf.int = TRUE, exact = FALSE,
conf.level = 1 - alpha) — the standard nonparametric interval
associated with the Wilcoxon rank-sum test, based on inverting the
rank-sum test statistic rather than a Wald normal-approximation
interval around $compute_estimate()'s point estimate (though the
two coincide asymptotically).
Delegates to the genuine rank-based
$compute_asymp_two_sided_pval() rather than the generic
Wald-component z/t formula.
Fixed 2026-09-06: this class did not override
compute_wald_two_sided_pval, so it fell through to the
composed Wald component's generic
(estimate - delta) / se formula built from
compute_estimate() (the Hodges-Lehmann median-of-pairwise-
differences) and get_standard_error(). On heavily tied,
small-integer count/ordinal data the Hodges-Lehmann estimate lands
on exactly 0 far more often than a continuous estimator would, so
the Wald statistic came out exactly 0/se = 0 regardless of
se, forcing p = 1 deterministically (observed:
pinned at 1 in ~75-98
compute_asymp_two_sided_pval() does not have this failure
mode.
Delegates to the genuine rank-based
$compute_asymp_confidence_interval() rather than the
generic Wald normal-approximation interval, for the same reason
as compute_wald_two_sided_pval above.
Fixed 2026-09-06: the generic Wald component's normal-approximation
interval is built from get_standard_error(), which this
class derives by back-solving se = (ci[2]-ci[1]) /
(2*1.96) from stats::wilcox.test()'s own asymptotic CI
width. Under heavy ties, that root search can converge to a
numerically near-zero-width interval as a search artifact, not a
real sampling-uncertainty statement; that spurious near-zero SE
then produced a near-[0,0] Wald interval (observed in
over 1,200 rows of comprehensive-results data). The rank-based
compute_asymp_confidence_interval() inverts the rank-sum
test directly and does not go through this derived SE at all.
Reports the jackknife point-estimate as explicitly
non-estimable for this Hodges-Lehmann estimator, rather than computing
a leave-one-out jackknife: the median-of-pairwise-differences
functional is not smooth enough for the delete-1 jackknife's
linear-approximation machinery to be reliable. This method exists
purely to record that unavailability (via
private$cache_nonestimable_estimate()) rather than silently
returning a misleading number; see
InferenceJackknife for the shared
jackknife contract this method participates in.
Reports the jackknife bias-correction estimate as
non-estimable for this simple Wilcoxon estimator, for the same reason
as $compute_jackknife_estimate() (the Hodges-Lehmann functional
is not smooth enough for the delete-1 jackknife); see
InferenceJackknife for the shared
jackknife contract.
Reports the jackknife standard error as non-estimable for
this simple Wilcoxon estimator, for the same reason as
$compute_jackknife_estimate(); see
InferenceJackknife for the shared
jackknife contract.
Reports the jackknife-Wald p-value as non-estimable here,
for the same reason as $compute_jackknife_estimate(); see
InferenceJackknife.
Reports the jackknife-Wald confidence interval as
non-estimable here, for the same reason as
$compute_jackknife_estimate(); see
InferenceJackknife.
References
Hodges, J. L., and Lehmann, E. L. (1963). "Estimates of Location Based on Rank Tests." The Annals of Mathematical Statistics, 34(2), 598-611, doi:10.1214/aoms/1177704172 , for the Hodges-Lehmann estimator; Wilcoxon, F. (1945). "Individual Comparisons by Ranking Methods." Biometrics Bulletin, 1(6), 80-83, doi:10.2307/3001968 , for the underlying rank-sum test.
Super class
Inference -> InferenceAllSimpleWilcox
Methods
Public methods
+ inherited public methods from Inference
Inference$capabilities()Inference$compute_exact_confidence_interval()Inference$compute_exact_two_sided_pval_for_treatment_effect()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_response()Inference$get_response_type()Inference$get_treatment()Inference$is_nonestimable()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceAllSimpleWilcox$new()
Usage
InferenceAllSimpleWilcox$new(
des_obj,
model_formula = NULL,
verbose = FALSE,
max_resample_attempts = 50L,
smart_cold_start_default = NULL
)Arguments
des_objA completed
DesignSeqOneByOneobject.model_formulaOptional formula for covariate adjustment. If
NULL(default), the formula from the design object is used and its pre-computed design matrix is reused. If a formula is provided, a new design matrix is constructed from the design's imputed covariates.verboseWhether to print progress messages. Default
FALSE.max_resample_attemptsMaximum number of times a single bootstrap replicate may be redrawn when the drawn sample fails validity screening. If all attempts fail the replicate is recorded as
NA, silently reducing the effectiveB. Must be a positive integer. Default50L.smart_cold_start_defaultFlag for consistent API.
InferenceAllSimpleWilcox$compute_jackknife_wald_two_sided_pval()
Arguments
deltaNull treatment effect. Default 0.
deltaNull treatment effect. Default 0.
deltaNull treatment-effect value. Default 0.
unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".
InferenceAllSimpleWilcox$compute_jackknife_wald_confidence_interval()
Usage
InferenceAllSimpleWilcox$compute_jackknife_wald_confidence_interval(
alpha = 0.05,
unit = "auto"
)Arguments
alphaSignificance level. Default 0.05.
alphaSignificance level. Default 0.05.
alphaSignificance level. Default 0.05.
unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".unitDeletion unit. Default
"auto".
Examples
seq_des = DesignSeqOneByOneBernoulli$new(n = 6, response_type = "continuous")
seq_des$add_one_subject_to_experiment_and_assign(MASS::biopsy[1, 2 : 10])
#> [1] 1
seq_des$add_one_subject_to_experiment_and_assign(MASS::biopsy[2, 2 : 10])
#> [1] 0
seq_des$add_one_subject_to_experiment_and_assign(MASS::biopsy[3, 2 : 10])
#> [1] 0
seq_des$add_one_subject_to_experiment_and_assign(MASS::biopsy[4, 2 : 10])
#> [1] 0
seq_des$add_one_subject_to_experiment_and_assign(MASS::biopsy[5, 2 : 10])
#> [1] 1
seq_des$add_one_subject_to_experiment_and_assign(MASS::biopsy[6, 2 : 10])
#> [1] 0
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))
seq_des_inf = InferenceAllSimpleWilcox$new(seq_des)
seq_des_inf$compute_estimate()
#> [1] -0.115