yrosseel / lavaan

an R package for structural equation modeling and more
http://lavaan.org
412 stars 99 forks source link

add vcov(standardized=, free.only=) arguments #361

Closed TDJorgensen closed 2 weeks ago

TDJorgensen commented 2 weeks ago

I’m working on some lavaan.mi functionality in semTools::monteCarloCI(), which requires the full vcov() for a standardized solution. When I last visited, I worked out a hack for standardizedSolution.mi() by creating a fake lavaan object with pooled results inside it. That object can also be passed to the workhorse:

lav_object_inspect_vcov(fit, standardized = TRUE, free.only = FALSE)

But that is not a public function. I explored 2 possibilities to call it indirectly via public functions, both of which have a limitation I need to circumvent:

This PR adds these 2 arguments to your vcov() method to pass them to lav_object_inspect_vcov(). I left these new arguments undocumented (like the existing ones) to avoid advertising them.

TDJorgensen commented 2 weeks ago

reprex to test it:

fit <- cfa("visual  =~ x1 + a*x2 + b*x3",
           constraints = 'ab := a*b',
           data = HolzingerSwineford1939)
vcov(fit) # default is unchanged, 6 x 6
vcov(fit, standardized = "std.all") # 6 by 6
vcov(fit, standardized = "std.all", type = "user") # 7 by 7
vcov(fit, standardized = "std.all", free.only = FALSE) # 8 by 8