I am attempting a stats assignment that has got me stumped. The original question was to fit a SEM model in lavaan (I am using R) using FIML, where two latent variables (extraversion and neuroticism) predict the latent variable of job satisfaction. I did the following syntax no problem:
model_demo <- '
# measurement model
extraversion =~ x1 + x2 + x3 + x4
neuroticism =~ x5 + x6 + x7 + x8
jobsatisfaction =~ y1 + y2 + y3 + y4
# structural model
jobsatisfaction ~ extraversion
jobsatisfaction ~ neuroticism
# residual correlations
x2 ~~ x6
x4 ~~ x8
'
fit_demo <- sem(model_demo, missing = 'FIML', data=mt)
summary(fit_demo, fit.measures=TRUE, standardized=TRUE)
However, the follow up is asking the question of which individual attribute matters more for employee job satisfaction: being extraverted or not neurotic. Where their hypothesis is that extraversion and neuroticism are equally important, just that extraversion is positive and neuroticism is negative. And then asked us to specify the this constraint using a simple equation about the regression coefficients of job satisfaction on extraversion and neuroticism.
I have tried to apply equality constraints done in class:
model_demo4 <- '
# measurement model
extraversion =~ x1 + b1*x2 + b2*x3 + b3*x4
neuroticism =~ x5 + b4*x6 + b5*x7 + b6*x8
jobsatisfaction =~ y1 + y2 + y3 + y4
# structural model
jobsatisfaction ~ extraversion
jobsatisfaction ~ neuroticism
# residual correlations
x2 ~~ x6
x4 ~~ x8
fit_demo4 <- sem(model_demo4, missing = 'FIML',data=mt) summary(fit_demo4, fit.measures=TRUE, standardized=TRUE)
Finally, how would you then run a wald test to get the chi squared for a model comparison between the original model and the constrained model?
I tried:
lavTestWald(fit_demo, fit_demo4)
and got an error message Error in nchar(constraints) : no method for coercing this S4 class to a vector
Any and all advice is welcomed in helping me understand constraints in this model but most importantly how to run a wald test to compare models. Thank you in advance!