Problem with Two-Stage Structural Equation Modelling

Hello,

I am two-stage structural equation modelling to confirm the factorial structure of a scale I am using. I have conducted a meta analysis and have found nine relevant studies that have used that scale. I want to confirm whether the structure of the scale fits or not using meta analytic structural equation modelling. For doing this, I am using the two-stage approach (in metaSEM) package.

This first stage is working fine but I am getting an error in the second stage (i.e. tssem2). The code is presented below:

Stage 2

#There are two observed variables (BO and STS) and one latent variable (CF)

dims <- c("BO", "STS", "CF")
mat<-matrix(rep(0, 3*3), nrow=3, ncol=3)
dimnames(mat)[[1]]<-dimnames(mat)[[2]]<-dims
mat

# A matrix

A <- matrix(c(0,0,"0.3*CF_BO",0,0,"0.3*CF_STS",0,0,0),nrow=3,ncol=3,byrow=TRUE)
dimnames(A)[[1]]<-dimnames(A)[[2]]<-dims
A
A<-as.mxMatrix(A)

# S matrix

Vars <- Diag(c("0.2*var_BO", "0.2*var_STS"))
Cors <- matrix(1,nrow=1,ncol=1)
S <- bdiagMat(list(Vars, Cors))
dimnames(S)[[1]] <- dimnames(S)[[2]] <- dims
S
S <- as.mxMatrix(S)

# F matrix

F <- Diag(c(1, 1, 0))
F <- F[1:2,]
dimnames(F)[[1]] <- dims[1:2]
dimnames(F)[[2]] <- dims
F
F <- as.mxMatrix(F)
cfa2 <- tssem2(cfa1, Amatrix = A, Smatrix = S, Fmatrix = F, diag.constraints = FALSE)
summary (cfa2)

# The error message I am getting is:

Error in if (pchisq(chi.squared, df = df, ncp = 0) >= upper) { : 
  missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In pchisq(tT, df = dfT, lower.tail = FALSE) : NaNs produced
2: In sqrt(max((tT - dfT)/(n - 1), 0)/dfT) : NaNs produced
3: In pchisq(chi.squared, df = df, ncp = 0) : NaNs produced

I would really appreciate some help.

Thank you

Jasmeet Singh

your reprex is incomplete unfortunately.

 object 'cfa1' not found

I think this reprex is no more useful as all.data is a private object of yours.
In general a reprex should be as minimal as possible and contain no private objects.

i.e. if you have one command that errors.
its enough to provide the command and the data params that you pass to it

for example if you have an error on the line

tssem2(cfa1, Amatrix = A, Smatrix = S, Fmatrix = F, diag.constraints = FALSE)

only.

then, quote that line, use the forum code formatting to print it nicely, also use dput on each param in turn and provide them as code in the post also, so that the param call can be reconstructed.

I will work on it and share the problem again.

Thank you for your suggestion.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Hello,

I apologise for that.

The complete reprex is mentioned below:

Stage 1

cfa1 <- tssem1(all.data[[1]], all.data[[2]], method="REM", RE.type = "Diag")
summary(cfa1)

Stage 2

#There are two observed variables (BO and STS) and one latent variable (CF)

dims <- c("BO", "STS", "CF")
mat<-matrix(rep(0, 3*3), nrow=3, ncol=3)
dimnames(mat)[[1]]<-dimnames(mat)[[2]]<-dims
mat

A matrix

A <- matrix(c(0,0,"0.3CF_BO",0,0,"0.3CF_STS",0,0,0),nrow=3,ncol=3,byrow=TRUE)
dimnames(A)[[1]]<-dimnames(A)[[2]]<-dims
A
A<-as.mxMatrix(A)

S matrix

Vars <- Diag(c("0.2var_BO", "0.2var_STS"))
Cors <- matrix(1,nrow=1,ncol=1)
S <- bdiagMat(list(Vars, Cors))
dimnames(S)[[1]] <- dimnames(S)[[2]] <- dims
S
S <- as.mxMatrix(S)

F matrix

F <- Diag(c(1, 1, 0))
F <- F[1:2,]
dimnames(F)[[1]] <- dims[1:2]
dimnames(F)[[2]] <- dims
F
F <- as.mxMatrix(F)
cfa2 <- tssem2(cfa1, Amatrix = A, Smatrix = S, Fmatrix = F, diag.constraints = FALSE)
summary (cfa2)

Kindly note that object 'cfa1' is a matrix that I developed of correlations and sample sizes. Would you like me to share code for that?