Error notification in SEM Regression with manifest variables

413 views
Skip to first unread message

Simon Bley

unread,
Aug 2, 2023, 11:10:41 AM8/2/23
to lavaan
Hi there,

I would really appreciate your help! I keep on getting the same error notification in my R output. I am trying to do a regression in a SEM with manifest variables. When I use the summary command I get this error: 

Error in data.frame(lhs = NAMES, op = rep("r2", nel), rhs = NAMES, block = block, :
Row names contain missing values

I have created a simplified dataframe (which gets me the same error), so that I can share it with you. 

This is my R-Code:

q <- data.frame(
  a = c(1, 2, 3, 4, 3, 5, 9),
  b = c(4, 4, 5, 6, 1, 1, 1),
  c = c(3, 4, 2, 4, 1, 2, 1)
)
r <- data.frame(
  d = c(4, 6, 1, 6, 8, 8, 8),
  e = c(3, 7, 8, 8, 9, 4, 9),
  f = c(9, 6, 2, 7, 7, 8, 9)
)

q$Ma <- apply(q, 1, mean, na.rm=T)
r$Mb <- apply(r, 1, mean, na.rm=T)

s <- cbind(q,r)

mod <- 'Ma ~ Mb
            Mb ~~ Mb
            Ma ~~ Ma
            Mb ~ 1
            Ma ~ 1'

fit <- lavaan(model=mod, data=s, meanstructure=TRUE, missing="fiml", fixed.x=FALSE)

summary(fit, fit.measures=TRUE, standardized=TRUE, rsquare=TRUE)

Without the 'rsquare=TRUE' it runs through, but I need the R². 
I am using the newest version of both R and lavaan. I sent the R-Code to a friend and she didnt get any error messages.
So, I would be grateful for any ideas / suggestions what could cause the error. 

Cheers, Simon

Christian Arnold

unread,
Aug 2, 2023, 11:21:30 AM8/2/23
to lav...@googlegroups.com

There is a good chance that this will solve your problem.

HTH

Christian 


Von: lav...@googlegroups.com <lav...@googlegroups.com> im Auftrag von Simon Bley <simon...@gmail.com>
Gesendet: Mittwoch, August 2, 2023 5:10:48 PM
An: lavaan <lav...@googlegroups.com>
Betreff: Error notification in SEM Regression with manifest variables
--
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/8e083bc7-275d-446c-8815-b82b5d0377c9n%40googlegroups.com.

Keith Markus

unread,
Aug 3, 2023, 11:20:37 AM8/3/23
to lavaan
Simon,
I could just be fuzzy headed this morning, but you appear to be submitting only the means as your statistics to which to fit the model (s).  Is that intentional?  Your model involves variances and covariances.  (Also, you appear to be computing row means instead of column means. Are you aware of the built in colMeans() and rowMeans() functions?)

Keith
------------------------
Keith A. Markus
John Jay College of Criminal Justice, CUNY
http://jjcweb.jjay.cuny.edu/kmarkus
Frontiers of Test Validity Theory: Measurement, Causation and Meaning.
http://www.routledge.com/books/details/9781841692203/

Reply all
Reply to author
Forward
0 new messages