library(readxl)
Mann_Whitney <- read_excel("D:/MARV BS MATH/4th year, 2nd sem/Nonparametric Statistics/Final Exam/Mann-Whitney.xlsx")
Mann_Whitney
# A tibble: 5 × 2
antidepressantdrug placebo
<dbl> <dbl>
1 11 11
2 1 11
3 0 5
4 2 8
5 0 4
The following assumptions must be met in order to run a Mann-Whitney U test:
normality_check <- shapiro.test(Mann_Whitney$antidepressantdrug)
if (normality_check$p.value > 0.05){
print("The data comes from a population that is normally distributed. Please check the result of two sample t test.")
} else {
print("The data is not normally distribued. Please check the result of Mann-Whitney U test.")
}
[1] "The data is not normally distribued. Please check the result of Mann-Whitney U test."
normality_check <- shapiro.test(Mann_Whitney$placebo)
if (normality_check$p.value > 0.05){
print("The data comes from a population that is normally distributed. Please check the result of two sample t test.")
} else {
print("The data is not normally distribued. Please check the result of Mann-Whitney U test.")
}
[1] "The data comes from a population that is normally distributed. Please check the result of two sample t test."
head(Mann_Whitney)
# A tibble: 5 × 2
antidepressantdrug placebo
<dbl> <dbl>
1 11 11
2 1 11
3 0 5
4 2 8
5 0 4
library(psych)
Warning: package 'psych' was built under R version 4.2.3
str(Mann_Whitney)
tibble [5 × 2] (S3: tbl_df/tbl/data.frame)
$ antidepressantdrug: num [1:5] 11 1 0 2 0
$ placebo : num [1:5] 11 11 5 8 4
summary(Mann_Whitney)
antidepressantdrug placebo
Min. : 0.0 Min. : 4.0
1st Qu.: 0.0 1st Qu.: 5.0
Median : 1.0 Median : 8.0
Mean : 2.8 Mean : 7.8
3rd Qu.: 2.0 3rd Qu.:11.0
Max. :11.0 Max. :11.0
wilcox.test(Mann_Whitney$antidepressantdrug, Mann_Whitney$placebo)
Wilcoxon rank sum test with continuity correction
data: Mann_Whitney$antidepressantdrug and Mann_Whitney$placebo
W = 4, p-value = 0.08969
alternative hypothesis: true location shift is not equal to 0
Since the p-value is 0.08969 which is greater than the significance level 0.05, we do not have sufficient evidence to say that the level of depression of depressed patients which is administered by antidepressant drug is different from the placebo group.
wilcox.test(Mann_Whitney$antidepressantdrug, Mann_Whitney$placebo, alternative = "less")
Warning in wilcox.test.default(Mann_Whitney$antidepressantdrug,
Mann_Whitney$placebo, : cannot compute exact p-value with ties
Wilcoxon rank sum test with continuity correction
data: Mann_Whitney$antidepressantdrug and Mann_Whitney$placebo
W = 4, p-value = 0.04484
alternative hypothesis: true location shift is less than 0
Since the p value is 0.04484 which is less than the significance level 0.05,
We have sufficient evidence to say that the level of depression of depressed patients administered by antidepressant drug was less than that of the patients in the placebo group. Hence, antidepressant drug is effective.