Two-Group Paired Nonparametric Comparison
Upon Completing This Topic
You will be able to distinguish between independent and paired data in two-group comparisons and select the appropriate comparison structure based on the analysis unit and research question. You will understand nonparametric methods not as automatic substitutes triggered by failed normality tests, but as approaches grounded in the rank structure, pairing, and exchangeability of the data.
Reading the Comparison Design First
Even when two groups share the same names, the underlying data structure may differ. You must distinguish whether A and B originate from distinct independent units, whether the same unit was measured before and after, or whether multiple observations exist within a higher-level unit.
In independent comparisons, each observation is not paired with an observation from the other group. In paired comparisons, the analysis focuses on the differences between the same unit or design-linked pairs. Ignoring pairs fails to leverage common variation between units, while artificially pairing independent data introduces bias.
Data Contract Before Comparison
| Question | Independent Comparison | Paired Comparison |
|---|---|---|
| One row | Outcome of an independent analysis unit | Outcome per unit/timepoint |
| Linking key | None or group ID | subject/unit ID |
| Value of interest | Difference between groups | Difference within pairs |
| Structure to verify | Independence/group definition | Pair completeness/order |
Fill this table according to your data before selecting an analysis method. Maintain the distinction between biological replicate and technical replicate identified in stat-002.
The Scope of "Nonparametric"
Nonparametric methods refer to comparison procedures that are less dependent on specific distributional parameter forms, but they do not assume no conditions. Conditions such as independence of observations, the meaning of ranks, pair structure, and exchangeability may be required.
Do not automatically select methods based solely on the p-value of a normality test. Consider the measurement scale of the outcome, outliers, sample size, research question, and effect size representation. Even when using nonparametric methods, you must report the magnitude and uncertainty of the results.
Using the Python API Aligned with Questions
SciPyโs statistical API performs tests and resampling calculations, but it does not determine which two values are independent or whether pairs are correct. Verify groups and pair keys before inputting them into functions, and interpret the returned statistics and p-values according to the documentation.
from scipy import stats
# ๋
๋ฆฝ ๋จ์์์ ๋์จ ๋ ๊ทธ๋ฃน์ด๋ผ๋ ์ค๊ณ ํ์ธ ํstatistic, p_value = stats.mannwhitneyu( group_a, group_b, alternative="two-sided")
# ๊ฐ์ ๋จ์์ ์ ํ ์ธก์ ์ด๋ผ๋ ์ค๊ณ ํ์ธ ํpaired_stat, paired_p = stats.wilcoxon(before, after)Verifying which unit the input vectors originate from is more important than memorizing function names. Do not write "there is a difference" based solely on the result's p-value; report the direction of comparison, effect size, and uncertainty together.
Verifying Pairs in Paired Data
Paired comparisons require a linking key confirming that two values come from the same unit. If unit_id exists on only one side or if multiple pre-post values exist for a single unit, first document the rules for creating pairs and the units excluded. After pairing, the number of remaining rows may differ from the initial number of measurements; therefore, report the number of pairs used in the analysis separately.
In independent comparisons, verify that the same key is not repeated by chance or that batches are not concentrated in only one group. The appearance of many rows within a group is not equivalent to having many independent units. Use the levels defined in the previous replicate topic as is.
Sentences for Reporting Method Selection
If a method is selected, do not conclude with "nonparametric tests were used because normality was poor." Instead, include the following:
๋น๊ต ๊ตฌ์กฐ: ๋
๋ฆฝ | ๋์
๋ถ์ ๋จ์: ______
๊ด์ฌ ํจ๊ณผ: ______
์ ํํ ์ ์ฐจ: ______
๊ตํ๊ฐ๋ฅ์ฑยท๋
๋ฆฝ์ฑ ์ ๊ฒ: ______
ํด์์ ํ๊ณ: ______This record links API calls to research design and reduces issues arising from the same function being used across different units.
Returning to the Research Question for Interpretation
Independent comparisons ask about differences between units across groups, while paired comparisons ask about changes within the same unit or differences between pairs. Although results from both designs can be summarized under the same phrase "comparison of A and B," the meaning of the effect differs.
The p-value of a nonparametric test is neither the probability that the null hypothesis is true nor a measure of biological importance. Specify the observational unit and comparison procedure, and limit conclusions to the scope of the research question.
Minimum Reporting Unit for Comparison Results
Two-group comparison results must include the number of analysis units per group, outcome summaries, the direction and magnitude of the effect, uncertainty, the selected procedure, and the p-value. For paired comparisons, add the number of complete pairs and the reasons for excluded pairs. Do not state that the median difference was automatically tested simply because a nonparametric procedure was used; verify what the actual statistic compares.
If missingness is concentrated in one group or at one timepoint, the comparison structure itself may change. Therefore, do not report only the units included in the analysis; jointly inspect the distribution of the initially planned units and those that were dropped. This record is not a procedure to make results appear more plausible, but a procedure to clarify which data the comparison relies on.
Boundary Cases of Independence and Pairing
If multiple images are obtained from the same sample, document the hierarchy of samples and images before referring to image-by-image comparisons as independent comparisons. Pre-post measurements of the same unit constitute a paired structure, but if the time interval is long enough that they become different biological units, the interpretation may change. For boundary cases, design documentation and expert review take precedence over function selection.
Common Failures and Verification Methods
- Do not treat pre-post data as two independent groups.
- Do not pair independent data simply because IDs are similar.
- Do not automatically determine test methods based on a single normality test.
- Do not skip independence checks just because a method is nonparametric.
- Do not omit effect sizes by reporting only p-values.
Key Takeaways
- Independent and paired comparisons differ in questions and data units.
- Nonparametric methods also make assumptions regarding design, ranks, and independence.
- The SciPy API performs calculations but does not replace research design.
- Report effect size, uncertainty, and p-value separately.
Next Topic
The next section covers multiple group comparisons and multiple comparisons/FDR. It addresses how to manage interpretation standards as the number of comparisons increases.
References
- SciPy statistics reference: https://docs.scipy.org/doc/scipy/reference/stats.html
- Bioconductor OSTA experimental design: https://bioconductor.org/books/release/OSTA/pages/bkg-exp-design.html
- ASA p-value statement: https://www.amstat.org/asa/files/pdfs/p-valuestatement.pdf
The comparison schema and code in this section are educational materials independently authored by BioStatPy.