[R] confidential interval of correlation coefficient using bootstrap

XIAO LIU xiaoliu at jhmi.edu
Sat Apr 10 20:21:41 CEST 2004


I tried 2 methods to estimate C.I. of correlation coefficient of variables x and y:

> x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
> y <- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)

#METHOD 1: Pearson's
**********************************************************
> cor.test(x, y, method = "pearson", conf.level = 0.95)

        Pearson's product-moment correlation

data:  x and y 
t = 1.8411, df = 7, p-value = 0.1082
alternative hypothesis: true correlation is not equal to 0 
95 percent confidence interval:
 -0.1497426  0.8955795 
sample estimates:
      cor 
0.5711816 
***********************************************************

#METHOD 2: bootstrap
***********************************************************
> boot(cbind(x,y), cor, 200)

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = cbind(x, y), statistic = cor, R = 200)


Bootstrap Statistics :
     original     bias    std. error
t1* 0.5429120 -0.5232893   0.3799117
t2* 0.3832856 -0.3779026   0.3876666
************************************************************

'cor.test' gave the value of cor as 0.5711816.  Why did 'boot' give two original cors: t1 and t2.  And why does none of t1 and t2 equal to what 'cor.test' gave.

Thank you very much

Xiao




More information about the R-help mailing list