Mood test for the scale of 2 samples in R:
With mood.medtest() can you compare the medians of independent samples.
If you want to compare the differnce in scale parameters you can use the function mood.test(). You can also use ansari.test() for ansari bradley test. For those tests you must test the location of the 2 Samples. You can only test on the scale with those tests, if the 2 samples have the same location.
In your example, to test on location first with the 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
With this small p-value we reject the null hypothesis and we can not test on the scale, because the location is not equal.
In this case we can repare our data samples and use this alternative to test on the scale:
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
If the null hypothesis to the equality of locations can't be rejected, you can use directly the mood.test() without reparation with the median:
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
In this case we can't reject the Hypothesis H1, that the locations are equal and we use directly the Mood-Test to compare the scale:
mood.test(a,b)
#Mood two-sample test of scale
# data: a and b
#Z = -0.82389, p-value = 0.41
#alternative hypothesis: two.sided