> Because ks.test seems to test whether the two distributions seen as a whole are different. What I am interested in is more specific: I'd like to test whether the distributions have their highest frequencies in the same value segment ...
But the ks.test DOES react to that because if the peak of the
cumulative distribution function / density is in different places then
ks.test will be significant even if both vectors have the normal
distribution. The following code shows this clearly by comparing two
normal distributions with the same n (100) and the same sd (2) but
with different means (5 and 3). As you can see, ks.test is ***.
##################
set.seed(1)
qwe <- rnorm(100, 5, 2)
asd <- rnorm(100, 3, 2)
par(mfrow=c(3,2))
plot(qwe, col="blue") # panel 1
plot(asd, col="red") # panel 2
hist(qwe, xlim=c(0,10), ylim=c(0, 0.4), freq=FALSE, col="blue") # panel 3
lines(density(qwe), col="blue"); lines(density(asd), col="red")
hist(asd, xlim=c(0,10), ylim=c(0, 0.4), freq=FALSE, col="red") # panel 4
lines(density(asd), col="red"); lines(density(qwe), col="blue")
plot(ecdf(qwe), xlim=c(0,10), col="blue") # panel 5
lines(ecdf(asd), col="red", lwd=0.5, pch="")
plot(ecdf(asd), xlim=c(0,10), col="red") # panel 6
lines(ecdf(qwe), col="blue", lwd=0.5, pch="")
par(mfrow=c(1,1))
ks.test(qwe, asd)
##################