Description Usage Arguments Details Value Examples
comp_ci_boot
produces confidence intervals for regression
models estimates on bootstrapped datasets, via percentile bootstrap.
1 | comp_ci_boot(boot_out, probs = c(0.025, 0.975), group_vars = "term")
|
boot_out |
A tibble of the model's coefficients estimated ( |
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. |
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.
A tibble containing the quantiles (x
) and the
probabilities (q
) for each group as specified by group_vars
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.