32 views

Skip to first unread message

Dec 19, 2018, 8:25:34 PM12/19/18

to lavaan

Hi all,

I tried conducting a moderated mediation analysis with lavaan. It works using "MLM", however because I have ordinal data, I tried to conduct the analysis with "WLSMV". I got the following error:

Error in vnames(FLAT, type = "ov.x", ov.x.fatal = TRUE) :

lavaan ERROR: model syntax contains variance/covariance/intercept formulas

involving (an) exogenous variable(s): [DivScr_c];

Please remove them and try again.

My code is:

model <- "

M ~ a1*X1

M ~ a2*X2

D1 =~ d11+ d12+ d13+ d14+ d15

D2 =~ d21+ d22+ d23+ d24+ d25

D3 =~ d31+ d32+ d33+ d34+ d35

D4 =~ d41+ d42+ d43+ d44+ d145

D5 =~ d51+ d52+ d53+ d54+ d55

L =~ D1+ D2+ D3+ D4+ D5

L~ b1*M

M~ a3*DivScr_c

M~ a4*X1DivScr

M~ a5*X2DivScr

M~ a6*X1X2

M~ a7*X1X2DivScr

L~ c1*X1

L~ c2*X2

DivScr_c ~ mean_of_DivScr*1

DivScr_c ~~ var_of_DivScr*DivScr_c

SD.below := a1 + a4*(mean_of_DivScr - sqrt(var_of_DivScr))

mean_ := a1 + a4*(mean_of_DivScr)

SD.above := a1 + a4*(mean_of_DivScr + sqrt(var_of_DivScr))

X1_Lindirect.SDbelow := a1*b1 + a4*-sqrt(var_of_DivScr)*b1

X1_Lindirect.mean := a1*b1 + a4*(mean_of_DivScr)*b1

X1_Lindirect.SDabove := a1*b1 + a4*sqrt(var_of_DivScr)*b1

I do not understand how I can resolve the error (I don't understand the error at all. Can someone provide advice or readings? Thank you.

Dec 20, 2018, 9:18:11 AM12/20/18

to lav...@googlegroups.com

I don't quite understand why there is an error, but if the "exogenous" status really is the problem, you could resolve it by making the variable into a single, error-free indicator of a common factor. In efect, the factor would be identical to the observed variable but the "exogenous" flag would not go up. (Here, "exogenous" just means not predicted by something else. The lavaan package does have some special procedures for deaing with such variables, so it is possible that you have turned up some peculiar behavior.)

Watch out for unexpected free covariances between DivScr_c_factor and other variables in your model which are not predicted ("exogenous" in the SEM sense). These changes should leave fit and DF entirely unchanged. Also, watch out for typos in my code, above.

To implement this fix, you will add lines like this:

DivScr_c_factor=~1*DivScr_c # observed variable loads on factor, loading = 1

DivScr_c~~0*DivScr_c # 0 residual variance in DivScr_c, so variace of factor = variance of observed var

DivScr_c~0*1 # 0 intercept for DivScr_c, so mean of factor = mean of observed var

DivScr_c_factor~~var_of_DivScr_c_factor* DivScr_c_factor

DivScr_c_factor~~var_of_DivScr_c_factor* DivScr_c_factor

# var_of_DivScr_c_factor replaces var_of_DivScr_c in code

DivScr_c_factor~1*mean_of_DivScr_c_factor* DivScr_c_factor

# mean_of_DivScr_c_factor replaces mean_of_DivScr_c in code

Good luck.

--

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 post to this group, send email to lav...@googlegroups.com.

Visit this group at https://groups.google.com/group/lavaan.

For more options, visit https://groups.google.com/d/optout.

Jan 3, 2019, 2:17:16 PM1/3/19

to lavaan

Error in vnames(FLAT, type = "ov.x", ov.x.fatal = TRUE) :lavaan ERROR: model syntax contains variance/covariance/intercept formulasinvolving (an) exogenous variable(s): [DivScr_c];Please remove them and try again.

I do not understand how I can resolve the error

Did you try following the advice? "Please remove them and try again" It is referring to these lines:

DivScr_c ~ mean_of_DivScr*1DivScr_c ~~ var_of_DivScr*DivScr_c

Those lines are unnecessary because by default, lavaan's options are fixed.x=TRUE and (for models with categorical outcomes) conditional.x=TRUE. See the ?lavOptions help page for details. Basically, you can avoid making distributional assumptions about exogenous predictors if you consider them fixed (as they are treated in OLS regression), in which case lavaan does not estimate their means & (co)variances but instead simply plugs in the observed sample statistics.

Terrence D. Jorgensen

Assistant Professor, Methods and Statistics

Research Institute for Child Development and Education, the University of Amsterdam

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu