Learn R Programming

simsem (version 0.2-8)

runMI: Multiply impute and analyze data using lavaan

Description

This function takes data with missing observations, multiple imputes the data, runs a SEM using lavaan and combines the results using Rubin's rules.

Usage

runMI(data.mat, data.model, m, miPackage="amelia", silent = FALSE, opts)

Arguments

data.mat
Data frame with missing observations.
data.model
Specification of the model to be analyzed. data.model can be either a simModel object or lavaan syntax
m
Number of imputations wanted
miPackage
Package to be used for impuation. Currently runMI only uses amelia for imputation
silent
TRUE if users do not wish to print number of imputations while running the function.
opts
A list of additional arguments to be passed to amelia for imputation.

Value

  • runMI returns a list with pooled estimates, standard errors, fit indices and fraction missing information
  • coefPooled parameter estimates. The order of parameter estimates corresponds to the order reported by Lavaan
  • sePooled standard errors. The order of standard errors corresponds to the order reported by Lavaan
  • fitPooled fit indices. The order of fit indices corresponds to the order reported by Lavaan
  • FMI.1Fraction of missing information for each parameter. The order of fraction missing corresponds to the order of parameters reported by Lavaan
  • FMI.2Fraction of missing information for each parameter. The order of fraction missing corresponds to the order of parameters reported by Lavaan

References

Rubin, D.B. (1987) Multiple Imputation for Nonresponse in Surveys. J. Wiley & Sons, New York.

See Also

  • miPoolfor pooling results from multiple imputation.

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(data.mat,data.model,imps) {
  #Impute missing data
  imputed.l<-imputeMissing(data.mat,imps)
  
  #Run models on each imputed data set
  #Does this give results from each dataset in the list?
  
  imputed.results<-result.object(imputed.l[[1]],sim.data.model,10)

  imputed.results <- lapply(imputed.l,result.object,data.model,1)
  comb.results<-MIpool(imputed.results,imps)
  
  return(comb.results)

  }

Run the code above in your browser using DataLab