0

I was looking at this example: https://stats.stackexchange.com/questions/163436/r-moderated-mediation-using-the-lavaan-package to make my own moderated mediation, but I get errors and I am not finding the solution.

my model is:

model <- '
#direct effects
mem ~ c*var1 + cw*interaction +b*var2
var2 ~ a*var1+aw*interaction
#covariates
mem ~ age+sex+iq
var1 ~ age+sex+iq
var 2 ~ age+sex+iq
#indirect effect
ab := a*b
#total effect
total := c+(a*b)
#conditional effects
ab1 := a*b+aw*b
total1 := a*b+c+cw'

fit <- sem(model, data=mydata, se="robust.huber.white", test="bootstrap",bootstrap=1000)

The error message I get is:

Error in chol.default(S) :the leading minor of order 8 is not positive definite In addition: Warning message: In lav_samplestats_from_data(lavdata = NULL, DataX = dataX, DataeXo = dataeXo,: lavaan WARNING: sample covariance can not be inverted

I did scale all variables beforehand, not sure if that is the issue? Any thoughts?

Community
  • 1
  • 1
user6121484
  • 143
  • 2
  • 15
  • 1
    This would be easiest to answer if you provide a dataset. What's the simplest dataset (and the simplest model formula) that reproduces this error message? – Richie Cotton Aug 18 '16 at 04:51
  • 1
    @Hack-R OK, I voted, but for new users it's often helpful to prompt them on how to improve the question, and give them a little bit of time to fix it before closing. – Richie Cotton Aug 18 '16 at 05:36
  • 1
    I solved it, there was a very stupid typo in the one of the variable names. Weird error message though... – user6121484 Aug 19 '16 at 16:54

0 Answers0