A regression coefficient from observational data is only as credible
as the assumption that no important variable was left out.
sensemakr (Cinelli & Hazlett, 2020) makes that
assumption concrete: it reports the coefficient you would have obtained
had a variable as strong as one of your observed covariates been
omitted. bootmakr adds a standard error, a confidence
interval and a p-value for that adjusted coefficient, obtained
by resampling the data the way you would choose standard errors for the
regression itself. This is needed because the usual tools, the impact
threshold of a confounding variable (ITCV) and the analytic interval of
sensemakr, break down when the regression calls for robust
standard errors (Lonati & Wulff, 2026); Why
bootstrap? shows why. This page shows a first analysis from start to
finish. The same steps in Stata are in Get
started in Stata.
Installation
bootmakr is installed from GitHub.
sensemakr, which it builds on, comes from CRAN and is
installed along with it.
# install.packages("remotes")
remotes::install_github("jespernwulff/bootmakr")The example data
The package comes with firms, a simulated panel of 250
firms observed for 20 years. Because the data are simulated, we know the
truth: the effect of x on y is 0.25. Two
firm-level characteristics affect both x and
y, an observed control c and a variable
q that we pretend not to have. The within-firm components
of x and of the disturbance are persistent, so standard
errors must be clustered by firm. (The data are a variant of the
simulated example in Lonati and Wulff, 2026; see ?firms for
how they were generated.)
library(bootmakr)
data("firms")
head(firms)
#> firm year y x c q
#> 1 1 1 1.1135241 0.7462263 -0.3820026 0.6451423
#> 2 1 2 0.5718906 0.5223299 -0.3820026 0.6451423
#> 3 1 3 0.6579784 0.8940660 -0.3820026 0.6451423
#> 4 1 4 1.2859237 1.2648760 -0.3820026 0.6451423
#> 5 1 5 1.3447777 1.2004796 -0.3820026 0.6451423
#> 6 1 6 0.8935023 0.8371407 -0.3820026 0.6451423Here is the regression a researcher without q would
run.
The coefficient is 0.44 instead of 0.25, because q
drives both x and y. With real data you would
not know this. What you can ask is how the result would change if a
variable as strong as something you do observe had been left
out. That is the question bootmakr answers.
A first analysis
sensemakr needs a benchmark: an observed
covariate that sets the scale for the omitted variable. We take
c and ask what the coefficient of x would be
had a variable as strong as c been omitted. In
these data that is exactly what q is.
first <- bootmakr(y ~ x + c, data = firms, treat = "x",
benchmark_covariates = "c",
cluster = "firm",
seed = 123, progress = FALSE)
first
#>
#> Call:
#> bootmakr(formula = y ~ x + c, data = firms, treat = "x", benchmark_covariates = "c",
#> seed = 123, cluster = "firm", progress = FALSE)
#>
#> Bootstrap sensitivity analysis (1,000 reps, n = 5,000, 250 clusters)
#> Benchmark: c | kd = 1, ky = 1
#>
#> Adjusted estimates (percentile 95% CI):
#> Estimate Std. Err 2.5% 97.5% Pr(>|0|)
#> x 0.252134 0.076236 0.087365 0.394215 0.01 *
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (H0: adjusted estimate = 0; CI and p-value from percentile bootstrap)
#>
#> Benchmark strength (descriptive: computed from the data, no standard errors involved)
#> Partial R2 |Partial r|
#> c with treatment | X 0.1433 0.379
#> c with outcome | D, X 0.1248 0.353
#> Implied strength of the omitted variable (sensemakr bounds):
#> kd ky R2dz.x R2yz.dx Impact
#> 1.00x c 1.00 1.00 0.1673 0.1998 0.222
#> (R2dz.x, R2yz.dx: partial R2 of the omitted variable with the treatment given the
#> covariates, and with the outcome given treatment and covariates. Impact: product of
#> its partial correlations with the outcome and with the treatment, both given the
#> covariates only, i.e. the scale of the ITCV; signed so that the omitted variable
#> biases the estimate away from zero. Descriptive only: independent of the variance
#> estimator, and not a threshold.)The call names the model, the treatment (treat), the
benchmark (benchmark_covariates) and, because observations
of the same firm are not independent, the variable that identifies the
clusters to resample (cluster). Everything else is left at
its default: an omitted variable exactly as strong as the benchmark
(kd = 1) and 1,000 bootstrap replications.
seed makes the result reproducible, and
progress = FALSE switches off the progress bar, which is
useful on screen but not in a document. The run takes about 15
seconds.
Reading the output
The adjusted estimate. Had a variable as strong as
c been omitted, the coefficient of x would be
0.252 rather than 0.445. This is the estimate sensemakr
reports for the same benchmark, and it is close to the true 0.25. It
does not involve the bootstrap.
Its uncertainty. The remaining columns come from the
bootstrap. In each of the 1,000 replications bootmakr draws
firms with replacement, refits the regression and recomputes the
adjusted estimate. The standard deviation of those 1,000 values is the
standard error (0.076), their 2.5th and 97.5th percentiles form the 95
percent confidence interval (0.087 to 0.394), and the p-value
(.010) is twice the smaller of the two shares of replications that fall
on either side of zero. The effect of x remains positive
and statistically distinguishable from zero even if an omitted variable
as strong as c is at work.
The benchmark strength. The last block says what “as
strong as c” means. c explains 14.3 percent of
the variance of x and 12.5 percent of the variance of
y that x leaves unexplained. The omitted
variable this implies has an impact of .22: the product of its
partial correlations with y and with x, which
is the scale on which the ITCV is stated. All of this is computed from
the data. No standard error is involved, so the block is the same
whatever variance estimator you prefer. See How
strong is the benchmark? for the details.
From one strength to many: the breakdown point
An omitted variable as strong as c does not overturn the
result. How much stronger would it have to be? Give kd
several values and bootmakr evaluates each of them on the
same bootstrap samples.
sweep <- bootmakr(y ~ x + c, data = firms, treat = "x",
benchmark_covariates = "c",
kd = seq(0.5, 1.5, by = 0.25),
cluster = "firm",
seed = 123, progress = FALSE)
sweep
#>
#> Call:
#> bootmakr(formula = y ~ x + c, data = firms, treat = "x", benchmark_covariates = "c",
#> kd = seq(0.5, 1.5, by = 0.25), seed = 123, cluster = "firm",
#> progress = FALSE)
#>
#> Bootstrap sensitivity analysis (1,000 reps, n = 5,000, 250 clusters)
#> Benchmark: c | kd = 0.5 0.75 1 1.25 1.5, ky = 0.5 0.75 1 1.25 1.5
#>
#> Adjusted estimates (percentile 95% CI):
#> Estimate Std. Err 2.5% 97.5% Pr(>|0|)
#> x (kd=0.5) 0.354042 0.052479 0.253451 0.456146 0 ***
#> x (kd=0.75) 0.304696 0.062805 0.176416 0.425069 0 ***
#> x (kd=1) 0.252134 0.076236 0.087365 0.394215 0.01 *
#> x (kd=1.25) 0.195903 0.093321 -0.013573 0.363798 0.066 .
#> x (kd=1.5) 0.135458 0.115036 -0.126653 0.328123 0.276
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (H0: adjusted estimate = 0; CI and p-value from percentile bootstrap)
#>
#> Benchmark strength (descriptive: computed from the data, no standard errors involved)
#> Partial R2 |Partial r|
#> c with treatment | X 0.1433 0.379
#> c with outcome | D, X 0.1248 0.353
#> Implied strength of the omitted variable (sensemakr bounds):
#> kd ky R2dz.x R2yz.dx Impact
#> 0.50x c 0.50 0.50 0.0836 0.0973 0.113
#> 0.75x c 0.75 0.75 0.1255 0.1478 0.168
#> 1.00x c 1.00 1.00 0.1673 0.1998 0.222
#> 1.25x c 1.25 1.25 0.2091 0.2536 0.274
#> 1.50x c 1.50 1.50 0.2509 0.3093 0.324
#> (R2dz.x, R2yz.dx: partial R2 of the omitted variable with the treatment given the
#> covariates, and with the outcome given treatment and covariates. Impact: product of
#> its partial correlations with the outcome and with the treatment, both given the
#> covariates only, i.e. the scale of the ITCV; signed so that the omitted variable
#> biases the estimate away from zero. Descriptive only: independent of the variance
#> estimator, and not a threshold.)
plot(sweep, type = "kd_sweep")The adjusted estimate shrinks as the assumed omitted variable grows
stronger, and its confidence interval widens. In this run the result
holds up to an omitted variable 1 times as strong as c and
breaks down at 1.25 times: from there on the interval includes zero.
That breakdown point is a compact summary of how robust the
finding is. (A p-value printed as 0 means that none of the
1,000 replications fell on the other side of zero.)
Checking the answer
Simulated data have one advantage over real ones: the omitted
variable is in the file. The regression that includes q
gives
which lies inside the bootstrap interval at kd = 1. The
Why
bootstrap? article uses the same data to show what the ITCV and the
analytic interval of sensemakr make of this example.
Working with the results
The object returned by bootmakr() keeps everything that
was computed.
sweep$results
#> kd estimate se ci_lower ci_upper pvalue r2dz.x r2yz.dx
#> 1 0.50 0.3540423 0.05247928 0.25345109 0.4561464 0.000 0.08363943 0.09728672
#> 2 0.75 0.3046965 0.06280549 0.17641581 0.4250691 0.000 0.12545914 0.14781734
#> 3 1.00 0.2521337 0.07623598 0.08736489 0.3942151 0.010 0.16727885 0.19983870
#> 4 1.25 0.1959030 0.09332121 -0.01357331 0.3637976 0.066 0.20909857 0.25356964
#> 5 1.50 0.1354581 0.11503646 -0.12665311 0.3281231 0.276 0.25091828 0.30927622
#> impact
#> 1 0.1134982
#> 2 0.1682740
#> 3 0.2216809
#> 4 0.2736747
#> 5 0.3242071estimate to pvalue are the columns of the
printed table. r2dz.x and r2yz.dx are the
partial R2 values of the omitted variable assumed in each
row, and impact its impact. The benchmark-strength block is
stored as a list.
first$benchmark_strength
#> $type
#> [1] "single"
#>
#> $observed
#> benchmark r2dxj.x r2yxj.dx r_dxj.x r_yxj.dx
#> 1 c 0.1433067 0.1247742 0.3785587 0.3532339
#>
#> $implied
#> benchmark kd ky r2dz.x r2yz.dx r_dz.x r_yz.dx r_yz.x impact
#> 1 c 1 1 0.1672789 0.1998387 0.4089974 0.4470332 0.5420107 0.2216809
#>
#> $r_yd.x
#> [1] 0.4201003The bootstrap draws themselves are in $boot_samples, one
column per value of kd, so the distribution can be
inspected without rerunning anything.
quantile(first$boot_samples[, 1], c(0.025, 0.5, 0.975))
#> 2.5% 50% 97.5%
#> 0.08736489 0.24821315 0.39421508
plot(first, type = "histogram")Finally, $sensemakr_orig holds the
sensemakr object of the original fit, so everything
sensemakr offers (its summary, robustness values and
contour plots) remains one step away.
The choices you make
The benchmark. Choose an observed covariate that is
strong and that you can argue an omitted variable is unlikely to exceed.
Report why you chose it. A group of covariates can serve as a joint
benchmark with gbenchmark_covariates = c("x1", "x2").
The multiple. kd scales the benchmark’s
relationship with the treatment and ky its relationship
with the outcome. ky follows kd unless you set
it.
The resampling scheme. It should mirror how the data
were sampled and how you would compute standard errors in the regression
itself. Without cluster, rows are resampled, which allows
for heteroskedasticity. With cluster = "id", whole clusters
are resampled. cluster = c("id1", "id2") requests two-way
clustering, and strata a stratified bootstrap. See Clustered
and stratified data.
Replications and seed. The default of 1,000
replications is fine for a first look. For results you report, use more
(5,000 or 10,000), set a seed, and when the verdict is
close to the significance threshold check that it has settled with the
converge argument.
Where next
- The worked example takes a published study through a complete analysis: the choice of standard errors, the benchmark, the breakdown point, a grouped benchmark and the convergence check.
-
Why
bootstrap? shows, on these data, why the ITCV and the analytic
interval of
sensemakrcannot be trusted with robust standard errors. -
?bootmakrdocuments every argument,?plot.bootmakrthe three plots, and?firmsthe data. - The Stata command of the same name runs the same analysis. See R and Stata side by side.
References
Cinelli, C., & Hazlett, C. (2020). Making sense of sensitivity: Extending omitted variable bias. Journal of the Royal Statistical Society: Series B, 82(1), 39–67. https://doi.org/10.1111/rssb.12348
Cinelli, C., Ferwerda, J., & Hazlett, C. (2024). sensemakr: Sensitivity analysis tools for OLS in R and Stata. Observational Studies, 10(2), 93–127. https://doi.org/10.1353/obs.2024.a946583
Lonati, S., & Wulff, J. N. (2026). Why you should not use the ITCV with robust standard errors (and what to do instead). Academy of Management Proceedings, 2026(1). https://doi.org/10.5465/AMPROC.2026.247bp