miSem {sem} | R Documentation |
Estimate a Structural Equation Model By Multiple Imputation
Description
miSem
uses the mi
function in the mi package to generate multiple imputations of missing
data, fitting the specified model to each completed data set.
Usage
miSem(model, ...)
## S3 method for class 'semmod'
miSem(model, ..., data, formula = ~., raw=FALSE,
fixed.x=NULL, objective=objectiveML,
n.imp=5, n.chains=n.imp, n.iter=30, seed=sample(1e6, 1), mi.args=list(),
show.progress=TRUE)
## S3 method for class 'semmodList'
miSem(model, ..., data, formula = ~., group, raw=FALSE,
fixed.x=NULL, objective=msemObjectiveML,
n.imp=5, n.chains=n.imp, n.iter=30, seed=sample(1e6, 1), mi.args=list(),
show.progress=TRUE)
## S3 method for class 'miSem'
print(x, ...)
## S3 method for class 'miSem'
summary(object, digits=max(3, getOption("digits") - 2), ...)
Arguments
model |
an SEM model-description object of class |
... , formula , raw , fixed.x , objective , group |
arguments to be passed to |
data |
an R data frame, presumably with some missing data (encoded as |
n.imp |
number of imputations (default |
n.chains |
number of Markov chains (default is the number of imputations). |
n.iter |
number of iterations for the multiple-imputation process (default |
seed |
seed for the random-number generator (default is an integer sampled from 1 to 1E6); stored in the resulting object. |
mi.args |
other arguments to be passed to |
show.progress |
show a text progress bar on the console tracking model fitting to the multiple imputations; this is distinct from
the progress of the multiple-imputation process, which is controlled by the |
x , object |
an object of class |
digits |
for printing numbers. |
Value
miSem
returns an object of class "miSem"
with the following components:
initial.fit |
an |
mi.fits |
a list of |
imputation |
the object produced by |
seed |
the seed used for the random number generator. |
mi.data |
the object returned by |
Author(s)
John Fox jfox@mcmaster.ca
References
Yu-Sung Su, Andrew Gelman, Jennifer Hill, Masanao Yajima. (2011). “Multiple imputation with diagnostics (mi) in R: Opening windows into the black box.” Journal of Statistical Software 45(2).
See Also
Examples
## Not run: # because of long execution time
mod.cfa.tests <- cfa(raw=TRUE, text="
verbal: x1, x2, x3
math: y1, y2, y3
")
imps <- miSem(mod.cfa.tests, data=Tests, fixed.x="Intercept",
raw=TRUE, seed=12345)
summary(imps, digits=3)
# introduce some missing data to the HS.data data set:
HS <- HS.data[, c(2,7:10,11:15,20:25,26:30)]
set.seed(12345)
r <- sample(301, 100, replace=TRUE)
c <- sample(2:21, 100, replace=TRUE)
for (i in 1:100) HS[r[i], c[i]] <- NA
mod.hs <- cfa(text="
spatial: visual, cubes, paper, flags
verbal: general, paragrap, sentence, wordc, wordm
memory: wordr, numberr, figurer, object, numberf, figurew
math: deduct, numeric, problemr, series, arithmet
")
mod.mg <- multigroupModel(mod.hs, groups=c("Female", "Male"))
system.time( # relatively time-consuming!
imps.mg <- miSem(mod.mg, data=HS, group="Gender", seed=12345)
)
summary(imps.mg, digits=3)
## End(Not run)