Error message when trying to use ordered variable in sem

915 views
Skip to first unread message

Johann Hutz

unread,
Jul 8, 2022, 7:43:13 AM7/8/22
to lav...@googlegroups.com
So I've been trying to fit a sem with ordered variables. I get the following error message:

Error in lav_samplestats_step1(Y = Data, wt = wt, ov.names = ov.names,  :
  lavaan ERROR: unknown ov.types:haven_labelled

I tried to look the error message up, but couldn't really find an answer. Anyone got an idea what might be going on here? My research on the subject suggests it might have something to do with the data being imported from a stata file. I don't know if that's true though or how I might solve this problem.

Edward Rigdon

unread,
Jul 8, 2022, 11:17:47 AM7/8/22
to lav...@googlegroups.com
Please share your syntax, and some specifics about the data that you are trying to analyze.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/CA%2B5b-VAA86S1mU-Yoo96%2B-jhaaK1wpty8mWwnKL27zBtwAVYXQ%40mail.gmail.com.

Brett

unread,
Jul 8, 2022, 11:23:47 AM7/8/22
to lav...@googlegroups.com
You are using variables that are not one of the base R types that lavaan expects (numeric, integer, etc.). Convert them from haven_labelled type to the appropriate base type, e.g. as.numeric(x).

--

Shu Fai Cheung

unread,
Jul 8, 2022, 11:33:40 AM7/8/22
to lavaan
I don't use stata so I am not 100% sure, but you may see if zap_labels() and zap_label() can solve the problem. I used them for SPSS data files imported by haven::read_sav():


Check the examples to see what these two functions do.

Hope this helps.

-- Shu Fai

Jungyeong Heo

unread,
Jul 9, 2022, 4:41:02 PM7/9/22
to lav...@googlegroups.com
I think that  I had a similar problem when I read my .sav file by using haven package. As soon as I used  a different package for reading the same file (in my case, foreign package), the error messages disappeared.

--
Reply all
Reply to author
Forward
0 new messages