lavaan.miThis is an R package whose primary purpose is to extend thefunctionality of the R packagelavaan. When incomplete datahave been multiply imputed, thelavaan.mi package allowsusers to fit structural equation models as they would using thelavaan package.
The development version can be installed from GitHub using theremotespackage:
remotes::install_github("TDJorgensen/lavaan.mi")lavaan.mi tolavaanThe top 4 lines of the table below indicate thelavaan.mi::lavaan.mi() function corresponds to thelavaan::lavaan() function, as do the wrapperscfa.mi(),sem.mi(), andgrowth.mi(), all of which return an object of classlavaan.mi.
lavaan Function | lavaan.mi Function |
|---|---|
lavaan() | lavaan.mi() |
cfa() | cfa.mi() |
sem() | sem.mi() |
growth() | growth.mi() |
parameterEstimates() | parameterEstimates.mi() |
standardizedSolution() | |
lavTestLRT() | lavTestLRT.mi() |
lavTestWald() | lavTestWald.mi() |
lavTestScore() | lavTestScore.mi() |
modIndices() | modIndices.mi() |
lavResiduals() | lavResiduals.mi() |
Thedata= argument must be alist ofdata.frames rather than a singledata.frame,and the specifiedlavaan::model.syntax will be applied toeachdata.frame in thelist.
lavaanListThelavaan.mi class inherits from classlavaanList (from thelavaan package),extending it with a few additional and customized slots (seeclass?lavaanList andclass?lavaan.mi fordetails).
It isnot wise to use “lazy loading” (i.e., callinglavaan.mi::lavaan.mi() without loadinglibrary(lavaan.mi) explicitly) because R may have troublefinding the correct methods in the package for applying genericfunctions (e.g.,summary) tolavaan.mi-classobjects. This occasionally happened in thesemTools packageas well. When the correct methods are not found, then the genericfunction will revert to the methods written forlavaanList-class objects (e.g.,summary() willonly have anest.ave column for the average estimate acrossdata sets). In most cases (e.g.,fitted(),anova(),residuals(), etc.), this will causean error because few methods have been written forlavaanList-class objects.
Additionallavaan output can be obtained per imputationusing theFUN= argument, which is applied to alavaan-class object formed from the result of eachimputation (prior to its being stored more succinctly in alavaanList-class object). The last?lavaan.mihelp-page example demonstrates how to obtain and extract additionaloutput.
lavaan andlavaan.mi objectsMany remaining methods written forlavaan-class objectsare also available forlavaan.mi-class objects (also seeclass?lavaan.mi for a list and descriptions ofarguments):
show()summary()fitMeasures()anova(), which simply callslavTestLRT.mi()nobs()coef()vcov()fitted.values() and aliasfitted()residuals() and aliasresid(), which calllavResiduals.mi()lavaan.mi tosemToolsMany of the functions in thesemTools package continueto be available forlavaan.mi-class objects (e.g.,semTools::compRelSEM() for model-based reliability), andfunctions such assemTools::parcelAllocation() andsemTools::plausibleValues() are enhanced by allowing theiroutput to be analyzed usinglavaan.mi().