## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5 ) options(hcinfer.use_emoji = FALSE) ## ----------------------------------------------------------------------------- library(hcinfer) schools <- PublicSchools2 schools$income_scaled <- schools$income / 10000 fit <- lm(expenditure ~ income_scaled + south, data = schools) fit ## ----------------------------------------------------------------------------- boot <- boot_pairs(fit, B = 2000, seed = 123) boot ## ----------------------------------------------------------------------------- coef(boot) vcov(boot) confint(boot) ## ----------------------------------------------------------------------------- confint(boot, level = 0.99, type = "basic") confint(boot, parm = "south", level = 0.90) ## ----bootstrap-ci-plot, fig.alt = "Pairs bootstrap confidence intervals for the public-schools regression coefficients."---- plot(boot) ## ----------------------------------------------------------------------------- data.frame( term = boot$table$term, ols = sqrt(diag(vcov(fit))), bootstrap = boot$table$std_error, hcbeta = sqrt(diag(vcov(hcinfer(fit, type = "hcbeta")))), hc3 = sqrt(diag(vcov(hcinfer(fit, type = "hc3")))) ) ## ----------------------------------------------------------------------------- a <- boot_pairs(fit, B = 1000, seed = 7) b <- boot_pairs(fit, B = 1000, seed = 7) identical(a$replicates, b$replicates) ## ----eval = FALSE------------------------------------------------------------- # boot_pairs(fit, B = 10000, cores = 4, seed = 1)