new lavaan.mi package on CRAN

233 views
Skip to first unread message

Terrence Jorgensen

unread,
Mar 13, 2025, 6:09:14 AM3/13/25
to lavaan
A new R package is available on CRAN, which contains some familiar but greatly improved functionality that is now deprecated from semTools 0.5-7.  Among the improvements is a stronger consistency in the user interface between lavaan and lavaan.mi, including new *.mi() functions listed in the README description.  The NEWS file includes a list of changes that make this package differ from the semTools functionality.  I also attached my presentation slides from the recent PsychoCo workshop, which provide a good overview of the package's functionality.

The semTools package still supports lavaan.mi-class objects, but until the deprecated semTools functions are completely removed from a future version of semTools, you should always load the packages in the following order:

library(semTools)
library(lavaan.mi)

Note that either line automatically first loads lavaan because it is a dependency for both packages.  So a separate library(lavaan) call is not necessary.

Best,

Terrence D. Jorgensen  (he, him, his)
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Jorgensen.PsychoCo2025.lavaan.mi.pdf

Christian Arnold

unread,
Apr 25, 2025, 11:26:27 AM4/25/25
to lavaan
Hi Terrence,

thanks for this fantastic package! I noticed that the following syntax for an MGSEM can cause problems:

f ~ c(M.G1, M.G2) * 1
M.G1 == 0

One can easily work around this by using a little trick (which isn't very pretty though):

group: 1

group: 2

f ~ M.G2 * 1

It seems like the first approach sometimes (apparently not always) outputs NA for the M.G1 se and thus excludes the imputation from imps2use, even if the model fits perfectly fine. I can send you a rereducible example if needed.

Since the vcov is available, should it actually be possible to determine the CIs (se's and the p-values) using Monte Carlo simulation? At least with many imputations, this should have a speed advantage compared to parameterEstimates.mi and the differences between the CIs should actually be negligible? monteCarloCI (semTools) does not currently accept a lavaan.mi object, or am I mistaken here?

Best

Christian

Terrence Jorgensen

unread,
Jun 12, 2025, 7:12:32 AM6/12/25
to lavaan
It seems like the first approach sometimes (apparently not always) outputs NA for the M.G1 se

That often happens in lavaan with complete data, too.  A better syntax would specify labels and fixed/free parameters (when that is what you want):

f ~ c(M.G1, M.G2)*1 + c(0, NA)*1 

Since the vcov is available, should it actually be possible to determine the CIs (se's and the p-values) using Monte Carlo simulation?

Yes.
 
At least with many imputations, this should have a speed advantage compared to parameterEstimates.mi

I doubt it.  The normal-theory CIs are already calculated from vcov() and don't require simulating estimates.
 
monteCarloCI (semTools) does not currently accept a lavaan.mi object, or am I mistaken here?

 It does:

library(semTools)
library(lavaan.mi)

data(HS20imps) # import a list of 20 imputed data sets

## specify CFA model from lavaan's ?cfa help page
HS.model <- '
  visual  =~ x1 + b1*x2 + x3
  textual =~ x4 + b2*x5 + x6
  speed   =~ x7 + b3*x8 + x9
b_sum := b1 + b2 + b3 '

fit <- cfa.mi(HS.model, data = HS20imps)
monteCarloCI(fit)
Reply all
Reply to author
Forward
0 new messages