Description Usage Arguments Value References Examples
Construct confidence functions from the output of bcaboot. This is a helper function to make constructing ones own bootstrap confidence functions straightforward.
1 |
bc |
an output from bcaboot |
A list or list of lists containing the confidence functions pconf, dconf, cconf, and qconf for the parameter associated with the statistic(s) used with bcaboot.
Tore Schweder and Nils Lid Hjort. Confidence, likelihood, probability. Vol. 41. Cambridge University Press, 2016.
Bradley Efron and Trevor Hastie. Computer Age Statistical Inference. Vol. 5. Cambridge University Press, 2016.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Reproduce BCa confidence density from Figure 11.7
# of *Computer Age Statistical Inference*.
scor <-
read.table('https://web.stanford.edu/~hastie/CASI_files/DATA/student_score.txt',
header = TRUE)
statistic <- function(data, id = 1:nrow(data), ...){
dat <- data[id, ]
Sigma <- cov(dat)*((nrow(dat)-1)/nrow(dat))
lams <- eigen(Sigma, symmetric = TRUE, only.values = TRUE)$values
return(lams[1])
}
ran.gen <- function(data, mle){
MASS::mvrnorm(n = nrow(data), mle$mu, mle$Sigma)
}
bc <- bcaboot(data = scor, statistic = statistic, B = 8000, sim = "parametric", ran.gen = ran.gen,
mle = list(mu = colMeans(scor),
Sigma = cov(scor)*((nrow(scor)-1)/nrow(scor))))
lam.conf <- conffuns.from.bcaboot(bc)
display.cconf(lam.conf, xlab = 'Largest Eigenvalue')
display.dconf(lam.conf, xlab = 'Largest Eigenvalue')
lam.conf$qconf(c(0.025, 0.975))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.