I have two independed samples: df and df8. The first sample df includes points at the data1 and at the data2. These points were earned in an experimental group (n1=20). The second sample df8 includes points at the data1 and at the data2. But these points are correspond to a control group (n2=21).
From boxplot we can see that median1< median2, at the data1 and vice versa at the data2: median1> median2.
I would like to prove this fact with the Brown-Mood median test (First sample is not normal.
The null hypothesis: median1= median2. I have tested the null hypothesis at the data2 and at the data1. In both cases the null hypothesis was rejected:
data1: p-value = 0.9211>0.05
data2: p-value = 0.1378>0.05
It means that median1 < median2 twice, at the data1 and data2.
Could someone please correct me and give an idea how to statistically prove that median1< median2 (at the data1) and vice versa median1> median2 (at the data2)?
library(coin)
df <- data.frame(points1 = c(113, 145, 137, 73, 131, 137, 130, 45, 133, 119,
115, 127, 156, 141, 95, 119, 121, 120, 163, 134),
points2 = c(173, 216, 188, 0, 195, 215, 209, 62, 186, 206,
194, 216, 207, 193, 244, 228, 217, 203, 204, 207)
))
df8 <- data.frame(points1 = c(182, 123, 150, 97, 154, 155, 118, 144, 129, 121, 153, 104, 153, 125, 151, 162, 170, 133, 126, 127, 165),
points2 = c(239, 198, 188, 218, 196, 177, 191, 167, 174, 187,
195, 180, 168, 205, 211, 208, 185, 189, 180, 144, 233))
boxplot(df$points1, df8$points1, df$points2, df8$points2, ylab ="Points",
col = c("red", "green", "red", "green"), names = c("exp","con", "exp","con"))
> # Brown-Mood median test
tmp1 <- data.frame(p1 = c(df$points1,df8$points1),
g = factor(rep( c("exp", "con"), c(20, 21))))
(mt1 <- median_test(p1 ~ g, data = tmp1, alternative = "less", distribution = "exact"))
# Exact Two-Sample Brown-Mood Median Test
#data: p1 by g (con, exp)
#Z = 1.0842, p-value = 0.9211>0.05
#alternative hypothesis: true mu is less than 0
tmp2 <- data.frame(p2 = c(df$points2,df8$points2),
g = factor(rep( c("exp", "con"), c(20, 21))))
(mt1 <- median_test(p2 ~ g, data = tmp2, alternative = "less", distribution = "exact"))
# Exact Two-Sample Brown-Mood Median Test
#data: p2 by g (con, exp)
#Z = -1.3854, p-value = 0.1378>0.05
#alternative hypothesis: true mu is less than 0