1

I am using lavaan package to run confirmatory analysis and got the following error:

Error in lavaan::lavaan(model = m7f, data = dat, std.lv = TRUE, model.type = "cfa",  : 
  lavaan ERROR: missing observed variables in dataset: ..constant..

I successfully ran the first line of code and created the model m7f. The error shows after I run the cfa:

m7f<-'
      Abs =~ IdentificationScale_1 + IdentificationScale_2 + IdentificationScale_3
      Mot =~ IdentificationScale_4 + IdentificationScale_5 + IdentificationScale_6
      CoE =~ IdentificationScale_7 + IdentificationScale_8 + IdentificationScale_9
      AfE =~ IdentificationScale_10 + IdentificationScale_11 + IdentificationScale_12
      Com =~ Compassion_1 + Compassion_2 + Compassion_3 + Compassion_4 + Compassion_5 + Compassion_6
      DiD =~ "Personal Distress_1" + "Personal Distress_2" + "Personal Distress_3" + "Personal Distress_4"
      DiO =~ "Personal Distress_5" + "Personal Distress_6" + "Personal Distress_7" + "Personal Distress_8"
'

sevfac26it<- cfa(m7f, data = dat, std.lv = TRUE)

Can someone help me to understand what ..constant.. mean? Thanks a lot!

  • I am guessing `..constant..` is something generated by lavaan's parser. You can't put quotation marks around variable names to preserve the spaces (which shouldn't be there anyway). In `formula` objects, you could use backticks to read those names as-is, but lavaan puts all specifications in a character vector. You should update the names in your `data.frame` (`dat`) so that they are "legal", perhaps using the `make.names()` function. – Terrence Jun 17 '22 at 09:34

0 Answers0