How this calculation works
The Van Elteren test combines two-treatment rank comparisons made separately within prespecified strata. It is useful when a common treatment comparison should account for a blocking variable without assuming normally distributed outcomes.
Within eachstratum pooledmidranks give U_s=rankSumA-nA(nA+1)/2. Nullmean nAnB/2; varU=nAnB/12*((n+1)-Σties(t³-t)/(n(n-1))). Choose vanElteren weights w_s=1/(n_s+1), explicitlylabel. Z=Σw_s(U_s-mean_s)/sqrtΣw_s²var_s. Asymptotic two-sidedp2Phi(-absZ). Optionalexact conditionalrandomization enumerates fixedgroupcountassignments separatelyperstratum and convolves weightedscore distributions, requiringboundedLCMrationalweightsor enumeration. Do notpoolranksacrossstrata.A worked example
With the prefilled inputs, weightedCenteredU = 0.
Good to know
Two-sided plus-one Monte Carlo within-stratum label permutations with fixed supplied weights; midrank tie variance included. Not paired data or exact convolution.
Reference: Primary method reference or author-maintained documentation (opens in a new tab) ↗
Keep comparisons within strata
The Van Elteren test combines two-treatment rank comparisons made separately within prespecified strata. It is useful when a common treatment comparison should account for a blocking variable without assuming normally distributed outcomes.
Observations within a stratum still belong to independent treatment groups. This is not the paired signed-rank test, and a stratum label does not turn unmatched observations into matched pairs.
Compare with the Mann–Whitney U test calculator with ties. Test a common stratified rank effect while conditioning on block-specific treatment counts; pooling samples into Mann Whitney discards strata and can reverse the comparison.
Rank each stratum independently
Use the prefilled input structure and preserve the declared column or index order. Pool the two groups only within the same stratum and assign average ranks to tied values. Rank sums from different strata are then centered against their own null expectations.
Ranking the entire dataset before stratification gives a different procedure. A large location difference between strata should not automatically influence the within-stratum treatment score. Every stratum supplies two independent sample lists and one positive weight. At least two observations in each treatment group are required within each of two to ten strata, and the total count cannot exceed two hundred. The weights are supplied explicitly, rather than automatically chosen from sample sizes. Changing the weights changes which strata dominate the pooled rank contrast. Choose a defensible rule before looking at which direction each stratum favors. A matched-pairs dataset should not be forced into this interface by placing each pair in a stratum with one observation per group.
Specify the weighting convention
This version combines centered U statistics using weight one divided by stratum size plus one. Naming the weight is important because related stratified rank procedures can use different weighting choices.
A stratum's contribution therefore depends on its size, rank separation and tie structure. Review the individual contributions instead of interpreting the final score as an unweighted average of treatment differences.
Correct variance for tied observations
Repeated outcomes reduce the number of distinguishable rank arrangements. The null variance incorporates tie-block sizes through the sum of t-cubed minus t.
If every informative comparison is tied, the total variance is zero and a standardized Z statistic is undefined. The correct output is a no-information diagnostic rather than a p-value based on division by zero.
A two-stratum exact example
In the first stratum let A contain one and B contain two. In the second let A contain three and B contain four; each stratum then has U equal to zero and centered score minus one-half.
With the stated weights, the standardized combined score is minus the square root of two. Enumerating the four equally likely fixed-count label assignments gives an exact two-sided p-value of one-half, distinct from a normal approximation.
Separate exact and asymptotic results
An exact conditional calculation holds treatment counts fixed within every stratum and evaluates the randomization distribution of the combined statistic. Its computational cost grows with the number of possible label assignments.
A normal reference is an approximation to that distribution. Small or heavily tied samples can make its p-value differ substantially from the exact result, so the method label must travel with the reported probability.
Interpret an omnibus treatment comparison
The test summarizes evidence for a consistent within-stratum treatment tendency under its assumptions. It does not estimate a difference in original measurement units.
Large treatment-by-stratum variation can be hidden by a single combined score. Inspect the stratum contributions and use an appropriate effect estimator when the practical magnitude of the treatment difference is the main question. The implementation converts each stratum to pooled midranks and computes a centered Mann-Whitney score and its tie-aware conditional variance. Its null simulation independently permutes treatment labels within each stratum while retaining the observed group sizes and supplied weights. The two-sided comparison uses the absolute pooled score and a plus-one correction for the Monte Carlo p-value. Between ninety-nine and four thousand nine hundred ninety-nine simulated assignments are permitted. This is not exhaustive conditional convolution, and the finite simulation resolution remains visible. Retaining the seed makes a result reproducible without converting the simulation into an exact p-value. Two-sided plus-one Monte Carlo within-stratum label permutations with fixed supplied weights; midrank tie variance included. Not paired data or exact convolution.
A few questions, answered
Should I rank all observations together?
No. Ranks and tie corrections are computed separately within each stratum.
Is this for paired outcomes?
No. It combines independent two-group comparisons within strata; paired differences require a paired method.
Why can the p-value change with another seed?
This page uses a finite within-stratum Monte Carlo permutation sample. Another seed draws different assignments; more prespecified replicates reduce that simulation variation without making the result an exact exhaustive p-value.
What if every outcome is tied?
The rank-score variance is zero, so the standardized test has no information and should not return a fabricated finite statistic.