# # EPage 139 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # Lets do the bootstrap confidence interval WITH the z transform: # z.transform = function(r) 0.5 * log( (1+r)/(1-r) ) z.inverse = function(z) (exp(2*z)-1)/(exp(2*z)+1) possum.fun = function(data, indices){ chest = data$chest[indices] belly = data$belly[indices] z.transform(cor(belly,chest)) } possum.boot = boot( possum, possum.fun, R=999 ) print( "CI: with the z-transform" ) print( z.inverse( boot.ci(possum.boot, type="perc")$percent[4:5] ) ) # Lets do the bootstrap confidence interval WITHOUT the z transform: # possum.fun = function(data, indices){ chest = data$chest[indices] belly = data$belly[indices] cor(belly,chest) } possum.boot = boot( possum, possum.fun, R=999 ) print( "CI: without the z-transform" ) print( boot.ci(possum.boot, type="perc")$percent[4:5] )