Search code examples
rr-lavaan

R lavaan error when standardizing observations


I've come across an error when trying to do the following model in lavaan package for path analysis:

my.data<-data.frame(A=A,C=C,D=D)
my.model<-"
C~D
A~C+D
"
fit.mine<-sem(my.model,data=my.data,fixed.x=FALSE, std.ov = TRUE)

Produces this error:

Error in cov(eXo[[g]], use = "pairwise") : supply both 'x' and 'y' or a matrix-like 'x'

The error disappears when std.ov is set to false, but this is not ideal.

I have also tried decostand(my.data, method="standardize") from vegan and while that will compute, it produces strange results (negative AIC/BIC) when that matrix is put into lavaan.

Thanks very much for insight, Michael


Solution

  • Found my answer in a user group on another forum, thought I would post here in case anyone else needs it:

    The error above is a bug. It only appears if the argument std.ov=TRUE, and there is exactly 1 exogenous variable in the model.

    The workaround in lavaan version 0.5-17 is to standardized your variables before the analysis.

    This bug has been fixed in dev 0.5-18.772.