Problems with creating a table for latent factor correlation

29 views
Skip to first unread message

JL

unread,
May 17, 2019, 7:10:57 AM5/17/19
to lavaan
Hi all,

I have a problem creating a table for latent factor correlation for my SEM with multiple imputation.

I am using a SEM to test the Theory of Planned Behavior. ATT, SN, PBC and INT are likert-scale variables, BEH is ordinary/binary. I use multiple imputation for missing data.

I would like to create a table for latent factor correlations with this code: 
##Creating a table with latent factor correlation
parameterEstimates(modelfitted2, standardized=TRUE) %>% 
  filter(op == "~~", 
         lhs %in% c("ATT", "SNORM", "PBC","INT", "BEH"), 
         !is.na(pvalue)) %>% mutate(stars = ifelse(pvalue < .001, "***", 
                                                   ifelse(pvalue < .01, "**", 
                                                          ifelse(pvalue < .05, "*", "")))) %>% 
  select('Factor 1'=lhs, 
         'Factor 2'=rhs, 
         Correlation=est, 
         sig=stars) %>% kable(digits = 2, format="pandoc", caption="Table 3: Latent Factor Correlations")

It does work for the normal SEM function:
modelfitted <- sem(model, data = df, ordered = "BEH")

but does not work if I use multiple imputation:
modelfitted2 <- sem.mi(model, data = df, ordered= "BEH", m = 20, seed = 12345)

Then I get the error: 
"Error in ~!is.na(pvalue) : object 'pvalue' not found"

Does anyone have a recommendation how to solve this? Is there another way to get the correlations between the latent factors (instead of using the covariances from the summary table)?

Thanks!


Terrence Jorgensen

unread,
May 17, 2019, 10:09:02 AM5/17/19
to lavaan
but does not work if I use multiple imputation:
modelfitted2 <- sem.mi(model, data = df, ordered= "BEH", m = 20, seed = 12345)

That is because parameterEstimates() is not a generic function exported by lavaan, so I could not write a method specific for lavaan.mi objects.  For lavaan objects, the generic summary() method only prints information to the screen from various functions, without being able to save output, so I coopted it by writing a generic summary() method for lavaan.mi objects returns the equivalent of parameterEstimates() output (by default, with the argument add.attributes = TRUE, so that the printed result resembles lavaan's summary() output).

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

Reply all
Reply to author
Forward
0 new messages