# This R code pertains to the jackknife results of Ch. 10 of E&T. # First I'll read in the data and compute the y and z values. patch <- read.table("http://mason.gmu.edu/~csutton/EandTT101.txt", header=TRUE) attach(patch) z <- oldpatch - placebo y <- newpatch - oldpatch theta.hat <- mean(y)/mean(z) theta.hat # This is the estimate of theta. ( (10.11) on p. 128 ) # Now to get the jackknife replicates. ybar.rep <- ( sum(y) - y )/7 zbar.rep <- ( sum(z) - z )/7 th.rep <- ybar.rep/zbar.rep bias.jk <- 7*( mean( th.rep ) - theta.hat ) bias.jk # This is the jackknife estimate of bias. ( (10.32) on p. 134 ) s.e.jk <- sd( th.rep )*7/sqrt(8) s.e.jk # This is the jackknife estimate of s.e.. ( (10.35) on p. 137 ) ### Here is another way to get the theta hat replicates. alt.th.rep <- numeric() for (i in 1:8) alt.th.rep[i] <- mean(y[-i])/mean(z[-i]) # Now I'll check these replicate values by comparing them with the # previously obtained replicate values. compare <- cbind(th.rep, alt.th.rep) compare