# NOT RUN {
# See Examples under RSlo()
# }
# NOT RUN {
# WHA experiments with BL_r()
n <- 10; r <- 3; nsim <- 10000; alpha <- 0.05; Tcrit <- 3.82
BLs <- Ho <- RHS <- SPt <- rep(NA, nsim)
EQ <- sqrt(r^2*(n-1)*(n-r-1)/(n*r+n))
for(i in 1:nsim) { # some simulation results shown below
BLs[i] <- abs(BLlo(rnorm(n), r)) # abs() correcting TAC sign convention
t <- sqrt( (n*(n-2)*BLs[i]^2) / (r*(n-r)*(n-1)-n*BLs[i]^2) )
RHS[i] <- choose(n,r)*pt(t, n-2, lower.tail=FALSE)
ifelse(t >= EQ, SPt[i] <- RHS[i], SPt[i] <- 1) # set SP(t) to unity?
Ho[i] <- BLs[i] > Tcrit
}
results <- c(quantile(BLs, prob=1-alpha), sum(Ho /nsim), sum(SPt < alpha)/nsim)
names(results) <- c("Critical_value", "Ho_rejected", "Coverage_SP(t)")
print(results) # minor differences are because of random number seeding
# Critical_value Ho_rejected Coverage_SP(t)
# 3.817236 0.048200 0.050100
# }
Run the code above in your browser using DataCamp Workspace