Moses Test of Extreme Reactions
Nonparametric test for scale/variability equality between two groups; detects if experimental group has more extreme scores (wider spread) than control, particularly at distribution tails..
What is it?
Moses Test of Extreme Reactions evaluates if a treatment triggers extreme responses (high dispersion/variance) in either direction compared to a control group.
When to use it
- Dispersion Difference: Check if treatment increases variance (extreme low/high reactions).
- Nonparametric: No normality requirements for distribution shapes.
Core Idea
Combines and ranks control and treatment. Measures the rank span containing all control observations. A wide span indicates treatment scores cluster at the extremes:
Hypotheses
How it works
- Combine Control and Treatment scores and sort.
- Determine the ranks of the Control observations.
- Locate minimum and maximum control ranks.
- Calculate Span: Span = Max Rank - Min Rank + 1. High span means treatment dominates the ends.
Assumptions
Effect Size
Represented by the **control rank span width**. Wide spans relative to control sample size indicate strong extreme treatment responses.
Quick Example
| Group | Ranks | Moses Span |
|---|---|---|
| Control (N=5) | 3, 4, 5, 6, 7 | Span = 5 (Identical) |
| Treatment | 1, 2, 8, 9, 10 |
Moses Extreme Reactions Live Laboratory
Stretch treatment variance dispersion to push control ranks to cluster together.
| Metric | Value |
|---|---|
| Min Control Rank | 1 |
| Max Control Rank | 24 |
| Moses Control Span (S) | 24 |
| p-value (exact hypergeom) | 0.4500 |
Hypotheses
Pragmatic null and alternative hypotheses defined in mathematical notation.
H₀: The two groups have equal variability (scale)
Hₐ: The experimental group has greater variability (wider spread, more extreme reactions)
Tests SCALE (spread/variability), NOT location. Unlike Levene's test (which tests variance equality for any two groups), Moses test is specifically designed for experimental vs. control comparisons and is particularly sensitive to differences in the tails (extreme scores). If groups also differ in location, results may be difficult to interpret—ideally use when medians are similar.
Assumptions
The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.
Diagnostics
Checking residual plots and indices to examine model deviations and ensure standard error integrity.
- Visual comparison: boxplots showing spread differences (compare box widths and whisker lengths)
- Check medians are similar (Moses tests scale; if locations differ, result confounded)
- Compare IQRs and ranges (quick scale check: IQR_ratio, range_ratio)
- Calculate variance ratio (σ²_experimental / σ²_control) as effect size
- Verify control group span is reasonable (not at extreme ends of combined ranking)
- Levene's test for comparison (tests variance equality, complements Moses test)
- Q-Q plot comparing quantiles (shows where distributions differ—tails vs center)
- Coefficient of variation (CV) comparison: CV = SD/Mean × 100 (standardized variability)
- Violin plots or density plots to visualize distribution shapes and spreads
- Plot of ranks showing control span within combined data (visualize Moses test logic)
- Bootstrap confidence interval for variance ratio (robust effect size estimate)
- Compare variance at different trim levels (e.g., 10% trimmed variance—isolates tail effects)
- Sensitivity analysis: Moses test with/without outliers
- Siegel-Tukey test for comparison (alternative rank-based scale test)
Applied Minds
Review concrete study examples, data layout guidelines, and copy executable syntax scripts.
Drug Side Effect Variability - ADHD Medication Adverse Events
Research question: Does ADHD medication (experimental) produce more variable side effect severity than placebo (control)? Design: RCT with n=50 (25 per group). Outcome: Side effect severity score 0-10 (ordinal). Moses test used because research question specifically asks if treatment creates MORE EXTREME reactions (some patients have severe side effects, others minimal), not just different average severity. This is classic 'extreme reactions' question perfect for Moses test.
# ==============================================================================
# Moses Test: ADHD Medication Side Effect Variability
# Research Question: Does medication produce more extreme/variable reactions?
# ==============================================================================
library(tidyverse) # Data manipulation and visualization
library(DescTools) # MosesTest() function
library(car) # Levene's test for comparison
library(effectsize) # Effect size calculations
set.seed(2025)
# Simulate data:
# Placebo: Low variability (homogeneous minor side effects)
# Medication: High variability (some severe, some minimal side effects)
data <- data.frame(
group = rep(c("Placebo", "Medication"), each=25),
side_effect_severity = c(
# Placebo: narrow spread around 2-3
pmin(10, pmax(0, rnorm(25, mean=2.5, sd=1.2))),
# Medication: wide spread (bimodal: responders + severe reactors)
pmin(10, pmax(0, c(
rnorm(12, mean=1.5, sd=1.5), # low side effects
rnorm(13, mean=6.5, sd=2.0) # high side effects
)))
)
)
data$group <- factor(data$group, levels = c("Placebo", "Medication"))
# ==============================================================================
# STEP 1: DESCRIPTIVE STATISTICS
# ==============================================================================
cat("\n=== DESCRIPTIVE STATISTICS ===\n")
descriptives <- data %>%
group_by(group) %>%
summarise(
n = n(),
mean = mean(side_effect_severity),
sd = sd(side_effect_severity),
median = median(side_effect_severity),
IQR = IQR(side_effect_severity),
min = min(side_effect_severity),
max = max(side_effect_severity),
range = max - min,
cv = (sd / mean) * 100 # coefficient of variation
)
print(descriptives)
cat("\nKey observation: Check if SDs/IQRs differ(scale) while medians similar(location).\n")
# ==============================================================================
# STEP 2: ASSUMPTION CHECKING
# ==============================================================================
cat("\n=== ASSUMPTION CHECKS ===\n")
# Assumption 1: Independence
cat("1. Independence: Between-subjects RCT design confirmed(independent groups).\n")
# Assumption 2: Adequate sample size
cat("\n2. Sample Size Check:\n")
n_placebo <- sum(data$group == "Placebo")
n_medication <- sum(data$group == "Medication")
cat(sprintf(" Placebo(control): n = %d(≥10 ✓)\n", n_placebo))
cat(sprintf(" Medication(experimental): n = %d(≥10 ✓)\n", n_medication))
cat(" Adequate sample sizes for Moses test.\n")
# Assumption 3: Check if medians are similar (critical for Moses test interpretation)
cat("\n3. Location Similarity Check(for clear scale interpretation):\n")
placebo_vals <- data %>% filter(group == "Placebo") %>% pull(side_effect_severity)
medication_vals <- data %>% filter(group == "Medication") %>% pull(side_effect_severity)
mdn_placebo <- median(placebo_vals)
mdn_medication <- median(medication_vals)
mdn_diff <- abs(mdn_placebo - mdn_medication)
pooled_iqr <- (IQR(placebo_vals) + IQR(medication_vals)) / 2
cat(sprintf(" Placebo median: %.2f\n", mdn_placebo))
cat(sprintf(" Medication median: %.2f\n", mdn_medication))
cat(sprintf(" Median difference: %.2f\n", mdn_diff))
cat(sprintf(" Relative difference: %.2f (< 0.5 suggests similar location)\n",
mdn_diff / pooled_iqr))
# Mann-Whitney to formally test location
mw_result <- wilcox.test(medication_vals, placebo_vals)
cat(sprintf("\n Mann-Whitney U test: W = %.1f, p = %.4f\n",
mw_result$statistic, mw_result$p.value))
if(mw_result$p.value > 0.05) {
cat(" Locations are similar(p > .05) → Moses test isolates SCALE difference. ✓\n")
} else {
cat(" Locations differ(p < .05) → Moses result may reflect both location AND scale.\n")
}
# ==============================================================================
# STEP 3: VISUALIZATIONS
# ==============================================================================
cat("\n=== GENERATING VISUALIZATIONS ===\n")
# Visualization 1: Boxplots (focus on spread)
p1 <- ggplot(data, aes(x=group, y=side_effect_severity, fill=group)) +
geom_boxplot(alpha=0.7, outlier.shape=NA) +
geom_jitter(width=0.2, alpha=0.5, size=2.5) +
stat_summary(fun=median, geom="point", shape=23, size=4, fill="red") +
labs(title="Side Effect Severity: Placebo vs. Medication",
subtitle="Moses test: Is medication group more variable(wider box/whiskers)?",
x="Group", y="Side Effect Severity(0-10)") +
theme_minimal() +
theme(legend.position="none")
print(p1)
# Visualization 2: Violin plots (show full distribution shape)
p2 <- ggplot(data, aes(x=group, y=side_effect_severity, fill=group)) +
geom_violin(alpha=0.6, trim=FALSE) +
geom_boxplot(width=0.1, fill="white", alpha=0.8) +
labs(title="Distribution Shapes: Medication Shows Greater Spread",
subtitle="Wider violin = more variability(extreme reactions)",
x="Group", y="Side Effect Severity") +
theme_minimal() +
theme(legend.position="none")
print(p2)
# Visualization 3: Q-Q plot (compare quantiles)
placebo_quantiles <- quantile(placebo_vals, probs = seq(0, 1, 0.1))
medication_quantiles <- quantile(medication_vals, probs = seq(0, 1, 0.1))
qq_data <- data.frame(
placebo_q = placebo_quantiles,
medication_q = medication_quantiles
)
p3 <- ggplot(qq_data, aes(x=placebo_q, y=medication_q)) +
geom_point(size=3, color="blue") +
geom_abline(slope=1, intercept=0, linetype="dashed", color="red") +
labs(title="Q-Q Plot: Medication vs. Placebo",
subtitle="Points above line = medication more variable at that quantile",
x="Placebo Quantiles", y="Medication Quantiles") +
theme_minimal()
print(p3)
# Visualization 4: Rank plot showing control span (Moses test logic)
data_ranked <- data %>%
arrange(side_effect_severity) %>%
mutate(rank = row_number())
# Identify control group span
control_ranks <- data_ranked %>%
filter(group == "Placebo") %>%
pull(rank)
control_span <- max(control_ranks) - min(control_ranks) + 1
p4 <- ggplot(data_ranked, aes(x=rank, y=side_effect_severity,
color=group, shape=group)) +
geom_point(size=3, alpha=0.7) +
geom_segment(aes(x=min(control_ranks), xend=max(control_ranks),
y=-0.5, yend=-0.5), color="darkgreen", size=2) +
annotate("text", x=mean(control_ranks), y=-1,
label=sprintf("Control span = %d", control_span),
color="darkgreen", fontface="bold") +
labs(title="Moses Test Logic: Control Group Span in Combined Ranking",
subtitle="Short span = control clustered(less variable); Medication more spread out",
x="Rank(Combined Data)", y="Side Effect Severity") +
theme_minimal()
print(p4)
# ==============================================================================
# STEP 4: MOSES TEST OF EXTREME REACTIONS
# ==============================================================================
cat("\n=== MOSES TEST OF EXTREME REACTIONS ===\n")
# Moses test: tests if experimental group (medication) has greater variability
# Uses DescTools package
moses_result <- MosesTest(
x = medication_vals, # experimental group
y = placebo_vals, # control group
alternative = "greater" # one-sided: experimental > control variability
)
print(moses_result)
cat("\n--- Test Summary ---\n")
cat(sprintf("Control group(Placebo): n = %d\n", n_placebo))
cat(sprintf("Experimental group(Medication): n = %d\n", n_medication))
cat(sprintf("Control span: %d\n", moses_result$statistic))
cat(sprintf("p-value: %.4f\n", moses_result$p.value))
cat(sprintf("Result: %s at α = .05\n",
ifelse(moses_result$p.value < 0.05, "SIGNIFICANT", "Not significant")))
if(moses_result$p.value < 0.05) {
cat("\nInterpretation: Medication group has significantly greater variability\n")
cat("(more extreme reactions) than placebo. This indicates responder heterogeneity:\n")
cat("some patients experience severe side effects, others minimal.\n")
}
# ==============================================================================
# STEP 5: EFFECT SIZE
# ==============================================================================
cat("\n=== EFFECT SIZE ===\n")
# Variance ratio (primary effect size for scale tests)
var_medication <- var(medication_vals)
var_placebo <- var(placebo_vals)
variance_ratio <- var_medication / var_placebo
cat(sprintf("Variance ratio(Medication / Placebo): %.3f\n", variance_ratio))
cat("Interpretation: ratio = 1.0 (equal variability), >1.5 (substantially more variable)\n")
# IQR ratio
iqr_ratio <- IQR(medication_vals) / IQR(placebo_vals)
cat(sprintf("\nIQR ratio(Medication / Placebo): %.3f\n", iqr_ratio))
# Coefficient of variation ratio
cv_placebo <- (sd(placebo_vals) / mean(placebo_vals)) * 100
cv_medication <- (sd(medication_vals) / mean(medication_vals)) * 100
cv_ratio <- cv_medication / cv_placebo
cat(sprintf("\nCoefficient of Variation:\n"))
cat(sprintf(" Placebo: %.1f%%\n", cv_placebo))
cat(sprintf(" Medication: %.1f%%\n", cv_medication))
cat(sprintf(" CV ratio: %.2f\n", cv_ratio))
# ==============================================================================
# STEP 6: COMPARE WITH LEVENE'S TEST
# ==============================================================================
cat("\n=== COMPARISON: LEVENE'S TEST FOR VARIANCE EQUALITY ===\n")
cat("Levene's test(parametric) vs. Moses test(nonparametric)\n\n")
levene_result <- leveneTest(side_effect_severity ~ group, data=data)
print(levene_result)
cat("\n--- Comparison Summary ---\n")
cat(sprintf("Moses test: p = %.4f (%s)\n",
moses_result$p.value,
ifelse(moses_result$p.value < 0.05, "significant", "not significant")))
cat(sprintf("Levene's test: p = %.4f (%s)\n",
levene_result$`Pr(>F)`[1],
ifelse(levene_result$`Pr(>F)`[1] < 0.05, "significant", "not significant")))
if(moses_result$p.value < 0.05 && levene_result$`Pr(>F)`[1] < 0.05) {
cat("\nBoth tests agree: variability differs significantly.\n")
cat("Convergent evidence strengthens conclusion.\n")
}
# ==============================================================================
# STEP 7: INTERPRETATION
# ==============================================================================
cat("\n=== INTERPRETATION ===\n")
if(moses_result$p.value < 0.05) {
cat("\nThe Moses test showed significantly greater variability in the medication\n")
cat(sprintf("group compared to placebo, p = %.4f. The medication group(SD=%.2f,\n",
moses_result$p.value, sd(medication_vals)))
cat(sprintf("IQR=%.2f, range=%.1f-%.1f) exhibited more extreme reactions than placebo\n",
IQR(medication_vals), min(medication_vals), max(medication_vals)))
cat(sprintf("(SD=%.2f, IQR=%.2f, range=%.1f-%.1f).\n",
sd(placebo_vals), IQR(placebo_vals), min(placebo_vals), max(placebo_vals)))
cat(sprintf("\nVariance ratio: %.2f (medication %.0fx more variable than placebo).\n",
variance_ratio, variance_ratio))
cat("\nClinical significance: Responder heterogeneity suggests some patients are\n")
cat("highly susceptible to side effects while others tolerate medication well.\n")
cat("Consider investigating predictors of adverse reactions for personalized dosing.\n")
} else {
cat("\nThe Moses test showed no significant difference in variability between\n")
cat("groups. Both medication and placebo produced similar variability in side effects.\n")
}
# ==============================================================================
# APA REPORTING TEMPLATE
# ==============================================================================
cat("\n=== APA-STYLE REPORTING ===\n")
cat("A Moses test of extreme reactions was conducted to compare side effect\n")
cat("variability between placebo(control, n=25) and ADHD medication(experimental,\n")
cat("n=25). Moses test evaluates whether the experimental group exhibits greater\n")
cat("variability(more extreme scores) than control. Groups had similar medians\n")
cat(sprintf("(Placebo: Mdn=%.1f, Medication: Mdn=%.1f, Mann-Whitney p=%.3f), isolating\n",
mdn_placebo, mdn_medication, mw_result$p.value))
cat(sprintf("scale from location effects. Results showed %s, p = %.4f.\n",
ifelse(moses_result$p.value < 0.05,
"significantly greater variability in medication group",
"no significant variability difference"),
moses_result$p.value))
if(moses_result$p.value < 0.05) {
cat(sprintf("\nThe medication group(SD=%.2f, IQR=%.2f) was %.1fx more variable than\n",
sd(medication_vals), IQR(medication_vals), variance_ratio))
cat(sprintf("placebo(SD=%.2f, IQR=%.2f), as confirmed by Levene's test(F=%.2f,\n",
sd(placebo_vals), IQR(placebo_vals), levene_result$`F value`[1]))
cat(sprintf("p<.001). This responder heterogeneity—with some patients experiencing\n"))
cat("severe side effects and others minimal reactions—suggests individual\n")
cat("differences in drug metabolism or sensitivity. Clinical implication: identify\n")
cat("predictive biomarkers for personalized treatment planning.\n")
}
Mood's p = .003, Levene's p = .001 (both significant). Medication group 2.8x more variable than placebo (variance ratio = 2.8, IQR ratio = 2.3). Similar medians (M-W p = .42) but very different spreads. Finding demonstrates responder heterogeneity: some patients have severe side effects (score 8-9), others minimal (score 1-2), while placebo shows consistent mild effects (scores 2-3). Critical for personalized medicine.
Alternatives
Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.
- Mann-Whitney U Test — Switch if you care about the 'Central Tendency' rather than the extreme spread.
- Siegel-Tukey Test — A non-parametric alternative that audits dispersion while protecting the median rank.
- Permutation Dispersion Strike — Use exact significance to bypass the rank-tie penalty in the range calculation.
Post-hoc
Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.
- Compare with Levene's test (parametric alternative)
- Compare with Brown-Forsythe test
- Compare with Ansari-Bradley test (another nonparametric spread test)
- Examine trimming parameter sensitivity (default vs custom span)
- Bootstrap confidence intervals for spread difference
Moses test compares variability/spread between two groups. Post-hoc tests are not applicable.
Effect Size
Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.
Ratio of variances: σ²₁/σ²₂. Interpretation: 1.0 = equal variability, 1.5 = 50% more variable, 2.0 = twice as variable, >3.0 = substantially more variable. Most intuitive scale effect size. Can be calculated with/without trimming to assess tail contributions.
Ratio of interquartile ranges: IQR₁/IQR₂. Robust to outliers. Focuses on middle 50% of data. Interpretation similar to variance ratio but less influenced by extreme values. Useful when outliers present or distributions skewed.
Ratio of coefficients of variation: (SD₁/Mean₁)/(SD₂/Mean₂). Standardizes by mean, useful when groups differ in location as well as scale. Unitless measure allowing comparison across different scales. Interpretation: >1.5 indicates substantially greater relative variability.
Ratio of ranges: (Max₁-Min₁)/(Max₂-Min₂). Simple but sensitive to single extreme value. Useful for initial exploration but not recommended as primary effect size due to outlier sensitivity. Consider interquartile range instead.
0.2
0.5
0.8
Sample Size
Guidelines for minimum sample requirements and power analysis parameters.
Minimum: control group n ≥ 5, experimental group n ≥ 5. Recommended: n ≥ 10 per group for adequate power and stable span estimates. Moses test has lower power than Levene's test for equivalent sample size.
| Effect Size | Parameters | Required n |
|---|---|---|
| Small Effect | Variance ratio ≈ 1.5 | Total N ≈ 200 |
| Medium Effect | Variance ratio ≈ 2.0 | Total N ≈ 100 |
| Large Effect | Variance ratio ≈ 3.0 | Total N ≈ 40 |
Power increases with larger control group (Moses test references control span). Balanced design (equal n) is NOT required but reduces sampling variability. Extremely unbalanced designs (e.g., n₁=50, n₂=10) reduce power; aim for ratio < 3:1. Presence of outliers decreases power for variance tests; consider robust alternatives if >5% outliers. Moses test most powerful when experimental group has more extreme values in tails.
Reporting
How to compile statistical results into publication prose matching APA and journal style guides.
A Moses test of extreme reactions was conducted to compare outcome variability between Control group (n=X) and Experimental group (n=X). Groups had similar/different medians (Control: Mdn=XX, Experimental: Mdn=XX, Mann-Whitney p=.XX), isolating scale from location effects / indicating both location and scale differences. Results showed significantly greater/no significant difference in variability in the experimental group, p = .XXX. The experimental group (SD=XX, IQR=XX) was X.Xx more variable than control (SD=XX, IQR=XX), variance ratio = X.XX. If significant: This finding suggests interpretation of extreme reactions/responder heterogeneity. Include Levene's test for comparison if conducted. Clinical/practical implications.
- p-value
- sample sizes (n per group)
- descriptive statistics for both groups (means, SDs, medians, IQRs, ranges)
- effect size (variance ratio, IQR ratio, and/or CV ratio)
- Mann-Whitney U result if testing location similarity
- Levene's test result if comparing with parametric approach
- interpretation of what the variability difference means (extreme reactions, responder heterogeneity, inconsistent performance)
Manuscript Lab
Copy standard summary tables and forensic reporting grids to outline analysis details.
| Group | Range of Ranks | Span (Statistic) | p-value | Conclusion |
|---|---|---|---|---|
| Group A | 72.4 | 45 | .012 | Significantly More Variable |
| Group B | 25.1 | — | — | — |
The Range Metric. Measures the distance between the highest and lowest ranks in the group, after trimming outliers.
The 'Hidden' effect. Some treatments might not change the mean, but they might make people much more 'unstable' or 'diverse' in their response.
Command Center
Syntax libraries and function parameters for executing calculations in stats packages.
# 1. Execute Moses Test for Extreme Reactions
DescTools::MosesTest(score ~ group, data = df)Traditional tests focus on 'The Average'. Moses focuses on 'The Spread'. Use it to detect if a treatment works great for some but fails for others.
# Execute Ansari-Bradley Test for dispersion comparison
coin::ansari_test(score ~ factor(group), data = df)Common Mistakes
Analytical caveats and corrections to maintain modeling integrity.
References
Scholarly lineage and citation keys grounding the statistical framework.