0

Trying to obtain the confidence interval of correlation from bootstrap that of two variables. Current code is from documentation.

pearson <- function(d, i){
        d2 <- d[i,]
        return(cor(d2$LSAT,d2$GPA))
     }
bootcorr <- boot(data=d2,statistic=pearson,R=10000)
bootcorr  
boot.ci(bootcorr,conf=.95)

There is no issues getting the correlation but when obtaining the confidence interval i get an error. I suspect it is because my bootBias and bootSE is 0 but i'm not quite sure why.

The dataset is the cd4 dataset.

Column1 Column 2 
212 247
435 461
339 526
251 302
404 636
510 593
377 393
335 409
410 488
335 381
415 474
356 329
339 555
188 282
256 423
296 323
249 256
303 431
266 437
300 240
xyn
  • 25
  • 6
  • Can you write an example? How does `d2` look like? May be it is a unique value, and so, without variance, no correlation can be computed? – R18 Mar 13 '18 at 15:19
  • I've attached the dataset in the question. It's the cd4 dataset. – xyn Mar 14 '18 at 05:31
  • I do not understand your `pearson` function. You first select a row of a `data.frame` or a `matrix`. This element named `d2` will contain only one row, and thus, the correlation will give you a `NA` value because of the lack of variation in your values. Additionally your `d` object has to contain at least two columns (`$LSAT` and `$GPA`) – R18 Mar 14 '18 at 09:30

0 Answers0