| miSem {sem} | R Documentation |
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.
miSem(model, ...)
## S3 method for class 'semmod'
miSem(model, ..., data, formula = ~., raw = FALSE,
fixed.x=NULL, objective=objectiveML, n.imp=5, n.iter=30,
seed=sample(1e+06, 1), mi.args=list())
## S3 method for class 'semmodList'
miSem(model, ..., data, formula = ~., group, raw=FALSE,
fixed.x=NULL, objective=msemObjectiveML,
n.imp=5, n.iter=30, seed=sample(1e6, 1), mi.args=list())
## S3 method for class 'miSem'
print(x, ...)
## S3 method for class 'miSem'
summary(object, digits=max(3, getOption("digits") - 2), ...)
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.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 |
x, object |
an object of class |
digits |
for printing numbers. |
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. |
John Fox jfox@mcmaster.ca
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).
## Not run:
mod.cfa.tests <- cfa(raw=TRUE)
verbal: x1, x2, x3
math: y1, y2, y3
imps <- miSem(mod.cfa.tests, data=Tests, fixed.x="Intercept", raw=TRUE, seed=12345,
mi.args=list(add.noise=noise.control(post.run.iter=30)))
summary(imps, digits=3)
library(MBESS) # for data
data(HS.data)
# introduce some missing data:
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()
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"))
imps.mg <- miSem(mod.mg, data=HS, group="Gender",
seed=12345, n.iter=50,
mi.args=list(add.noise=noise.control(post.run.iter=30)))
summary(imps.mg, digits=3)
## End(Not run)