Invalid argument at lavaan model

40 views
Skip to first unread message

Neyrian Fernandes

unread,
Mar 25, 2019, 2:32:08 PM3/25/19
to lavaan
I am trying to run a cfa in lavaan, but I'am receiving the follow message:

HS.model <- ' visual  =~ x1 + x2 + x3
+               textual =~ x4 + x5 + x6
+               speed   =~ x7 + x8 + x9'
> cfa(HS.model, data=HolzingerSwineford1939)
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open file ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9': Invalid argument


Could anyone help me, please?

David Adedia

unread,
Mar 26, 2019, 1:48:32 AM3/26/19
to lav...@googlegroups.com
You need to load the data in lavaan library. If possible extract the individual variables, before modelling.

DMA.

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Edward Rigdon

unread,
Mar 26, 2019, 9:27:24 AM3/26/19
to lav...@googlegroups.com
Do you have the lavaan package loaded into your workspace?

--

Christopher David Desjardins

unread,
Mar 26, 2019, 9:54:16 AM3/26/19
to lavaan

I am guessing you loaded the sem package as well. You need to unload it or whatever package is conflicting with the cfa() or type lavaan::cfa(). This code reproduces your message

library(lavaan)
library(sem) # tells us cfa() and sem() are masking the functions in lavaan

HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- cfa(HS.model, data=HolzingerSwineford1939)  

# unload the sem package
detach("package:sem", unload = TRUE) 

# works as expected
fit <- cfa(HS.model, data=HolzingerSwineford1939) 

## Alternatively leaving sem loaded
library(lavaan)
library(sem) 

HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- lavaan::cfa(HS.model, data=HolzingerSwineford1939)  # the sem cfa() function masked the lavaan cfa() function

Christopher David Desjardins

unread,
Mar 26, 2019, 9:54:54 AM3/26/19
to lavaan

And I mean you loaded the sem package AFTER the lavaan package.

Reply all
Reply to author
Forward
0 new messages