misim | R Documentation |
misim()
simulates model parameters from multivariate normal or t distributions after multiple imputation that are then used by sim_apply()
to calculate quantities of interest.
misim(fitlist, n = 1000, vcov = NULL, coefs = NULL, dist = NULL)
fitlist |
a list of model fits, one for each imputed dataset, or a |
n |
the number of simulations to run for each imputed dataset; default is 1000. More is always better but resulting calculations will take longer. |
vcov |
a square covariance matrix of the coefficient covariance estimates, a function to use to extract it from |
coefs |
a vector of coefficient estimates, a function to use to extract it from |
dist |
a character vector containing the name of the multivariate distribution(s) to use to draw simulated coefficients. Should be one of |
misim()
essentially combines multiple sim()
calls applied to a list of model fits, each fit in an imputed dataset, into a single combined pool of simulated coefficients. When simulation-based inference is to be used with multiply imputed data, many imputations are required; see Zhou and Reiter (2010).
A clarify_misim
object, which inherits from clarify_sim
and has the following components:
sim.coefs |
a matrix containing the simulated coefficients with a column for each coefficient and a row for each simulation for each imputation |
coefs |
a matrix containing the original coefficients extracted from |
fit |
the list of model fits supplied to |
imp |
a identifier of which imputed dataset each set of simulated coefficients corresponds to. |
The "dist"
attribute contains "normal"
if the coefficients were sampled from a multivariate normal distribution and "t({df})"
if sampled from a multivariate t distribution. The "clarify_hash"
attribute contains a unique hash generated by rlang::hash()
.
Zhou, X., & Reiter, J. P. (2010). A Note on Bayesian Inference After Multiple Imputation. The American Statistician, 64(2), 159–163. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1198/tast.2010.09109")}
sim()
for simulating model coefficients for a single dataset
sim_apply()
for applying a function to each set of simulated coefficients
sim_ame()
for computing average marginal effects in each simulation draw
sim_setx()
for computing marginal predictions and first differences at typical values in each simulation draw
data("africa", package = "Amelia")
# Multiple imputation using Amelia
a.out <- Amelia::amelia(x = africa, m = 10,
cs = "country",
ts = "year", logs = "gdp_pc",
p2s = 0)
fits <- with(a.out, lm(gdp_pc ~ infl * trade))
# Simulate coefficients
s <- misim(fits)
s
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.