# jacktest.r December 2007 # # compare speeds for jackknife # # First method -- create matrix and use apply # data set.seed(5151917) N <- 1000 v <- -log(runif(N)) # generate exponential RVs mean(v,trim=.2) # compute statistic on data # proc.time() # read clock before execution V <- matrix(v,N-1,N) # compute statistic vps <- apply(V,2,mean,trim=.2) proc.time() # read clock after execution var(vps) mean(vps) # # Second method -- using loop proc.time() # read clock before execution vps <- rep(0,N) for(i in(1:N)){ vps[i]<-mean(v[-i],trim=.2) } proc.time() # read clock after execution mean(vps) var(vps) # done rm(list=ls()) q()