boot_ci
computes bootstrapped confidence intervals from a matrix of
coefficients (or any statistical information of interest). The function is an
alternative to confint2.boot
for when the user does not have an object
of class boot
, but rather creates their own matrix of coefficients. It
has limited types of bootstrapped confidence intervals at the moment, but
future versions are expected to have more options.
boot_ci(coef, est = colMeans(coef), boot.ci.type = "perc2", level = 0.95)
data.frame will be returned with nrow equal to the number of
coefficients bootstrapped and columns specified below. The rownames are the
colnames in the coef
argument or the names in the est
argument
(default data.frame rownames if neither have any names). The columns are the
following:
original parameter estimates
bootstrapped standard errors (does not differ by boot.ci.type
)
lower bound of the bootstrapped confidence intervals
upper bound of the bootstrapped confidence intervals
numeric matrix (or data.frame of numeric columns) of
coefficients. The rows correspond to each bootstrapped resample and the
columns to different coefficients. This is the equivalent of the "t"
element in a boot
object.
numeric vector of observed coefficients from the full sample. This
is the equivalent of the "t0" element in a boot
object. The default
takes the mean of each coefficient across bootstrapped resamples; however,
this usually results in small amount of bias in the coefficients.
character vector of length 1 specifying the type of
bootstrapped confidence interval to compute. The options are 1) "perc2" for
the naive percentile method using quantile
, and 2) "norm2"
for the normal method that uses the bootstrapped standard error to
construct symmetrical confidence intervals with the classic formula around
the estimate, The options have a "2" after them because, although they are
conceptually similar to the "perc" and "norm" methods in the
boot.ci
function, they are slightly different
mathematically.
double vector of length 1 specifying the confidence level. Must be between 0 and 1.
boot.ci
for the confidence interval function in the boot
package,
confint.boot
for an alternative function with boot
objects
tmp <- replicate(n = 100, expr = {
i <- sample.int(nrow(attitude), replace = TRUE)
colMeans(attitude[i, ])
}, simplify = FALSE)
mat <- str2str::lv2m(tmp, along = 1)
boot_ci(mat, est = colMeans(attitude))
Run the code above in your browser using DataLab