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?