Looking for a global factor for the latent factors

Posted on
No user picture. nastjuscha Joined: 06/28/2016
Forums

Dear Mike,

thank you very much for your metaSEM-package, I really enjoy working with it!

I tested a model with 8 variables and 3 latent factors and now I would like to check, if there is a common factor for these three latent factors at the superordinate level - is it possible with metaSEM? I was looking for specifications like Gamma matrix in LISREL, but I unfortunately couldn't find anything.

Thank you!

Best wishes,
Nastja

Replied on Fri, 09/30/2016 - 23:05
Picture of user. Mike Cheung Joined: 10/08/2009

Dear Nastja,

Yes, you may specify both first- and second-order factor models in RAM specification. See e.g., http://openmx.psyc.virginia.edu/docs/OpenMx/2.6.7/Examples_Matrix.html

Alternatively, you may specify the models in equations (lavann syntax) and convert them to RAM specification via lavaan2RAM() in the metaSEM package. Please always check the RAM output as lavaan2RAM() is only experimental. Attached are the examples relevant to your models. Please also note that these two models are equivalent models with the same dfs.

Best,
Mike

Replied on Wed, 03/18/2020 - 05:12
No user picture. nastjuscha Joined: 06/28/2016

Dear Mike,

due to the current situation I have some to complete my old analyses. Would you be so kind and provide me with examples for specifying second-order factor models in RAM?
Thank you!

Best,
nastjuscha

Replied on Wed, 03/18/2020 - 06:13
Picture of user. Mike Cheung Joined: 10/08/2009

Dear nastjuscha,

There are some examples at https://cran.r-project.org/web/packages/metaSEM/vignettes/Examples.html#two-stage-structural-equation-modeling-tssem You may modify them to fit your case.

If you have specific questions, please let use know.

Best,
Mike

Replied on Wed, 03/18/2020 - 07:26
No user picture. nastjuscha Joined: 06/28/2016

In reply to by Mike Cheung

Dear Mike,

thank you! Unfortunately I still don't know where I have to specify the second-order factor. I tried something like this:
Phi2<-matrix(c(1,"0.3*cor1","0.3*cor2",".3*G_DT","0.3*cor1",1,"0.3*cor3",".3*G_Alpha",
"0.3*cor2","0.3*cor3",1,".3*G_Beta",".3*G_DT",".3*G_Alpha",".3*G_Beta",1),ncol=4, nrow=4)
Psi2<-Diag(c("0.2*e1","0.2*e2","0.2*e3","0.2*e4","0.2*e5","0.2*e6","0.2*e7",
"0.2*e8","0.2*e9","0.2*e10","0.2*e11","0.2*e12","0.2*e13","0.2*e14"))
S2<-bdiagMat(list(Psi2, Phi2))
dimnames(S2)[[1]]<-dimnames(S2)[[2]]<-c("M","N","P","5O","5C","5E","5A","5N","6H","6E","6X","6A","6C","6O","DT","Alpha","Beta","G")
S2
Lambda2<-matrix(c(".3*DT_M",".3*DT_N",".3*DT_P",0,".3*DT_5C",0,".3*DT_5A",0,".3*DT_6H",
rep(0,2), ".3*DT_6A", ".3*DT_6C",rep(0,5),".3*Alpha_5C",0,".3*Alpha_5A",".3*Alpha_5N",0,".3*Alpha_6E",
0,".3*Alpha_6A",".3*Alpha_6C",rep(0,2),".3*Beta_Nar",0,".3*Beta_5O",0,".3*Beta_5E",rep(0,4),
".3*Beta_6X",rep(0,2),".3*Beta_6O",rep(0,14)),ncol=4, nrow=14)
A2<-rbind(cbind(matrix(0,ncol=14,nrow=14),Lambda2), matrix(0,ncol=18,nrow=4))
dimnames(A2)[[1]]<-dimnames(A2)[[2]]<-c("M","N","P","5O","5C","5E","5A","5N","6H","6E","6X","6A","6C","6O","DT","Alpha","Beta","G")
A2
F2<-create.Fmatrix(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), as.mxMatrix=FALSE)
F2
random2<-tssem2(random1,Amatrix=A2, Smatrix=S2, Fmatrix=F2, intervals="LB")
summary(random2)

The programm is running this code for hours and hours without results. Could you help me, please?

Best,
nastjuscha

Replied on Wed, 03/18/2020 - 20:29
Picture of user. Mike Cheung Joined: 10/08/2009

Dear nastjuscha,

There are some errors in your model specification, e.g., "0.3cor1" should be "0.3*cor1".
I suggest to use the lavaan specification if you are not familiar with the RAM specification. Here is an example similar to yours.


model <- "## Factor loadings
Alpha =~ A+C+ES
Beta =~ E+I
## 2nd order general factor
G =~ Alpha + Beta
## Fix the variance of G at 1
G ~~ 1*G"

## Display the model
plot(model)

## Convert model to RAM
RAM <- lavaan2RAM(model, obs.variables=c("A","C","ES","E","I"), std.lv=FALSE)
RAM
> RAM
$A
A C ES E I Alpha Beta G
A "0" "0" "0" "0" "0" "0*AONAlpha" "0" "0"
C "0" "0" "0" "0" "0" "0*CONAlpha" "0" "0"
ES "0" "0" "0" "0" "0" "0*ESONAlpha" "0" "0"
E "0" "0" "0" "0" "0" "0" "0*EONBeta" "0"
I "0" "0" "0" "0" "0" "0" "0*IONBeta" "0"
Alpha "0" "0" "0" "0" "0" "0" "0" "0*AlphaONG"
Beta "0" "0" "0" "0" "0" "0" "0" "0*BetaONG"
G "0" "0" "0" "0" "0" "0" "0" "0"

$S
A C ES E I
A "0*AWITHA" "0" "0" "0" "0"
C "0" "0*CWITHC" "0" "0" "0"
ES "0" "0" "0*ESWITHES" "0" "0"
E "0" "0" "0" "0*EWITHE" "0"
I "0" "0" "0" "0" "0*IWITHI"
Alpha "0" "0" "0" "0" "0"
Beta "0" "0" "0" "0" "0"
G "0" "0" "0" "0" "0"
Alpha Beta G
A "0" "0" "0"
C "0" "0" "0"
ES "0" "0" "0"
E "0" "0" "0"
I "0" "0" "0"
Alpha "0*AlphaWITHAlpha" "0" "0"
Beta "0" "0*BetaWITHBeta" "0"
G "0" "0" "1"

$F
A C ES E I Alpha Beta G
A 1 0 0 0 0 0 0 0
C 0 1 0 0 0 0 0 0
ES 0 0 1 0 0 0 0 0
E 0 0 0 1 0 0 0 0
I 0 0 0 0 1 0 0 0

$M
A C ES E I Alpha Beta G
1 0 0 0 0 0 0 0 0

Best,
Mike

Replied on Sun, 03/22/2020 - 15:21
No user picture. nastjuscha Joined: 06/28/2016

Thank you!

I tried to use lavaan specification like yours but I always have the same error:

RAM <- lavaan2RAM(model2, obs.variables=c("M","N","P","FFMO","FFMC","FFME","FFMA","FFMN","HH","HE","HX","HA","HC","HO"), std.lv=FALSE)
> RAM
$`A`
M N P FFMO FFMC FFME FFMA FFMN HH HE HX HA HC HO DT Alpha
M "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*MONDT" "0"
N "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*NONDT" "0"
P "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*PONDT" "0"
FFMO "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
FFMC "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*FFMCONDT" "0*FFMCONAlpha"
FFME "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
FFMA "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*FFMAONDT" "0*FFMAONAlpha"
FFMN "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*FFMNONAlpha"
HH "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*HHONDT" "0"
HE "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*HEONAlpha"
HX "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
HA "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*HAONDT" "0*HAONAlpha"
HC "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0*HCONDT" "0*HCONAlpha"
HO "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
DT "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
Alpha "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
Beta "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
G "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
Beta G
M "0" "0"
N "0*NONBeta" "0"
P "0" "0"
FFMO "0*FFMOONBeta" "0"
FFMC "0" "0"
FFME "0*FFMEONBeta" "0"
FFMA "0" "0"
FFMN "0" "0"
HH "0" "0"
HE "0" "0"
HX "0*HXONBeta" "0"
HA "0" "0"
HC "0" "0"
HO "0*HOONBeta" "0"
DT "0" "0"
Alpha "0" "0*AlphaONG"
Beta "0" "0*BetaONG"
G "0" "0"

$S
M N P FFMO FFMC FFME FFMA
M "0*MWITHM" "0" "0" "0" "0" "0" "0"
N "0" "0*NWITHN" "0" "0" "0" "0" "0"
P "0" "0" "0*PWITHP" "0" "0" "0" "0"
FFMO "0" "0" "0" "0*FFMOWITHFFMO" "0" "0" "0"
FFMC "0" "0" "0" "0" "0*FFMCWITHFFMC" "0" "0"
FFME "0" "0" "0" "0" "0" "0*FFMEWITHFFME" "0"
FFMA "0" "0" "0" "0" "0" "0" "0*FFMAWITHFFMA"
FFMN "0" "0" "0" "0" "0" "0" "0"
HH "0" "0" "0" "0" "0" "0" "0"
HE "0" "0" "0" "0" "0" "0" "0"
HX "0" "0" "0" "0" "0" "0" "0"
HA "0" "0" "0" "0" "0" "0" "0"
HC "0" "0" "0" "0" "0" "0" "0"
HO "0" "0" "0" "0" "0" "0" "0"
DT "0" "0" "0" "0" "0" "0" "0"
Alpha "0" "0" "0" "0" "0" "0" "0"
Beta "0" "0" "0" "0" "0" "0" "0"
G "0" "0" "0" "0" "0" "0" "0"
FFMN HH HE HX HA HC HO
M "0" "0" "0" "0" "0" "0" "0"
N "0" "0" "0" "0" "0" "0" "0"
P "0" "0" "0" "0" "0" "0" "0"
FFMO "0" "0" "0" "0" "0" "0" "0"
FFMC "0" "0" "0" "0" "0" "0" "0"
FFME "0" "0" "0" "0" "0" "0" "0"
FFMA "0" "0" "0" "0" "0" "0" "0"
FFMN "0*FFMNWITHFFMN" "0" "0" "0" "0" "0" "0"
HH "0" "0*HHWITHHH" "0" "0" "0" "0" "0"
HE "0" "0" "0*HEWITHHE" "0" "0" "0" "0"
HX "0" "0" "0" "0*HXWITHHX" "0" "0" "0"
HA "0" "0" "0" "0" "0*HAWITHHA" "0" "0"
HC "0" "0" "0" "0" "0" "0*HCWITHHC" "0"
HO "0" "0" "0" "0" "0" "0" "0*HOWITHHO"
DT "0" "0" "0" "0" "0" "0" "0"
Alpha "0" "0" "0" "0" "0" "0" "0"
Beta "0" "0" "0" "0" "0" "0" "0"
G "0" "0" "0" "0" "0" "0" "0"
DT Alpha Beta G
M "0" "0" "0" "0"
N "0" "0" "0" "0"
P "0" "0" "0" "0"
FFMO "0" "0" "0" "0"
FFMC "0" "0" "0" "0"
FFME "0" "0" "0" "0"
FFMA "0" "0" "0" "0"
FFMN "0" "0" "0" "0"
HH "0" "0" "0" "0"
HE "0" "0" "0" "0"
HX "0" "0" "0" "0"
HA "0" "0" "0" "0"
HC "0" "0" "0" "0"
HO "0" "0" "0" "0"
DT "0*DTWITHDT" "0" "0" "0"
Alpha "0" "0*AlphaWITHAlpha" "0" "0"
Beta "0" "0" "0*BetaWITHBeta" "0"
G "0" "0" "0" "1"

$F
M N P FFMO FFMC FFME FFMA FFMN HH HE HX HA HC HO DT Alpha Beta G
M 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
N 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
P 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FFMO 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FFMC 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
FFME 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
FFMA 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
FFMN 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
HH 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
HE 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
HX 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
HA 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
HC 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
HO 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0

$M
M N P FFMO FFMC FFME FFMA FFMN HH HE HX HA HC HO DT Alpha Beta G

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

> fitmodel2 <- tssem2(random1, RAM=RAM, intervals="LB")
Error in wls(Cov = pooledS, aCov = aCov, n = tssem1.obj$total.n, Amatrix = Amatrix, :
"Smatrix" matrix is not specified.

Why is Smatrix not specified? I don't understand it, that's why I tried it with RAM specification.

Best,
nastjuscha

Replied on Wed, 03/25/2020 - 20:39
Picture of user. Mike Cheung Joined: 10/08/2009

Dear Nastja,

Please provide the data and R code so that the errors can be replicated.

Best,
Mike

Replied on Sun, 03/29/2020 - 21:42
Picture of user. Mike Cheung Joined: 10/08/2009

Dear Nastja,

The issue was the variance of the latent independent variable DT had not been fixed yet. Please see the attached file.
Please also note that I have not checked whether or not the model makes sense.

Best,
Mike

File attachments