Back to List

Two-Group Paired Nonparametric Comparison

Learn the core concepts and study-design considerations of Two-Group Paired Nonparametric Comparison in Python-based biostatistics.

Intermediate
|
25min
|
Verified (2026-08-07)
BioStatPybiostatisticsPythonstudy design
Progress0/33 (0%)

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

QuestionIndependent ComparisonPaired Comparison
One rowOutcome of an independent analysis unitOutcome per unit/timepoint
Linking keyNone or group IDsubject/unit ID
Value of interestDifference between groupsDifference within pairs
Structure to verifyIndependence/group definitionPair 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.

python
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:

text
๋น„๊ต ๊ตฌ์กฐ: ๋…๋ฆฝ | ๋Œ€์‘
๋ถ„์„ ๋‹จ์œ„: ______
๊ด€์‹ฌ ํšจ๊ณผ: ______
์„ ํƒํ•œ ์ ˆ์ฐจ: ______
๊ตํ™˜๊ฐ€๋Šฅ์„ฑยท๋…๋ฆฝ์„ฑ ์ ๊ฒ€: ______
ํ•ด์„์˜ ํ•œ๊ณ„: ______

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

The comparison schema and code in this section are educational materials independently authored by BioStatPy.

๐Ÿ’ฌ Questions & Comments

0 comments

You can post without signing in. Guest comments cannot be edited or deleted by their author.

0/2000

Loading...