Hi everyone,
As part of a current project I'm trying to use SEM to determine the effect of a latent variable.
All variables are continuous except for the 'outcome' variable.
When trying to run my model, assuming that everything (including outcome) is continuous, there are no problem.
However, I run into problems trying to account for the outcome variable type.
Here is the error message I get:
Error in X[[g]][, num.idx, drop = FALSE] : subscript out of bounds
In addition: Warning message:
In ov.names[[g]] %in% ov$name & ov$type == "numeric" :
longer object length is not a multiple of shorter object lengthI've already searched the forum here and found similar error messages, however seems like only the warning is known and not the error.
So I sat down and tried to recreate the issue in a small test scenario (see below).
Any insights on what's going on?
And as a more general question: Would there be a general trend if I'd assume the outcome to be continuous, i.e. will the model underestimate or overestimate the "goodness" of the model? Or is it so unpredictable that this cannot be stated?
Best wishes,
M
########################
library(lavaan)
# dataset
aa <- c(0,1,1,2,2,2,3,3,4)
bb <- c(0,1,6,2,3,1,4,2,5) # outcome variable
cc <- aa
dd <- aa
dat <- data.frame(aa=aa, bb=bb, cc=cc, dd=dd)
# 1
model.a <- '
lat =~ start(1.)*aa + cc
# regression model
bb ~ aa + dd
'
# 2
fit <- sem(model.a, data = dat,
std.lv = TRUE, std.ov = TRUE, ordered=c('bb'))