comp_boot_mul_ind calculates a single replication of the multiplier bootstrap for an OLS fitted dataset based on an lm fitted object in R. This is given by the following expression: $$\frac{1}{n}\sum_{i=1}^{n} e_{i}\widehat{J}^{-1}X_{i}(Y_{i}-X_{i}^{T} \widehat{\beta})$$.

comp_boot_mul_ind(J_inv_X_res, e)

Arguments

J_inv_X_res

A \(d \times \d\) matrix given by the expression \(\sum_{i=1}^{n}\widehat{J}^{-1}X_{i}(Y_{i}-X_{i}^{T} \widehat{\beta})\).

e

multiplier bootstrap weights. This is an \(n \times 1\) vector of mean zero, variance 1 random variables.

n

Number of observations (rows) of the underlying dataset. In the given notation we assume our dataset has \(n\) observations and \(d\) features (including an intercept)

Value

A tibble of the bootstrap standard errors.

Examples

if (FALSE) { # Run an linear model (OLS) fit set.seed(162632) n <- 1e2 X <- stats::rnorm(n, 0, 1) y <- 2 + X * 1 + stats::rnorm(n, 0, 1) lm_fit <- stats::lm(y ~ X) # Calculate the necessary required inputs for the bootstrap J_inv <- summary.lm(lm_fit)$cov.unscaled X <- qr.X(lm_fit$qr) res <- residuals(lm_fit) n <- length(res) J_inv_X_res <- 1:nrow(X) %>% purrr::map(~ t(J_inv %*% X[.x, ] * res[.x])) %>% do.call(rbind, .) # Generate a single random vector of length n, containing # mean 0, variance 1 random variables e <- rnorm(n, 0, 1) # Run a single replication of the multiplier bootstrap mult_boot_single_rep <- comp_boot_mul_ind( n = n, J_inv_X_res = J_inv_X_res, e = e ) # Display the output print(mult_boot) }