Learn R Programming

sem (version 3.1-4)

miSem: 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.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), ...)

Arguments

model
an SEM model-description object of class semmod or semmodList, created by specifyEquations cfa, or
..., formula, raw, fixed.x, objective, group
arguments to be passed to sem.
data
an R data frame, presumably with some missing data (encoded as NA), containing the data for fitting the SEM, possibly along with other variables to use to obtain multiple imputations of missing values. In the case of a multi-group m
n.imp
number of imputations (default 5).
n.iter
number of iterations for the multiple-imputation process (default 30).
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 mi.
x, object
an object of class "miSem".
digits
for printing numbers.

Value

  • miSem returns an object of class "miSem" with the following components:
  • initial.fitan sem model object produced using objectiveFIML if raw=TRUE, or the objective function given by the objective argument otherwise.
  • mi.fitsa list of sem model objects, one for each imputed data set.
  • imputationthe object produced by mi, containing the imputed data sets.
  • seedthe seed used for the random number generator.

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

sem, mi

Examples

Run this code
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)

Run the code above in your browser using DataLab