In this article, we will discuss the importance of establishing a safe environment to confirm regularities, as well as introduce the Wilcoxon signed rank test in R.
Regularities in Data
Before we dive into the Wilcoxon signed rank test, let's talk about regularities in data. Regularities refer to patterns or structures present in the data. In statistics, it is crucial to check for regularities before conducting statistical tests. This ensures that our results are accurate and reliable.
Wilcoxon Signed Rank Test
The Wilcoxon signed rank test is a non-parametric test used to compare paired samples. It is often used to assess whether there is a significant difference between two related variables, such as the change in scores before and after an intervention.
However, what many people don't know is that the Wilcoxon signed rank test can also be used for one-sample tests. This means we can use it to compare a single sample to a known distribution or median.
Code
Let's take a look at some R code that demonstrates the usage of the Wilcoxon signed rank test:
# Load libraries
library(readr)
# Set working directory
setwd("C:/Users/user/Documents/Tistory_blog")
# Load data
df <- read_csv("Data.csv")
# Check regularities in NP1_raw
qqnorm(df$NP1_raw)
qqline(df$NP1_raw)
hist(df$NP1_raw, prob=TRUE)
# Shapiro-Wilk test for normality
shapiro.test(df$NP1_raw)
# Wilcoxon signed rank test for one-sample test
wilcox.test(df$NP1_raw, mu=55, alternative="greater", correct=FALSE)
wilcox.test(df$NP1_raw, mu=55, alternative="less", correct=FALSE)
wilcox.test(df$NP1_raw, mu=55, alternative="two.sided", correct=FALSE)
wilcox.test(df$NP1_raw, mu=55, correct=FALSE)
# Median of NP1_raw
median(df$NP1_raw)
# One-sample test with median as the target value
wilcox.test(df$NP1_raw, mu=50, alternative="two.sided", correct=FALSE)
This code demonstrates how to check regularities in data using Q-Q plots and histograms. It also shows how to perform a one-sample Wilcoxon signed rank test to compare a single sample to a known distribution or median.
In this article, we discussed the importance of establishing a safe environment to confirm regularities in data. We also introduced the Wilcoxon signed rank test, which can be used for both paired and one-sample tests. By using R code, we demonstrated how to perform these tests and check for regularities in data.
References
- [R] Wilcoxon Signed Rank Test
- [R] Shapiro-Wilk Test
Date Written: 2022.11.29.
Last Updated: 2022.11.29.
Software Used: R 4.2.2, RStudio v2022.07.2