Dear colleagues,
I am completely new to lavaan and would appreciate any help.
When I copy an example of composite from Dr. Jim Grace, and use function of summary(mod.1.fit, rsq= T, standardized=T) and R give "Error in data.frame(lhs = NAMES, op = rep("r2", nel), rhs = NAMES, block = block, :Missing value in row name“. I don't know why the same syntax have different answers.
Thanks for any suggestions!
library(MASS)
mu = c(10, 20)
Sigma <- matrix(c(10, 3, 3, 2), 2, 2)
set.seed(1, kind = NULL, normal.kind = NULL)
xs <- mvrnorm(n = 50, mu, Sigma)
cause1 = xs[,1]
cause2 = xs[,2]
set.seed(3, kind = NULL, normal.kind = NULL)
yerror = rnorm(50, mean=0, sd=2)
response <- 0.812*cause1 + 0.673*cause2 + yerror
sim.dat <- data.frame(cause1, cause2, response)
cor(sim.dat)
### lavaan model
library(lavaan)
## model without composite (typically as a first step)
mod.1 <- 'response ~ cause1 + cause2'
mod.1.fit <- sem(mod.1, data=sim.dat)
summary(mod.1.fit, rsq= T, standardized=T)
Error in data.frame(lhs = NAMES, op = rep("r2", nel), rhs = NAMES, block = block, :Missing value in row name