function(k, n0, pstar, conf, rep) { # last update 2/23/00 # function to compute critical constants for comparisons with a standard # when mu is unknown and var-cov matrix satisfies sphericity # k = number of systems, excluding baseline # n0 = initial sample size # pstar = single 1-alpha (PCS) # conf = confidence level on upper bounds for critical values # rep = number of reps to estimate critical values # # returns (g,h) with conf*100% upper confidence bounds # (confidence on h is actually 1 - (1-conf)/2) # # first get h set.seed(13.) conf <- 1 - (1 - conf)/2 Z <- matrix(rnorm(k * rep), ncol = k) Z0 <- matrix(rnorm(rep), ncol = 1.) Z0mat <- matrix(Z0, nrow = rep, ncol = k, byrow = F) C <- sqrt(matrix(rchisq(rep, (n0 - 1.) * k), ncol = 1.)/(k * (n0 - 1.)) ) Cmat <- matrix(C, nrow = rep, ncol = k, byrow = F) MVT <- (sqrt(1./2.) * Z - sqrt(1./2.) * Z0mat)/Cmat H <- sort(apply(MVT, 1., max)) Hstar <- quantile(H, pstar) upper <- ceiling(pstar * rep + qnorm(conf) * sqrt(pstar * (1. - pstar) * rep) + 0.5) # # # then get g Hupper <- H[upper] Z <- matrix(rnorm(k * rep), ncol = k) Z0 <- matrix(rnorm(rep), ncol = 1.) Z0mat <- matrix(Z0, nrow = rep, ncol = k, byrow = F) C <- sqrt(matrix(rchisq(rep, (n0 - 1.) * k), ncol = 1.)/(k * (n0 - 1.)) ) Cmat <- matrix(C, nrow = rep, ncol = k, byrow = F) MVT <- (sqrt(1./2.) * Z - sqrt(1./2.) * Z0mat)/Cmat MVT[, 1.] <- MVT[, 1.] + Hupper G <- sort(apply(MVT, 1., max)) Gstar <- quantile(G, pstar) upper <- ceiling(pstar * rep + qnorm(conf) * sqrt(pstar * (1. - pstar) * rep) + 0.5) Gupper <- G[upper] result <- cbind(c(Hstar, Hupper), c(Gstar, Gupper)) result }