Dear All,
I would like to ask a quick question on runMI() and lavaan.mi class objects.
parameterEstimates() can be used to get the parameter estimates of the output of lavaan() and its wrappers in the form of a lavaan.data.frame object.
I found that
parameterEstimates()
does not work on a lavaan.mi object. Only lhs, op, and rhs is returned, as shown in the example below.
However, if I call summary() but output is not set to "text", the default, then, the output is a lavaan.data.frame, as shown below. I also compared the results with those from summary() with output = "text" and confirmed that results are the same.
Is this an intended behavior of the summary-method of lavaan.mi? Can I trust this way to use summary() as
the lavaan.mi version of parameterEstimates()?
Regards,
Shu Fai Cheung (張樹輝)
The long example appended below:
# Adapted from the example of runMI()
library(semTools)
#> Loading required package: lavaan
#> This is lavaan 0.6-15
#> lavaan is FREE software! Please report any bugs.
#>
#> ###############################################################################
#> This is semTools 0.5-6
#> All users of R (or SEM) are invited to submit functions or ideas for functions.
#> ###############################################################################
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
set.seed(12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
HS.model <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
out1 <- cfa.mi(HS.model, data = HSMiss, m = 20, seed = 12345,
miArgs = list(noms = "school"))
#> Loading required namespace: Amelia
#> ##
#> ## Amelia II: Multiple Imputation
#> ## (Version 1.8.1, built: 2022-11-18)
#> ## Copyright (C) 2005-2023 James Honaker, Gary King and Matthew Blackwell
#> ## Refer to http://gking.harvard.edu/amelia/ for more information
#> ##
# `parameterEstimates()` does not work
parameterEstimates(out1)
#> lhs op rhs
#> 1 visual =~ x1
#> 2 visual =~ x2
#> 3 visual =~ x3
#> 4 textual =~ x4
#> 5 textual =~ x5
#> 6 textual =~ x6
#> 7 speed =~ x7
#> 8 speed =~ x8
#> 9 speed =~ x9
#> 10 x1 ~~ x1
#> 11 x2 ~~ x2
#> 12 x3 ~~ x3
#> 13 x4 ~~ x4
#> 14 x5 ~~ x5
#> 15 x6 ~~ x6
#> 16 x7 ~~ x7
#> 17 x8 ~~ x8
#> 18 x9 ~~ x9
#> 19 visual ~~ visual
#> 20 textual ~~ textual
#> 21 speed ~~ speed
#> 22 visual ~~ textual
#> 23 visual ~~ speed
#> 24 textual ~~ speed
# Set output = "" to get a lavaan.data.frame
summary(out1, output = "")
#> lhs op rhs est se t df pvalue
#> 1 visual =~ x1 1.000 0.000 NA NA NA
#> 2 visual =~ x2 0.556 0.108 5.153 Inf 0.000
#> 3 visual =~ x3 0.728 0.118 6.180 Inf 0.000
#> 4 textual =~ x4 1.000 0.000 NA NA NA
#> 5 textual =~ x5 0.661 0.052 12.792 116.901 0.000
#> 6 textual =~ x6 0.993 0.072 13.760 463.762 0.000
#> 7 speed =~ x7 1.000 0.000 NA NA NA
#> 8 speed =~ x8 1.176 0.185 6.348 1374.016 0.000
#> 9 speed =~ x9 0.901 0.142 6.366 321.076 0.000
#> 10 x1 ~~ x1 0.549 0.123 4.475 Inf 0.000
#> 11 x2 ~~ x2 1.132 0.110 10.297 Inf 0.000
#> 12 x3 ~~ x3 0.846 0.098 8.634 Inf 0.000
#> 13 x4 ~~ x4 0.450 0.061 7.374 491.475 0.000
#> 14 x5 ~~ x5 0.272 0.032 8.588 150.445 0.000
#> 15 x6 ~~ x6 0.309 0.053 5.844 201.536 0.000
#> 16 x7 ~~ x7 0.768 0.090 8.525 5997.168 0.000
#> 17 x8 ~~ x8 0.449 0.088 5.104 675.850 0.000
#> 18 x9 ~~ x9 0.634 0.074 8.569 264.311 0.000
#> 19 visual ~~ visual 0.809 0.157 5.147 Inf 0.000
#> 20 textual ~~ textual 0.901 0.121 7.422 5617.667 0.000
#> 21 speed ~~ speed 0.415 0.099 4.189 8611.644 0.000
#> 22 visual ~~ textual 0.428 0.079 5.406 6361.340 0.000
#> 23 visual ~~ speed 0.242 0.061 3.951 Inf 0.000
#> 24 textual ~~ speed 0.177 0.054 3.264 3695.871 0.001
# Compare the estimates with default options
summary(out1)
#> lavaan.mi object based on 20 imputed data sets.
#> See class?lavaan.mi help page for available methods.
#>
#> Convergence information:
#> The model converged on 20 imputed data sets
#>
#> Rubin's (1987) rules were used to pool point and SE estimates across 20 imputed data sets, and to calculate degrees of freedom for each parameter's t test and CI.
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Expected
#> Information saturated (h1) model Structured
#>
#> Latent Variables:
#> Estimate Std.Err t-value df P(>|t|)
#> visual =~
#> x1 1.000
#> x2 0.556 0.108 5.153 Inf 0.000
#> x3 0.728 0.118 6.180 Inf 0.000
#> textual =~
#> x4 1.000
#> x5 0.661 0.052 12.792 116.901 0.000
#> x6 0.993 0.072 13.760 463.762 0.000
#> speed =~
#> x7 1.000
#> x8 1.176 0.185 6.348 1374.016 0.000
#> x9 0.901 0.142 6.366 321.076 0.000
#>
#> Covariances:
#> Estimate Std.Err t-value df P(>|t|)
#> visual ~~
#> textual 0.428 0.079 5.406 6361.340 0.000
#> speed 0.242 0.061 3.951 Inf 0.000
#> textual ~~
#> speed 0.177 0.054 3.264 3695.871 0.001
#>
#> Variances:
#> Estimate Std.Err t-value df P(>|t|)
#> .x1 0.549 0.123 4.475 Inf 0.000
#> .x2 1.132 0.110 10.297 Inf 0.000
#> .x3 0.846 0.098 8.634 Inf 0.000
#> .x4 0.450 0.061 7.374 491.475 0.000
#> .x5 0.272 0.032 8.588 150.445 0.000
#> .x6 0.309 0.053 5.844 201.536 0.000
#> .x7 0.768 0.090 8.525 5997.168 0.000
#> .x8 0.449 0.088 5.104 675.850 0.000
#> .x9 0.634 0.074 8.569 264.311 0.000
#> visual 0.809 0.157 5.147 Inf 0.000
#> textual 0.901 0.121 7.422 5617.667 0.000
#> speed 0.415 0.099 4.189 8611.644 0.000