# Looking for a global factor for the latent factors

10 posts / 0 new
Offline
Joined: 06/28/2016 - 04:51
Looking for a global factor for the latent factors
AttachmentSize
8.94 KB
802 bytes

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

Offline
Joined: 10/08/2009 - 22:37
Dear Nastja, Yes, you may

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

Offline
Joined: 06/28/2016 - 04:51
Dear Mike,

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

Offline
Joined: 10/08/2009 - 22:37
Dear nastjuscha,

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

Offline
Joined: 06/28/2016 - 04:51
Dear Mike,

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.3cor1","0.3cor2",".3G_DT","0.3cor1",1,"0.3cor3",".3G_Alpha",
"0.3cor2","0.3cor3",1,".3G_Beta",".3G_DT",".3G_Alpha",".3G_Beta",1),ncol=4, nrow=4)
Psi2<-Diag(c("0.2e1","0.2e2","0.2e3","0.2e4","0.2e5","0.2e6","0.2e7",
"0.2
e8","0.2e9","0.2e10","0.2e11","0.2e12","0.2e13","0.2e14"))
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(".3DT_M",".3DT_N",".3DT_P",0,".3DT_5C",0,".3DT_5A",0,".3DT_6H",
rep(0,2), ".3DT_6A", ".3DT_6C",rep(0,5),".3Alpha_5C",0,".3Alpha_5A",".3Alpha_5N",0,".3Alpha_6E",
0,".3Alpha_6A",".3Alpha_6C",rep(0,2),".3Beta_Nar",0,".3Beta_5O",0,".3Beta_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

Offline
Joined: 10/08/2009 - 22:37
Dear nastjuscha,

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

File attachments:
Offline
Joined: 06/28/2016 - 04:51
Thank you!

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" "0MONDT" "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" "0PONDT" "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" "0FFMCONAlpha" 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" "0FFMAONAlpha" 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" "0HHONDT" "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" "0HAONDT" "0HAONAlpha" HC "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0HCONDT" "0HCONAlpha" 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 "0NONBeta" "0" P "0" "0" FFMO "0 FFMOONBeta" "0" FFMC "0" "0" FFME "0FFMEONBeta" "0" FFMA "0" "0" FFMN "0" "0" HH "0" "0" HE "0" "0" HX "0 HXONBeta" "0" HA "0" "0" HC "0" "0" HO "0HOONBeta" "0" DT "0" "0" Alpha "0" "0 AlphaONG" Beta "0" "0*BetaONG" G "0" "0"$S
M N P FFMO FFMC FFME FFMA
M "0MWITHM" "0" "0" "0" "0" "0" "0"
N "0" "0
NWITHN" "0" "0" "0" "0" "0"
P "0" "0" "0PWITHP" "0" "0" "0" "0"
FFMO "0" "0" "0" "0
FFMOWITHFFMO" "0" "0" "0"
FFMC "0" "0" "0" "0" "0FFMCWITHFFMC" "0" "0"
FFME "0" "0" "0" "0" "0" "0
FFMEWITHFFME" "0"
FFMA "0" "0" "0" "0" "0" "0" "0FFMAWITHFFMA"
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" "0HHWITHHH" "0" "0" "0" "0" "0"
HE "0" "0" "0
HEWITHHE" "0" "0" "0" "0"
HX "0" "0" "0" "0HXWITHHX" "0" "0" "0"
HA "0" "0" "0" "0" "0
HAWITHHA" "0" "0"
HC "0" "0" "0" "0" "0" "0HCWITHHC" "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 "0DTWITHDT" "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

Offline
Joined: 10/08/2009 - 22:37
Dear Nastja,

Dear Nastja,

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

Best,
Mike

Offline
Joined: 06/28/2016 - 04:51
Dear Mike,

Dear Mike,

here you are. I hope you can help me to solve the problem.

Best,
Nastja

File attachments:
Offline
Joined: 10/08/2009 - 22:37
Dear Nastja,

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: