mi.eval {bucky} | R Documentation |
Multiple-imputation evaluation
Description
Evaluation of an expression across multiply imputed data sets.
Usage
mi.eval(EXPR, robust, cluster, coef., vcov., df.=NULL,
parallel=FALSE, lazy=NULL, ...)
Arguments
EXPR |
An R expression to evaluate. This expression must contain a |
robust |
Whether to use Huber-White robust standard errors. The default is
|
cluster |
A vector specifying clusters for the purpose of computing clustered
robust standard errors. This can be a variable inside the
imputed data set. If unspecified, standard errors are not clustered. If
specified, |
coef. |
The function used to get a numeric vector of coefficient estimates when
evaluated on an object returned from evaluating |
vcov. |
The function that returns a numeric matrix giving the variance-covariance
matrix when evaluated on an object returned from evaluating |
df. |
Either the degrees of freedom for each model or a function that
calculates degrees of freedom on an object returned from evaluating
|
parallel |
A logical indicating whether to evaluate |
lazy |
A logical indicating whether to use lazy evaluation to avoid copying all
imputed data sets into memory. When the |
... |
Any additional arguments to be passed to |
Details
This function evaluates a R command for each of several multiply imputed
data sets and combines results across data sets into a single set of
estimates. This is similar to the functionality provided by
with.mids
but also works with multiply-imputed data
sets generated by other packages like 'Amelia' as well as those from
'mice'.
For generating formatted tables of
regression coefficients, the outputted objects should be
compatible with the 'texreg' package. When used with lm
,
glm
or a few other types of models, these objects are also
compatible with the 'stargazer' package.
Value
An object of class mi.estimates
containing the coefficient
estimates, variance-covariance matrix, and related information.
See Also
See Also summary.mi.estimates
,
with.mids
,
amelia
,
mice
,
coef
,
vcov
and
df.residual
.
Examples
if (require("Amelia")) {
## Load data
data(africa)
africa$civlib <- factor(round(africa$civlib*6), ordered=TRUE)
## Estimate a linear model using imputed data sets
model0 <- lm(trade ~ log(gdp_pc), data=africa, subset=year==1973)
summary(model0)
## Impute using Amelia
a.out <- amelia(x = africa, cs = "country", ts = "year",
logs = "gdp_pc", ord="civlib")
## Estimate a linear model using imputed data sets
model1 <- mi.eval(lm(trade ~ log(gdp_pc), data=a.out, subset=year==1973))
## Show estimates
model1
coef(model1)
## Show summary information
summary(model1)
if (require("MASS")) {
## Estimate an ordered logit model
model2 <- mi.eval(polr(civlib ~ log(gdp_pc) + log(population),
data=a.out))
summary(model2)
## Also show thresholds by including thresholds with coefficients
model3 <- mi.eval(polr(civlib ~ log(gdp_pc) + log(population),
data=a.out),
coef=function(x) c(x$coefficients, x$zeta))
summary(model2)
}
}