Let's say I have the following data and want to test whether the Spearman's correlation is > 0.5
x <- c(1.27, 2.37, 3.57, 4.91, 5.2, 6.9, 7.94, 8.66, 9.63, 10.1, 11.2,
12.2, 13.7, 14.4, 15.8, 16.5, 17.7, 19, 19.4, 20.8)
y <- c(7.05, 3.56, 0.515, -4.86, 9.5, 5.82, 6.94, 11.8, 12.3, 12.4,
14.7, 15.1, 13.3, 6.04, 17.5, 15.8, 16.4, 12.1, 17.1, 21.7)
In the normal case, the hypothesis test is:
$$ H_0 : \rho = 0 \\ H_a : \rho \neq 0 \\ $$
But what I want to test is:
$$ H_0 : \rho < 0.5 \\ H_a : \rho \ge 0.5 \\ $$
I see two approaches. One is based on the z-test of Fisher's transformation.
MARGIN <- 0.5
r <- cor(x, y, method = "spearman")
fisher_r <- atanh(r)
fisher_r_adjust <- atanh(MARGIN)
z <- sqrt(N-3) / sqrt(1.06) * (fisher_r - fisher_r_adjust)
pnorm(z,lower.tail = FALSE) # 0.00971
This makes sense to me (hopefully I did this right).
Another approach is based on a permutation, mentioned in the wiki article. However, I'm having trouble adopting the permutation approach. What's the correct way to do this?
perms <- sapply(1:1000, function(i) {
xs <- sample(x)
ys <- sample(y)
cor(xs, ys, method = "spearman")
})
# what to do next ?