我确实有
a<-rnorm(10,0,1)
b<-rnorm(10,3,1)我想测试下面的假设“它们是相等的,没有移位”与“第二个a从第一个移位”相比,我搜索了中位数检验w,它使用的是比合并的中位数更多的值,但我找不到一个,在我找到的中位数检验中,我不能从中提取p值。
发布于 2020-09-23 04:03:49
使用mood.test()将Mood的中位数测试内置到基数R中
set.seed(123)
n <- 10000
a <- rnorm(n, 0, 1)
b <- rnorm(n, 3, 1)
mood_fit <- mood.test(a, b)
mood_fit
# Mood two-sample test of scale
#
# data: a and b
# Z = -0.026159, p-value = 0.9791
# alternative hypothesis: two.sided要提取p值,请使用$p.value属性:
mood_fit$p.value
[1] 0.9791303发布于 2021-06-10 08:24:36
R:中2个样本规模的情绪测试
使用mood.medtest()可以比较独立样本的中位数。如果要比较缩放参数的不同,可以使用函数mood.test()。您还可以使用ansari.test()进行ansari bradley测试。对于这些测试,您必须测试两个样本的位置。如果两个样本具有相同的位置,则只能使用这些测试在刻度上进行测试。
在您的示例中,要首先使用wilcoxon-Rang- test在位置上进行测试:
a = rnorm(10,0,1)
b = rnorm(10,3,1)
wilcox.test(a,b)
# Wilcoxon rank sum exact test
# data: a and b
# W = 3, p-value = 7.578e-05
# alternative hypothesis: true location shift is not equal to 0有了这个小的p值,我们拒绝了零假设,并且我们不能在规模上进行测试,因为位置不相等。
在这种情况下,我们可以重新检查我们的数据样本,并使用此替代方案在规模上进行测试:
mood.test(a-median(a),b-median(b))
Mood two-sample test of scale
# data: a - median(a) and b - median(b)
# Z = 0.26482, p-value = 0.7911
# alternative hypothesis: two.sided 如果位置相等的空假设不能被拒绝,您可以直接使用mood.test(),而不使用中位数:
a = rnorm(10,0,1)
b = rnorm(10,0,2)
wilcox.test(a,b)
#Wilcoxon rank sum exact test
#data: a and b
#W = 55, p-value = 0.7394
#alternative hypothesis: true location shift is not equal to 0在这种情况下,我们不能拒绝位置相等的假设H1,我们直接使用情绪测试来比较规模:
mood.test(a,b)
#Mood two-sample test of scale
# data: a and b
#Z = -0.82389, p-value = 0.41
#alternative hypothesis: two.sidedhttps://stackoverflow.com/questions/64016844
复制相似问题