You are here

Error in metasem, tssem2, “operations are possible only for numeric, logical or complex types”

2 posts / 0 new
Last post
PeterK's picture
Offline
Joined: 03/20/2018 - 13:10
Error in metasem, tssem2, “operations are possible only for numeric, logical or complex types”

I try to estimate parameters in a meta-analytical path model, where A -> B -> C (full mediation) based on a list of correlation matrices in metaSem.

My A1 matrix is as follows:


A1 <- create.mxMatrix(c(0, 0, 0,
indep2med, 0, 0,
0, med2dep, 0),
type="Full", byrow=TRUE, ncol=3, nrow=3,
as.mxMatrix=TRUE)
dimnames(A1)[[1]] <- dimnames(A1)[[2]] <- variable.labels

My S1 matrix is as follows:


S1 <- create.mxMatrix(c("1", 0, 0,
0, ".1*e2", 0,
0, 0, ".1*e3"),
type="Full", byrow=TRUE, ncol=3, nrow=3,
as.mxMatrix=TRUE)
dimnames(S1)[[1]] <- dimnames(S1)[[2]] <- variable.labels

All is fine when I use the standard settings in estimating the pooled correlation matrix and estimating the model parameters using:


fit1 <- tssem1(data.list$data,data.list$n,method = "REM", RE.type = "Diag")
fit2 <- tssem2(fit1,Amatrix=A1,Smatrix=S1)

However, if I set diag.constraints="TRUE" in tssem2, that is

fit2 <- tssem2(fit1,Amatrix=A1,Smatrix=S1,diag.constraints="TRUE") as is recommended for mediation models, I get an error:


Error in diag.constraints & (sum(Constraints) > 0) : operations are possible only for numeric, logical or complex types

What do I do wrong? Moreover, why do I need to set diag.constraints="TRUE"?

Any help is appreciated.

PS. I firstly/also posted this question on stackoverflow: https://stackoverflow.com/questions/49387102/error-in-metasem-tssem2-ope...

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
A1 should generate an error.

A1 should generate an error. The correct syntax for A1 is:

A1 <- create.mxMatrix(c(0, 0, 0,
"0indep2med", 0, 0,
0, "0
med2dep", 0),
type="Full", byrow=TRUE, ncol=3, nrow=3,
as.mxMatrix=TRUE)

The other syntax seems correct to me. By the way, diag.constraints="TRUE" is not required in tssem2() any more.

P.S. Please do not post it twice.