#Code to run on each core library(boot) calc.t2 <- function(data, i) { d2 <- data[i] var(d2) } calc.t <- function(data, i) { d <- data[i] n <- length(d) l.jack <- empinf(data = d, statistic = calc.t2, stype = "i", type = "jack") v.jack <- var.linear(L = l.jack) c(var(d), v.jack) } sim.func <- function(y, alpha, R = 1999) { n <- length(y) t <- var(y) normal.based <- (n - 1)*t / qchisq(p = c(1-alpha/2, alpha/2), df = n - 1) mu.hat4 <- 1/n*sum((y - mean(y))^4) asym <- t + qnorm(p = c(alpha/2, 1-alpha/2))*sqrt((mu.hat4 - t^2)/n) boot.res <- boot(data = y, statistic = calc.t, R = R, sim = "ordinary") save.int <- boot.ci(boot.out = boot.res, conf = 1-alpha, type = "all") basic <- c(save.int$basic[4], save.int$basic[5]) percentile <- c(save.int$perc[4], save.int$perc[5]) bca <- c(save.int$bca[4], save.int$bca[5]) student <- c(save.int$student[4], save.int$student[5]) c(normal.based, asym, basic, percentile, bca, student) } #