Hello,I'm a first-year PhD student stumbling around with data analysis. Could someone please help with my lavaan R code?
Here's my simplified model:
my.model <- '
#random effect?
#covariates
group ~ age + sex
cg ~ age + sex + cell + slide
ctq ~ age + sex
# direct effect
group ~ c*ctq
# mediator
cg ~ a*ctq
group ~ b*cg
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit <- cfa(my.model, data=tbTest, ordered = c("group","slide"))
slide is a categorical random variable I use as a covariate. It's NOT an ordinal variable. But if I don't make it ordered, I got an error "lavaan ERROR: unordered factor(s) with more than 2 levels detected as exogenous covariate(s): slide".
If I make it ordered I receive a warning: "lavaan WARNING: exogenous variable(s) declared as ordered in data: slide"
I have three questions:
1. how to indicate slide as a random variable? (I read the tutorial but didn't understand)
2. will it affect the result to define the variable as ordered but it's actually not?
3. Did I define my covariates with the right lavaan grammar?
Thanks in advance!