0% found this document useful (0 votes)
30 views4 pages

Nonparametric Test Examples and Codes

The document outlines various statistical tests including the Sign Test, Wilcoxon Signed Rank Test, Mann-Whitney U Test, Run Test, Kolmogorov-Smirnov Test, Spearman's Rank Correlation, and Kendall's Tau. Each test is accompanied by its purpose, assumptions, examples, and corresponding R code for implementation. These tests are used for analyzing paired or independent samples, assessing randomness, and measuring associations between variables.

Uploaded by

Mahesh veera
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

Nonparametric Test Examples and Codes

The document outlines various statistical tests including the Sign Test, Wilcoxon Signed Rank Test, Mann-Whitney U Test, Run Test, Kolmogorov-Smirnov Test, Spearman's Rank Correlation, and Kendall's Tau. Each test is accompanied by its purpose, assumptions, examples, and corresponding R code for implementation. These tests are used for analyzing paired or independent samples, assessing randomness, and measuring associations between variables.

Uploaded by

Mahesh veera
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Sign Test

Purpose:

Tests the median of a single sample or compares the medians of two related samples (paired data).

Assumptions:

- Data is paired and from the same population.

- Differences are independent.

- Only the sign of the differences (+ or -) is used.

Example:

Before and after weights of 6 people:

Before = c(70, 68, 65, 72, 74, 69)

After = c(68, 66, 64, 71, 74, 68)

R Code:

before <- c(70, 68, 65, 72, 74, 69)

after <- c(68, 66, 64, 71, 74, 68)

library(BSDA)

[Link](before, after = after, md = 0, alternative = "[Link]")

2. Wilcoxon Signed Rank Test

Purpose:

Tests whether the median of the differences between paired observations is zero.

Assumptions:

- Paired samples.

- Data is at least ordinal.

- Symmetry of the distribution of differences.


Example:

before <- c(10, 20, 30, 40, 50)

after <- c(12, 18, 33, 39, 48)

R Code:

[Link](before, after, paired = TRUE)

3. Mann-Whitney U Test (Wilcoxon Rank Sum Test)

Purpose:

Compares two independent samples to test if they come from the same distribution.

Assumptions:

- Observations are independent.

- Ordinal scale or higher.

Example:

group1 <- c(85, 90, 88, 75, 95)

group2 <- c(80, 70, 78, 85, 89)

R Code:

[Link](group1, group2)

4. Run Test

Purpose:

Tests the randomness of a sequence.

Assumptions:

- Binary or dichotomous data.


Example:

data <- c(1, 0, 1, 1, 0, 0, 1, 0)

R Code:

library(tseries)

[Link]([Link](data))

5. Kolmogorov-Smirnov Test

Purpose:

Tests if a sample follows a specified distribution or compares two samples.

Assumptions:

- Continuous data.

- Independent samples.

Example (One sample):

x <- rnorm(50)

R Code:

[Link](x, "pnorm", mean = mean(x), sd = sd(x))

Example (Two samples):

x <- rnorm(50)

y <- runif(50)

[Link](x, y)

6. Spearman's Rank Correlation

Purpose:
Measures the strength and direction of the monotonic relationship between two variables.

Assumptions:

- Ordinal data.

- Monotonic relationship.

Example:

x <- c(10, 20, 30, 40, 50)

y <- c(5, 15, 25, 35, 45)

R Code:

[Link](x, y, method = "spearman")

7. Kendall's Tau

Purpose:

Measures association between two ordinal variables.

Assumptions:

- Data should be ordinal.

Example:

x <- c(1, 2, 3, 4, 5)

y <- c(3, 2, 1, 5, 4)

R Code:

[Link](x, y, method = "kendall")

You might also like