(EXPERIMENTAL) Bootstrap and Simulation-Based Inference
Description
Warning: This function is experimental. It may be renamed, the user interface may change, or the functionality may migrate to arguments in other marginaleffects
functions.
Apply this function to a marginaleffects
object to change the inferential method used to compute uncertainty estimates.
Usage
inferences(x, method, R = 1000, conf_type = "perc", ...)
Arguments
x |
Object produced by one of the core marginaleffects functions.
|
method |
String
-
"delta": delta method standard errors
-
"boot" package
-
"fwb": fractional weighted bootstrap
-
"rsample" package
-
"simulation" from a multivariate normal distribution (Krinsky & Robb, 1986)
-
"mi" multiple imputation for missing data
|
R |
Number of resamples or simulations.
|
conf_type |
String: type of bootstrap interval to construct.
-
boot : "perc", "norm", "basic", or "bca"
-
fwb : "perc", "norm", "basic", "bc", or "bca"
-
rsample : "perc" or "bca"
-
simulation : argument ignored.
|
... |
-
If method=“boot” , additional arguments are passed to boot::boot() .
-
If method=“fwb” , additional arguments are passed to fwb::fwb() .
-
If method=“rsample” , additional arguments are passed to rsample::bootstraps() .
-
If method=“simulation” , additional arguments are ignored.
|
Details
When method=“simulation”
, we conduct simulation-based inference following the method discussed in Krinsky & Robb (1986):
-
Draw R
sets of simulated coefficients from a multivariate normal distribution with mean equal to the original model’s estimated coefficients and variance equal to the model’s variance-covariance matrix (classical, "HC3", or other).
-
Use the R
sets of coefficients to compute R
sets of estimands: predictions, comparisons, or slopes.
-
Take quantiles of the resulting distribution of estimands to obtain a confidence interval and the standard deviation of simulated estimates to estimate the standard error.
When method=“fwb”
, drawn weights are supplied to the model fitting function’s weights
argument; if the model doesn’t accept non-integer weights, this method should not be used. If weights were included in the original model fit, they are extracted by weights()
and multiplied by the drawn weights. These weights are supplied to the wts
argument of the estimation function (e.g., comparisons()
).
Value
A marginaleffects
object with simulation or bootstrap resamples and objects attached.
References
Krinsky, I., and A. L. Robb. 1986. “On Approximating the Statistical Properties of Elasticities.” Review of Economics and Statistics 68 (4): 715–9.
King, Gary, Michael Tomz, and Jason Wittenberg. "Making the most of statistical analyses: Improving interpretation and presentation." American journal of political science (2000): 347-361
Dowd, Bryan E., William H. Greene, and Edward C. Norton. "Computation of standard errors." Health services research 49.2 (2014): 731-750.
Examples
Species Estimate Std. Error 2.5 % 97.5 %
setosa 5.01 0.0344 4.93 5.07
versicolor 5.94 0.0619 5.82 6.07
virginica 6.59 0.0788 6.44 6.75
Columns: Species, estimate, std.error, conf.low, conf.high
Species Estimate 2.5 % 97.5 %
setosa 5.01 4.94 5.07
versicolor 5.94 5.82 6.06
virginica 6.59 6.44 6.75
Columns: Species, estimate, conf.low, conf.high
term contrast Species estimate predicted
1 Sepal.Width mean(dY/dX) setosa 0.6904897 5.055715
2 Sepal.Width mean(dY/dX) versicolor 0.8650777 6.307983
3 Sepal.Width mean(dY/dX) virginica 0.9015345 6.881900
4 Species mean(versicolor) - mean(setosa) setosa 1.4992211 5.055715
5 Species mean(versicolor) - mean(setosa) versicolor 1.3843422 6.307983
6 Species mean(versicolor) - mean(setosa) virginica 1.4199582 6.881900
7 Species mean(virginica) - mean(setosa) setosa 1.9912967 5.055715
8 Species mean(virginica) - mean(setosa) versicolor 1.8524292 6.307983
9 Species mean(virginica) - mean(setosa) virginica 1.8954823 6.881900
predicted_hi predicted_lo std.error conf.low conf.high rvar
1 5.055881 5.055715 0.08102709 0.5487008 0.8583514 0.69 ± 0.081
2 6.308191 6.307983 0.20712193 0.4808519 1.2809997 0.88 ± 0.207
3 6.882117 6.881900 0.23704875 0.3867165 1.3338278 0.89 ± 0.237
4 6.567507 5.055715 0.15422309 1.2037516 1.7935150 1.50 ± 0.154
5 6.307983 4.848568 0.08693716 1.2216215 1.5524924 1.38 ± 0.087
6 6.394491 4.917617 0.08908202 1.2437332 1.5875035 1.42 ± 0.089
7 7.062207 5.055715 0.12038738 1.7300974 2.2013722 1.99 ± 0.120
8 6.791747 4.848568 0.12456281 1.6287253 2.1275295 1.86 ± 0.125
9 6.881900 4.917617 0.09656870 1.7196001 2.0992510 1.90 ± 0.097
Term Contrast Estimate Std. Error 2.5 % 97.5 %
Sepal.Width dY/dX 0.696 0.167 0.366 1.01
Sepal.Width dY/dX 0.696 0.167 0.366 1.01
Sepal.Width dY/dX 0.696 0.167 0.366 1.01
Sepal.Width dY/dX 0.696 0.167 0.366 1.01
Sepal.Width dY/dX 0.696 0.167 0.366 1.01
Sepal.Width dY/dX 0.696 0.167 0.366 1.01
Columns: rowid, term, contrast, estimate, std.error, conf.low, conf.high, predicted, predicted_hi, predicted_lo, tmp_idx, Sepal.Length, Sepal.Width, Species