I’m testing the correlation between two variables:
set.seed(123)
x <- rnorm(20)
y <- x + x * 1:20
cor.test(x, y, method = c("spearman"))
which gives:
Spearman's rank correlation rho
data: x and y
S = 54, p-value = 6.442e-06
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.9594
The p-value is testing the null hypothesis that the correlation is zero. Is there an R function that will allow me to test a different null hypothesis – say that the correlation is less than or equal to 0.3?
It doesn’t say in the question, but if you can live with Pearson assumptions (bivariate normal), you can just look to the upper bound of the confidence interval. Any null hypothesis like yours that is greater than that would be rejected at p<0.05.