bootstraped spearman correlation in R
1
0
Entering edit mode
3.8 years ago
zhangdengwei ▴ 210

Hi all,

I wanna do bootstraped spearman correlation in R. I found there was a function, spearmanRho, which is capable of doing it in R. But after testing, it seems that there is no difference between with bootstrap and without bootstrap, here is my code:

> LSAT <- c(576,635,558,578,666,580,555,661,651,605,653,575,545,572,594)
> GPA <- c(3.39,3.30,2.81,3.03,3.44,3.07,3.00,3.43,3.36,3.13,3.12,2.74,
+          2.76,2.88,2.96)
> n = length(LSAT)
> xy <- data.frame(cbind(LSAT,GPA))
> xy
   LSAT  GPA
1   576 3.39
2   635 3.30
3   558 2.81
4   578 3.03
5   666 3.44
6   580 3.07
7   555 3.00
8   661 3.43
9   651 3.36
10  605 3.13
11  653 3.12
12  575 2.74
13  545 2.76
14  572 2.88
15  594 2.96 
> cor.test(xy$LSAT, xy$GPA, method = "spearman")

    Spearman's rank correlation rho

data:  xy$LSAT and xy$GPA
S = 114, p-value = 0.0006079
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.7964286 
> spearmanRho(x=xy$LSAT,y=xy$GPA,method="spearman",R=1000)
  rho 
0.796

So is there anything I did wrong? or is there any alternative to perform it in R? Any suggestions would be greatly appreciated. Thanks!

spearman correlation bootstraped spearmanRho • 1.8k views
ADD COMMENT
1
Entering edit mode
3.8 years ago
h.mon 35k

The confidence intervals are calculated by bootstrapping, not the rho statistic itself. Try:

spearmanRho(x=xy$LSAT,y=xy$GPA,method="spearman",R=1000,ci=T)
1 0.796     0.45    0.964
  
ADD COMMENT
0
Entering edit mode

h.mon, thanks for your reply. do you mean that the bootstrap would impact the confidence intervals other than rho?

ADD REPLY
2
Entering edit mode

The spearmanRho function uses the stats::cor function to calculate rho. Bootstrapping a certain number of times (the parameter R or 1000 times in your example) then gives you a confidence interval around that measurement of rho.

ADD REPLY

Login before adding your answer.

Traffic: 1552 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6