Generates an object of class "maars_lm", "lm" containing estimates of the variance of the coefficients in the regression model.

comp_var(
  mod_fit,
  boot_emp = NULL,
  boot_sub = NULL,
  boot_res = NULL,
  boot_mul = NULL
)

Arguments

mod_fit

An lm (OLS) object

boot_emp

(list) In the case of empirical bootstrap the expected input is of the form #' list(B = 10, m = 100). Here the named element m is optional e.g. list(B = 10) is valid, or passed in as an explicit NULL e.g. list(B = 10, m = NULL). Note that technically B, m should both be positive integers, but this assertion checking is handled explicitly in the comp_boot_emp function. So although passing in list(B = -15, m = -20) will pass this function without errors, these will be addressed explicitly in comp_boot_emp as invalid inputs.

boot_sub

(list) TODO: ADD

boot_res

(list) : In the case of residual bootstrap the expected input is of the form list(B = 10). Note that technically B should be a positive integer, but this assertion checking is handled explicitly in the comp_boot_res function. So although passing in list(B = -15) will pass this function without errors, these will be addressed explicitly in comp_boot_res as invalid inputs.

boot_mul

(list) : In the case of multiplier bootstrap the expected input is of the form list(B = 10, weights_type = "rademacher"). Here the named element weights_type is optional e.g. list(B = 10) is valid, or passed in as an explicit NULL e.g. list(B = 10, weights_type = NULL). Note that technically B should be a positive integer, and weights_type should be a character vector (see comp_boot_mul), but this assertion checking is handled explicitly in the comp_boot_mul function. So although passing in list(B = -15, m = "test") will pass this function without errors, these will be addressed explicitly in comp_boot_mul as invalid inputs.

Value

A "maars_lm" object containing the estimates of the variance of the regression coefficients, including the sandwich and the variance returned by stats::lm.

Details

The "maars_lm" object is basically an "lm" object with additional attributes (the additional estimates of the coefficients variance), which are stored within "var". For example, the estimates of the empirical bootstrap will be stored within "var$var_boot_emp". Each of the nested lists contains the following elements: the type of estimator of of the variance (var_type); An abbreviated string representing the type of the estimator of the variance (var_type_abb); the summary statistics of mod_fit based on this estimator of the variance (e.g., standard errors and p-values) (var_summary); the assumptions under which the estimator of the variance is consistent (var_assumptions); the covariance matrix for the coefficients estimates (cov_mat).

Examples

if (FALSE) { # Simulate data from a linear model set.seed(35542) n <- 1e2 X <- stats::rnorm(n, 0, 1) y <- 2 + X * 1 + stats::rnorm(n, 0, 1) # Fit the linear model using OLS (ordinary least squares) mod_fit <- stats::lm(y ~ X) # Run the multiplier bootstrap on the fitted (OLS) linear model set.seed(162632) out <- comp_var(mod_fit, boot_mul = list(B = 100, weights_type = "rademacher")) # print output print(out) print(out$var$var_boot_mul) }