lecture 2
1. Introduction to hypothesis testing and non-parametric methods
This section summarizes the review of standard hypothesis testing steps, the rationale for selecting non-parametric tests, and provides a detailed walkthrough of the Mann-Whitney U test (Wilcoxon Rank-Sum test), including its corresponding effect size calculation using Pearson's r 1.
1.1 Recap of hypothesis testing steps
Hypothesis testing follows a defined sequence of steps to draw statistically sound conclusions:
- State the null hypothesis (H0) and the alternative hypothesis (H1).
- Choose an appropriate test statistic and determine its sampling distribution.
- Compute the value of the test statistic based on the collected sample data.
- Calculate the p-value and compare it against the chosen significance level (α).
- Draw a conclusion, deciding whether to reject the null hypothesis or not 3.
1.2 Parametric versus non-parametric tests
The primary consideration when choosing a statistical test involves assessing the nature of the data and its distribution. Parametric tests rely on specific assumptions about the population distribution (like normality), whereas non-parametric tests are less restrictive, making them suitable for different data conditions.
Parametric tests typically assume normality, homogeneity of variance, and independence of observations, often exemplified by T-tests and ANOVA. Conversely, non-parametric tests are employed when these assumptions are violated or when the data structure is inherently ordinal or nominal.
Non-parametric methods are necessary in the following situations:
- Ordinal or nominal variables: When data can only be ranked or ordered (e.g., Likert scale responses ranging from 1 to 5), not measured numerically on a continuous scale.
- Scale variables with violations: When dealing with scale data where the population normality is unknown, especially with small sample sizes (e.g., n<30).
Non-parametric tests achieve robustness by transforming scale data into ranks (treating them as ordinal data), which mitigates the influence of outliers and skewness 4.
Tip: The decision process for selecting a test involves considering the number of groups being compared, whether the groups are independent or repeated, the nature of the variable of interest (scale vs. ordinal), and the distribution assumptions if the variable is scale.
The relationship between these test types, categorized by the number of groups, is visualized in summary charts 5 6.

1.3 Mann-Whitney U test (Wilcoxon Rank-Sum Test)
The Mann-Whitney U test, equivalent to the Wilcoxon Rank-Sum test, is used to compare two independent groups. Its fundamental goal is to evaluate whether the distribution of scores in one group tends to be systematically higher or lower than the distribution in the other group.
The hypotheses are stated as:
- H0: The two populations have the same distribution (no difference in distributions).
- H1: The two populations do not have the same distribution (one tends to have higher or lower values) 7.
1.3.1 Steps for the Mann-Whitney U test
The test operates by replacing raw data values with their corresponding ranks. Consider an example comparing fatigue scores (ordinal scale 1 to 7) between an intervention group (Group 1) and a waiting list group (Group 2) 8.
The procedure involves ranking all observations combined across both groups:
-
Combine and Rank Data: All scores are pooled, and ranks are assigned from smallest (rank 1) to largest.
-
Handling Tied Scores: When two or more observations share the same score, they are assigned the average of the ranks they would have occupied. For example, if scores occupy ranks 1, 2, 3, and 4, they all receive the average rank of (1+2+3+4)/4=2.5 9.

-
Calculate Rank Sums (R1 and R2): The ranks assigned to observations belonging to each respective group are summed up to obtain R1 and R2.
Example: For the sample data provided, the sum of ranks for Group 1 (intervention) was R1=46 (based on n1=8 subjects), and for Group 2 (waitlist), R2=74 (based on n2=7 subjects).
-
Calculate the U statistic: The U statistic is calculated based on the rank sums. For understanding purposes (though often automated by software and outside the scope of direct calculation for this course), the formulas are: U1=n1n2+2n1(n1+1)−R1 U2=n1n2+2n2(n2+1)−R2 The test statistic used is U=min(U1,U2) 10.
-
Determine p-value: For small samples, the p-value is determined using the exact sampling distribution. For larger samples, a normal approximation may be used. Software packages like R's
wilcox.test()function perform this analysis, often using an exact test by default if n<50. If a one-tailed hypothesis is tested, the resulting p-value must be halved 11 12.
1.4 Effect Size: Pearson's r for Non-Parametric Tests
When reporting results from non-parametric tests like the Mann-Whitney U test, Pearson's r is often used to quantify the effect size, indicating the strength of the association or difference between the ranks 13.
Pearson's r measures the linear relationship between two variables (or ranks), ranging from −1 to +1.
1.4.1 Interpretation of Pearson's r
When r is used as an effect size for tests like Mann-Whitney, the focus is usually on its absolute value (∣r∣):
- ∣r∣<0.10: Negligible effect
- 0.10≤∣r∣<0.30: Small effect
- 0.30≤∣r∣<0.50: Medium effect
- ∣r∣≥0.50: Large effect.
While the sign of r indicates the direction of the relationship (e.g., as one variable increases, the other increases or decreases), for effect size reporting in group comparisons, the sign often reflects the arbitrary way the groups were coded 14.

1.4.2 Calculation of Pearson's r
The common formula to calculate Pearson's r from the standardized z-statistic obtained during the Mann-Whitney analysis is:
r=nz
Where z is the standardized test statistic (often provided by software like the coin package's wilcox_test()), and n is the total number of observations in the study.
Example: If the z-statistic calculated was −2.1332 and the total sample size n was 15, the effect size is r=−2.1332/15≈−0.55. This value (∣r∣=0.55) corresponds to a large effect 15.
1.5 Reporting non-parametric results
For non-parametric tests, the median is generally preferred over the mean when reporting descriptive statistics, as it is more representative of central tendency for ordinal or skewed scale data 16.
A standard reporting format for the Mann-Whitney U test integrates the test statistics, p-value, and effect size.
Example of reporting: "A Mann-Whitney test was used to test the hypothesis that the distribution of fatigue ratings between the intervention and waiting list group was equal because fatigue was measured on an ordinal scale. Fatigue ratings in the intervention group (Mdn=3.50) were significantly lower than the control group (Mdn=5.00), W=10, z=−2.13, p=.01562, r=−.55." 17.
1.6 Related Non-Parametric Tests
While the focus here is on the independent samples test, other related non-parametric procedures exist, such as the Wilcoxon Signed-Rank Test, which is used for analyzing repeated measures or one-sample data when parametric assumptions are violated. The Signed-Rank test, for instance, compares the distribution of differences between paired observations to zero 2.
2. Wilcoxon signed-rank test for repeated measures
The Wilcoxon Signed-Rank Test is utilized for paired (repeated) data to determine if the median difference between the pairs of observations is statistically different from zero, serving as the non-parametric alternative to the paired t-test.
The context of the Wilcoxon Signed-Rank Test (Paired Data) in statistical analysis is highlighted by its position relative to other tests categorized by data structure (independent vs. repeated) and number of groups. It is the appropriate non-parametric choice when comparing two related samples.

2.1 Hypothesis and Calculation Steps
The null hypothesis (H0) for the repeated measures scenario posits that the median difference between paired observations is zero, while the alternative hypothesis (H1) suggests the median difference is not zero 18.
The procedure for calculating the test statistics involves several methodical steps for handling the paired differences:
- Calculate Differences: Determine the difference (d) for each pair (e.g., d=score2−score1).
- Identify Zeros: Any instances where the difference is zero must be excluded from the subsequent ranking process.
- Calculate Absolute Differences: Compute the absolute value of all non-zero differences, ∣d∣.
- Rank Absolute Differences: Assign ranks to these absolute differences in ascending order. If ties exist among the absolute differences, the tied ranks must be averaged.
Example: If two absolute differences tie for the 6th and 7th positions, both receive the average rank of 6.5, calculated as (6+7)/2.

- Assign Signed Ranks: Reapply the original sign (negative or positive) to the calculated ranks corresponding to the direction of the initial difference.
- Sum Ranks: Calculate the sum of the ranks for all negative differences (W−) and the sum of the ranks for all positive differences (W+) 19.
For instance, if the sum of ranks for positive differences (W+) is 4 (based on two observations) and the sum of ranks for negative differences (W−) is 24 (based on five observations), these sums are used for the final test statistic calculation.
2.2 Interpreting Test Output and Significance
The test statistic reported by statistical software (like R's wilcox.test()) might be V, which often corresponds to the sum of ranks for the positive differences (W+), though the specific statistic reported can depend on the order in which the paired variables are entered. Regardless of which sum (W+ or W−) is used to generate the test statistic (z or V), the resulting two-sided p-value remains consistent 20.
Statistical packages handle significance testing based on sample size (n):
- If n<50, an exact test is often performed by default.
- If n≥50, a normal approximation is typically used. It is critical to note that exact p-values cannot be computed if the data set contains ties or zero differences 21.
When an exact test is used (especially when ties or zeros are present), software like R's wilcoxsign_test() might yield a two-sided p-value. If a one-sided conclusion is desired, this p-value must be halved. For example, if the output p-value is 0.1719, the one-sided p-value reported would be 0.08595. If this value (p=0.08595) is greater than the standard significance level (α=0.05), the null hypothesis is not rejected 22.
2.3 Effect Size Calculation and Reporting
For the Wilcoxon Signed-Rank Test, the effect size, denoted as r, can be calculated similarly to how it is determined for the Mann-Whitney U test. The formula relates the test statistic (z) to the total number of relevant observations (n):
r=n∣z∣
Here, n is the total count of observations (pairs), not the number of subjects if each subject only contributes one pair. If a resulting r value is, for example, 0.34, this is interpreted as representing a medium effect size 23.

Descriptive statistics, such as the median, are essential for describing the central tendency of the scores before and after the intervention, which aids in interpreting the directionality of the observed differences 24.
When reporting the results, researchers should detail the scale used (ordinal vs. continuous), the median scores for both time points, the test statistic (V), the z-value, the p-value (adjusted if necessary for one-sided tests), and the effect size (r). For instance, a report might state that depression scores were lower post-intervention (Median = 2.50) compared to pre-intervention (Median = 3.50), but the result was not statistically significant (V=24,z=1.51,p=.08595,r=.34) 25.
2.4 Context: One-Sample Wilcoxon Signed-Rank Test
Although the primary focus is repeated measures between two related groups, the Wilcoxon Signed-Rank Test is also applicable to a single sample to test if its median differs from a specified hypothesized value (μ0).
The hypotheses for the one-sample test are:
- H0: median = specified value (μ0)
- H1: median = specified value (μ0) OR H1: median > specified value OR H1: median < specified value 26.
The output from the standard wilcox.test() for a one-sample test allows the calculation of the effect size r if the z-value is obtained, typically by running a specialized function like wilcoxsign_test(). To utilize such a function for the one-sample case, two numeric vectors are required: the variable of interest and a vector of the hypothesized median values (μ0) of the same length 31.
The effect size calculation for the one-sample test is structurally the same as the paired test: r=n∣z∣ where n is the number of observations in the sample being tested. An example calculation yielding r=1.1202/8=0.40 suggests a medium effect size. In reporting, this context is crucial, especially when small sample sizes necessitate the use of this non-parametric test to compare a sample median (e.g., Mdn = 5.08) against a benchmark (e.g., 4 hours) 32 33.
3. Application and practice problems using non-parametric tests
This section focuses on applying decision-making scripts to determine the correct non-parametric test (Mann-Whitney U or Wilcoxon Signed-Rank) for specific research questions based on data structure, followed by the corresponding R functions for testing and effect size calculation.
3.1 Data Overview and Variable Types
The practice dataset, sourced from Practice2.xls, contains data on 191 retirement home residents, including demographic information and various outcome measures 37.
Key variables relevant for the practice problems include:
- Campus: Categorical (1=central, 2=east, 3=west).
- Sex: Dichotomous categorical (1=female, 2=male).
- Age: Scale variable.
- Residence_yrs: Ordinal categorical (1=0-2 yrs, 2=3-5 yrs, 3=6-8 yrs, 4=9+ yrs).
- Marital status: Ordinal categorical (1=divorced, 2=married, 3=never married, 4=widowed).
- Service Costs: Scale variable (dollars incurred in the last 2 months).
- Service type: Nominal categorical (1=occupational therapy, 2=PSW, 3=physiotherapy).
- Likert Scales (S1-S4): Ordinal variables (4=always, 1=rarely).
- Functional Scores: Scale variables (initial and final; higher scores indicate better functioning).
- TUG Scores: Scale variables measured at multiple time points (initial, interim1, interim2, final).
3.2 Practice Problem 1: One Sample Comparison (Wilcoxon Signed-Rank Test Application)
The first question asks whether average service costs for residents receiving occupational therapy are significantly greater than a constant value of USD 300 USD.
Statistical Script Analysis:
- Comparison Type: Comparing one group (occupational therapy costs) against a specified constant (μ0=300 USD).
- Data Type: Cost is a scale variable, and normality assumption is unknown.
- Test Selection: Due to unknown normality and a single sample comparison against a hypothesized mean, the Wilcoxon Signed-Rank Test is appropriate, assuming the sample size (n) is small (n<30).
- Hypothesis: This is a one-tailed test (greater than).
R Functions Required:
- To check sample size per service type:
by(data = Practice2$cost, INDICES = Practice2$service, FUN = stat.desc). - To calculate the test statistic (z-value for effect size r) and the p-value (halved for one-tail):
by(data = Practice2, INDICES = Practice2$service, FUN = function(Practice2) {wilcoxsign_test(Practice2$cost ∼ Practice2 USDmu, distribution = exact())}). - To obtain the Wilcoxon V-statistic:
by(data = Practice2, INDICES = Practice2$service, FUN = function(Practice2) {wilcox.test(Practice2$cost, mu = 300, exact = TRUE)})36.
The effect size (r) calculation, often derived from the Z-statistic, is crucial for reporting non-parametric results.

Tip: When using the Wilcoxon Signed-Rank test for a one-sample scenario with small n, using the
exactdistribution option in R functions is often preferred, and the resulting p-value must be adjusted for the one-tailed hypothesis.
3.3 Practice Problem 2: Independent Samples Comparison (Mann-Whitney U Test Application)
The second question investigates whether there are sex differences in responses to the Likert scale survey statement S1 ("Staff always listen to my requests").
Statistical Script Analysis:
- Comparison Type: Comparing two independent groups (males vs. females).
- Data Type: Survey response S1 is an ordinal variable.
- Test Selection: Comparing two independent samples based on an ordinal outcome necessitates the Mann-Whitney U Test (equivalent to the Wilcoxon Rank-Sum test).
- Hypothesis: This is a two-tailed test (difference exists).
R Functions Required:
- To obtain the z-value (for effect size r) and the two-tailed p-value:
wilcox_test(Practice2$S1 ∼ Practice2$sex, distribution = exact()). - To obtain the W-statistic:
wilcox.test(Practice2$S1 ∼ Practice2$sex, exact = TRUE)38.
Example: If we were comparing the median scores of males versus females on S1, the Mann-Whitney U test assesses if the distributions are significantly different across the ranks. The effect size r in this context relates the U statistic to the sample sizes.
3.4 Practice Problem 3: Dependent Samples Comparison (Wilcoxon Signed-Rank Test Application)
The final question examines if functional scores have significantly improved among residents on the west campus between the initial measurement and the final measurement.
Statistical Script Analysis:
- Comparison Type: Comparing two measurements (initial vs. final) on the same residents (within the specified subset: west campus).
- Data Type: Functional scores are scale variables, and normality is unknown. The samples are dependent (paired data).
- Test Selection: Comparing paired measurements on a scale variable where normality is not assumed leads to the Wilcoxon Signed-Rank Test.
- Hypothesis: This is a one-tailed test (improved, meaning final score > initial score).
R Functions Required:
- To determine initial sample size for west campus across the scores:
by(data = Practice2, INDICES = Practice2$campus, FUN = function(Practice2) {stat.desc(cbind(Practice2$initial functional score, Practice2 USDfinal functional score))}). - To obtain the z-value (for effect size r) and the one-tailed p-value:
by(data = Practice2, INDICES = Practice2$campus, FUN = function(Practice2) {wilcoxsign_test(Practice2$initial functional score ∼ Practice2 USDfinal functional score, distribution = exact())}). - To obtain the V-statistic:
by(data = Practice2, INDICES = Practice2$campus, FUN = function(Practice2) {wilcox.test(Practice2$initial functional score, Practice2 USDfinal functional score, paired = TRUE, exact = TRUE)})39.
Tip: For paired comparisons (Question 3), the key differentiator from the one-sample Wilcoxon test (Question 1) is that the data points are not compared against an external constant (μ0), but rather against the difference between the paired observations, checking if the median difference is zero.
Common mistakes to avoid
- Review all topics thoroughly before exams
- Pay attention to formulas and key definitions
- Practice with examples provided in each section
- Don't memorize without understanding the underlying concepts
© 2026 Maeve. All rights reserved. This content is protected by copyright.
