#This first script is what I run in class 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) plot(LSAT,GPA) School=as.data.frame(cbind(LSAT,GPA),row.names=NULL) # You should try the command below without stype (the default) lsat.boot=boot(School,corr,R=999,stype="w") lsat.boot boot.ci(lsat.boot,conf=.95,type=c("norm","basic","perc","bca")) # # An alternative approach using a different stype # corrlsat=function(d,w) { data=d[w,] return(corr(data)) } lsat.boot=boot(School,corrlsat,R=999,stype="i") boot.ci(lsat.boot,conf=.95,type=c("norm","basic","perc","bca")) # # After loading the data and re-running lsat.boot and corrlsat, # here are commands to accompany the bootstrap exercise. # # The following command generates CIs for the transformation atanh # This command won't produce percentile t (studentized) CIs because # no variance function is provided. boot.ci(lsat.boot,type="all",h=atanh) # Change corrlsat to provide a variance function for the percentile t # method. corrlsat=function(d,w) { data=d[w,] nd=dim(data)[1] return(c(corr(data),((1-corr(data)^2)^2)/(nd-3))) } lsat.boot=boot(School,corrlsat,R=999,stype="i") boot.ci(lsat.boot,type="all",h=atanh,hdot=function(x) 1/(1-x)^2) # Now provide the inverse function to obtain CIs on the original metric lsat.boot=boot(School,corrlsat,R=999,stype="i") boot.ci(lsat.boot,type="all",h=atanh,hinv=tanh,hdot=function(x) 1/(1-x)^2)