You are here

How to write the syntax of bifactor model for Big Five Model by the metaSEM

3 posts / 0 new
Last post
Deng xiaoping's picture
Offline
Joined: 03/30/2018 - 11:03
How to write the syntax of bifactor model for Big Five Model by the metaSEM
AttachmentSize
Image icon bifactor model.png50.53 KB

Hi Mike
I have wrote a paper by metaSEM. Now,I am testing the bifactor model for the Big Five model by metaSEM, but I met dfficulties in the stage 2. I written the syntax on the basic of A higher-order confirmatory factor analytic model for the Big Five model(from the book Meta-Analysis A Structural Equation Modeling Approach), but the result was "Error in if (pchisq(chi.squared, df = df, ncp = 0) >= upper) { : missing value where TRUE/FALSE needed".
I'll always be very very grateful for your suggestion.

The syntax of the bifactor model :
library("metaSEM")
options(scipen=200)
##stage 1
fixed1 <- tssem1(Digman97$data, Digman97$n, method="FEM")
summary(fixed1)
coef(fixed1)
##stage 2
## Define the S matrix that includes both Phi and Psi
## Phi matrix: 3x3 correlation matrix between the latent factors
( Phi <- matrix(c(1,".3*cor", 0, ".3*cor",1,0,0,0,1), nrow=3, ncol=3) )
## Psi matrix: 5x5 diagonal matrix of the error variances
( Psi <- Diag(c(".2*e1",".2*e2",".2*e3",".2*e4",".2*e5")) )
## Create a block diagonal matrix as the S matrix
S1 <- bdiagMat(list(Psi, Phi))

## This step is not necessary but useful for inspecting the model.
dimnames(S1)[[1]] <- c("A","C","ES","E","I","f_Alpha","f_Beta","f_G")
dimnames(S1)[[2]] <- dimnames(S1)[[1]]
S1

## Convert it into a MxMatrix class
S1 <- as.mxMatrix(S1)
## Lambda matrix: 5x3 factor loadings
## Arrange the data by row
( Lambda <- matrix(c(".3*Alpha_A", 0, ".3*G_A ",
".3*Alpha_C", 0, ".3*G_C ",
".3*Alpha_ES", 0, ".3*G_ES ",
0, ".3*Beta_E",".3*G_E ",
0, ".3*Beta_I",".3*G_I "),
nrow=5, ncol=3, byrow=TRUE) )
## Create a 5x5 of zeros
( Zero5x5 <- matrix(0, nrow=5, ncol=5) )
## Create a 3x8 of zeros
( Zero3x8 <- matrix(0, nrow=3, ncol=8) )
## Define the A matrix
A1 <- rbind(cbind(Zero5x5, Lambda), Zero3x8)
## This step is useful for inspecting the model.
dimnames(A1)[[1]] <- c("A","C","ES","E","I","f_Alpha","f_Beta","f_G")
dimnames(A1)[[2]] <- dimnames(A1)[[1]]
A1
## Convert it into a MxMatrix class
A1 <- as.mxMatrix(A1)
## F matrix to select the observed variables
## First 5 elements are observed variables
## Last 3 elements are latent variables
F1 <- create.Fmatrix(c(1,1,1,1,1,0,0,0), name="F1", as.mxMatrix=FALSE)
## This step is useful for inspecting the model.
dimnames(F1)[[1]] <- c("A","C","ES","E","I")
dimnames(F1)[[2]] <- c("A","C","ES","E","I","f_Alpha","f_Beta","f_G")
F1
## Convert it into a MxMatrix class
F1 <- as.mxMatrix(F1)
fixed2 <- tssem2(fixed1, Amatrix=A1, Smatrix=S1, Fmatrix=F1, diag.constraints=FALSE)
summary(fixed2)

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Dear Xiaoping,

Dear Xiaoping,

For bifactor models, the specific factors are usually uncorrelated. The model works when you set the correlation between f_Alpha and f_Beta at 0.

Mike

Deng xiaoping's picture
Offline
Joined: 03/30/2018 - 11:03
Dear Mike,

Dear Mike,
I followed your suggestion, and the problem was gone.
Thanks again.
Xiaoping