comp_ci_boot: Confidence intervals for on bootstrapped datasets via...

Description Usage Arguments Details Value Examples

Description

comp_ci_boot produces confidence intervals for regression models estimates on bootstrapped datasets, via percentile bootstrap.

Usage

1
comp_ci_boot(boot_out, probs = c(0.025, 0.975), group_vars = "term")

Arguments

boot_out

A tibble of the model's coefficients estimated (term and estimate) on the bootstrapped datasets, the size of each bootstrapped dataset (m), the size of the original dataset (n), and the number of the bootstrap repetition (b).

probs

A numeric vector containing the probabilities of the quantiles to be computed.

group_vars

A vector of characters including the variables used to form the groups.

Details

comp_ci_boot takes in a set of bootstrap estimates (boot_out), a series of probabilities for the quantiles (probs), and optionally some "grouping" terms (group_vars). It returns the corresponding quantiles.

Value

A tibble containing the quantiles (x) and the probabilities (q) for each group as specified by group_vars.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# Get confidence interval for OLS estimates via bootstrap
n <- 1e3
X1 <- stats::rnorm(n, 0, 1)
X2 <- stats::rnorm(n, 0, 3)
y <- 2 + X1 + X2 * 0.3 + stats::rnorm(n, 0, 1)
reg_df <- tibble::tibble(y = y, X1 = X1, X2 = X2, n_obs = 1:length(X1))
mod_fit <- stats::lm(y ~ X1 + X2, reg_df)
boot_out <- comp_boot_emp(mod_fit)
conf_int <- comp_ci_boot(boot_out, c(0.05, 0.95)) %>%
  tidyr::pivot_wider(names_from = q, values_from = x)

# Display the output
print(conf_int)

## End(Not run)

shamindras/maar documentation built on Sept. 19, 2021, 10:21 p.m.