library(boot) 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) Brep = 10000 xy <- data.frame(cbind(LSAT,GPA)) xy # Bootstrap the Pearson correlation coefficient pearson <- function(d,i=c(1:n)){ d2 <- d[i,] return(cor(d2$LSAT,d2$GPA)) } bootcorr <- boot(data=xy,statistic=pearson,R=Brep) bootcorr boot.ci(bootcorr,conf=.95) windows() par(mfrow=c(2,1)) hist(bootcorr$t,main="Bootstrap Pearson Sample Correlation Coefficients") plot(ecdf(bootcorr$t),main="ECDF of Bootstrap Correlation Coefficients") # Bootstrap the transformed Pearson correlation coefficient xihat <- function(dd,i=c(1:n)){ dd2 <- dd[i,] return(.5*log((1+cor(dd2$LSAT,dd2$GPA))/(1-cor(dd2$LSAT,dd2$GPA)))) } bootxi <- boot(data=xy,statistic=xihat,R=Brep) bootxi boot.ci(bootxi,conf=.95) windows() par(mfrow=c(2,1)) hist(bootxi$t,main="Bootstrap Transformed Correlation Coefficients") plot(ecdf(bootxi$t),main="ECDF of Bootstrap Transformed Correlation Coefficients")