\(~\)
For this final blog I decided to dig more into non-parametric tests that was mentioned in the weekly video for the class. Non-parametric tests is a method of statistical analysis that does not require a normally distributed data. It serves an alternative to parametric tests such as T-test or ANOVA.
\(~\)
When to use non-parametric tests?:
\(~\)
The main nonparametric tests are:
\(~\)
There can be some disadvantages to non-parametric tests:
Lets put one of these non-parametric tests to the test in R. I will be using the 1-sample Wilcoxon signed rank test.
Below is the libraries used for this case:
library(stats) # wilcox.test()
library(ggplot2)
library(hrbrthemes)
We first create our values to use and then using the
wilcox.test()
we can start testing.
To check if we can reject our null or alternate hypotheses our significance level alpha must be less than 0.05.
\(~\)
Other parameters:
\(~\)
# The data set
set.seed(1234)
= data.frame(
myData name = paste0(rep("R_", 10), 1:10),
weight = round(rnorm(10, 30, 2), 1)
)
# Print the data
myData
## name weight
## 1 R_1 27.6
## 2 R_2 30.6
## 3 R_3 32.2
## 4 R_4 25.3
## 5 R_5 30.9
## 6 R_6 31.0
## 7 R_7 28.9
## 8 R_8 28.9
## 9 R_9 28.9
## 10 R_10 28.2
\(~\)
The distribution:
ggplot(myData, aes(x=weight)) +
geom_histogram(binwidth=2, fill="#69b3a2", color="#e9ecef", alpha=0.9) +
theme_ipsum()
\(~\)
# One-sample wilcoxon test 1
wilcox.test(myData$weight, mu = 25)
##
## Wilcoxon signed rank test with continuity correction
##
## data: myData$weight
## V = 55, p-value = 0.005793
## alternative hypothesis: true location is not equal to 25
# One-sample wilcoxon test 2
wilcox.test(myData$weight, mu = 25,
alternative = "less") # testing if the median is less than 25
##
## Wilcoxon signed rank test with continuity correction
##
## data: myData$weight
## V = 55, p-value = 0.9979
## alternative hypothesis: true location is less than 25
# One-sample wilcoxon test 3
wilcox.test(myData$weight, mu = 25,
alternative = "greater") # testing if the median is greater than 25
##
## Wilcoxon signed rank test with continuity correction
##
## data: myData$weight
## V = 55, p-value = 0.002897
## alternative hypothesis: true location is greater than 25
\(~\)
After creating 3 different tests we notice the following:
\(~\)
Non parametric data and tests (distribution free tests). Statistics How To. (2021, May 31). Retrieved November 26, 2022, from https://www.statisticshowto.com/probability-and-statistics/statistics-definitions/parametric-and-non-parametric-data/
Glen, S. (n.d.). Wilcoxon signed rank test: Definition, how to run, SPSS. Statistics How To. Retrieved December 8, 2022, from https://www.statisticshowto.com/probability-and-statistics/statistics-definitions/wilcoxon-signed-rank-test/
Rout, A. R. (2021, December 23). Wilcoxon signed rank test in R programming. GeeksforGeeks. Retrieved December 8, 2022, from https://www.geeksforgeeks.org/wilcoxon-signed-rank-test-in-r-programming/
Mangiafico., S. S. (2015). Wilcoxon signed-rank test. R Companion: Wilcoxon Signed-rank Test. Retrieved December 8, 2022, from http://rcompanion.org/rcompanion/d_10.html
Wilcoxon signed rank test in R programming. GeeksforGeeks. (2021, December 23). Retrieved December 8, 2022, from https://www.geeksforgeeks.org/wilcoxon-signed-rank-test-in-r-programming/