Re: script and data related to the post about bifactors and lavaan::: sam/FSR+Croon

83 views
Skip to first unread message

Yves Rosseel

unread,
Aug 29, 2020, 10:36:06 AM8/29/20
to Nikola Ćirović, 'Anna' via lavaan
Dear Nikola,

Thanks for your script/data. In principle, it should work. But it is
important that when we estimate the CFA models in the first step, we
keep the bifactor pieces together. This means that we must fit the
general factor and its specific factors in one go (and not first the
general factor alone, and then the first specific factor alone, etc). To
accomplish this, you need to use the mm.list= argument as follows:

mm.list = list(bis = "bis", bas = "bas", fight = "fight", freeze =
"freeze", flight = "flight", socanx = c("SOCANX", "SA1", "SA3", "SA4"),
rum = c("RUM" ,"RT", "CFT", "PFT"))

The mm.list defines the 'blocks' that are fitted together. For the
bis/bas/... factors, it is one factor per block. But for socanx and rum,
we fit several factor together:

# sam - local
fit.sam <- lavaan:::sam(proba, data = rsq_rtsq_sas1, sam.method =
"local", estimator = "MLR", missing = "fiml", verbose = TRUE,
mm.list = mm.list)

Unfortunately, this will not work for your data. The reason is that the
measurement models fit (very) poorly, leading to more 'error' than
'signal' for some of the variables, and this gives computational trouble
later when computing the (two-step) standard errors. At least, when
sam.method = "local".

The only way out (here) is to switch to sam.method = "global":

fit.sam.global <- lavaan:::sam(proba, data = rsq_rtsq_sas1,
sam.method = "global",
estimator = "MLR", missing = "fiml",
mm.list = mm.list)

which does work for your model/data combination. The difference between
local/global is somewhat technical. Local sam will explicitly compute an
estimate of the variance/covariance matrix of the latent variables, and
compute the regressions among them in a second step. Global sam does not
explicitly compute this variance matrix, and this can an advantage in
more demanding settings.

Yves.



On 8/27/20 4:19 AM, Nikola Ćirović wrote:
> Dear Dr Rosseel,
>
> I am writing to you in reply to the post on lavaan google group where we
> made a deal about sharing the syntax and the data.
>
> https://groups.google.com/d/msgid/lavaan/a1c3de6d-ef1a-40c4-bd17-a7de82767364o%40googlegroups.com
>
> First of all, thank you for your interest and your help. I am really
> eager to learn how to apply  FDR+Croon procedure. A reviewer recommended
> it to me and I am really eager to learn about it for the soon upcoming work.
>
> I am sending you the script (like you said) I used for the analysis of
> the model I mentioned (5 personality traits, two bifactor structures –
> one whose general factor is a mediator and the other whose general
> factor is the outcome; at first, I specified all the direct and indirect
> paths). Also, attached you will find the full data with the variables in
> question.
>
>
> This is the script I used.
>
> proba<-'
>
> *#personality traits *
>
> bis=~ p114+p125+p129+p130+p133+p136+p138
>
> bas=~p116+p118+p127+p131+p137+p140
>
> fight=~p115+p121+p123+p124+p132+p139
>
> freeze=~p117+p119+p126+p128+p134
>
> flight=~p113+p120+p122+p135+p141
>
> *#the bifactors *
>
> SOCANX =~
> p142+p143+p144+p145+p146+p147+p148+p149+p150+p151+p152+p153+p154+p155+p156+p157+p158+p159+p160+p161+p162+p163+p164+p165+p166
>
>
> SA1=~  p143+p145+p146
>
> p154~~p144
>
> SA3=~ p156+p157+p158+p159
>
> SA4=~p162+p163+p164+p165
>
> RUM=~p167+p168+p169+p170+p171+p172+p173+p174+p175+p176+p177+p178+p179+p180+p181+p183+p184+p185+p186
>
> RT =~p167+p168+p169+p170
>
> CFT=~ p172+p173+p174
>
> PFT=~p175+p177+p178+p179
>
> p183~~p185
>
> p185 ~~ p186
>
> *#manual fixing of covariances to zero to make sure group-factors of
> bifactors are orthogonal to every other factor (I get the same with
> orthogonal argument that I use with sem function)*
>
> bis~~0*SA1+0*SA3+0*SA4
>
> bas~~0*SA1+0*SA3+0*SA4
>
> fight~~0*SA1+0*SA3+0*SA4
>
> freeze~~0*SA1+0*SA3+0*SA4
>
> flight~~0*SA1+0*SA3+0*SA4
>
> bis~~ 0*RT+0*CFT+0*PFT
>
> bas~~0*RT+0*CFT+0*PFT
>
> fight~~0*RT+0*CFT+0*PFT
>
> freeze~~0*RT+0*CFT+0*PFT
>
> flight~~0*RT+0*CFT+0*PFT
>
> SA1~~ 0*RT+0*CFT+0*PFT
>
> SA3~~0*RT+0*CFT+0*PFT
>
> SA4~~0*RT+0*CFT+0*PFT
>
> RT~~ 0*CFT+0*PFT
>
> CFT~~0*PFT
>
> SA1~~ 0*SA3+0*SA4
>
> SA3~~ 0*SA4
>
> SOCANX~~0*SA1+0*SA3+0*SA4
>
> RUM ~~0*RT+0*CFT+0*PFT
>
> *# the structural part of the model*
>
> RUM~ bis+fight+flight+freeze+bas
>
> SOCANX~ RUM+bis+fight+flight+freez+bas
>
> '
>
> fit.proba <- lavaan ::: sam (proba, data = rsq_rtsq_sas1 ,sam.method =
> "local", estimator = "MLR", missing = 'fiml')
>
> summary(fit.proba,
>
>         fit.measures = TRUE,standardize = TRUE,
>
>         rsquare = TRUE)
>
> *This script produces the following error:*
>
>> fit.proba <- lavaan ::: sam (proba, data = PORPOS_3_ukupna_matrica_07_12bez10misingout_01
> ,sam.method = "local", estimator = "MLR", missing = 'fiml')
>
> Warning message:
>
> In lavaan:::sam(proba, data = rsq_rtsq_sas1,  :
>
>   lavaan WARNING: no free parameters left for structural part.
>
>         Returning measurement part only.
>
>>
>
>> summary(fit.proba,
>
> +         fit.measures = TRUE,standardize = TRUE,
>
> +         rsquare = TRUE)
>
>       Length Class  Mode
>
>  [1,] 1 lavaan S4
>
>  [2,] 1 lavaan S4
>
>  [3,] 1 lavaan S4
>
>  [4,] 1 lavaan S4
>
>  [5,] 1 lavaan S4
>
>  [6,] 1 lavaan S4
>
>  [7,] 1 lavaan S4
>
>  [8,] 1 lavaan S4
>
>  [9,] 1 lavaan S4
>
> [10,] 1      lavaan S4
>
> [11,] 1      lavaan S4
>
> [12,] 1      lavaan S4
>
> [13,] 1      lavaan S4
>
>>
>
> *Howe**ver, when I drop the group-factors it works.*
>
> modeSAM.bez.bifactora<-'
>
> bis=~ p114+p125+p129+p130+p133+p136+p138
>
> bas=~p116+p118+p127+p131+p137+p140
>
> fight=~p115+p121+p123+p124+p132+p139
>
> freez=~p117+p119+p126+p128+p134
>
> flight=~p113+p120+p122+p135+p141
>
> SOCANX =~
> p142+p143+p144+p145+p146+p147+p148+p149+p150+p151+p152+p153+p154+p155+p156+p157+p158+p159+p160+p161+p162+p163+p164+p165+p166
>
>
> RUM =~
> p167+p168+p169+p170+p171+p172+p173+p174+p175+p176+p177+p178+p179+p180+p181+p183+p184+p185+p186
>
> RUM~ bis+fight+flight+freez+bas
>
> SOCANX~ RUM+bis+fight+flight+freez+bas
>
> '
>
> fit.SAM.model.bezbifactora <- lavaan ::: sam (modeSAM.bez.bifactora,
> data = rsq_rtsq_sas1,estimator = "MLR",missing = 'fiml', sam.method =
> "local" )
>
> summary(fit.SAM.model.bezbifactora,
>
>         fit.measures = TRUE,standardize = TRUE,
>
>         rsquare = TRUE)
>
> Ona additional question, I have noticed that when I use sam function
> after ML standard errors of the structural parameters (and p values)
> differ really slightly form SEs and p that I get from MLR.
>
> Finally, the problem with fsr function I had  (I mentioned in lavaan
> group) was resolved when I reinstalled lavaan (to the 6-7 version) but
> the results I get are really strange  - structural parameter are so
> contrary to the once I obtained with sam function with the
> sam.method=”local” argument and contrary to once I got when I use MLR or
> WLSMV with sem function, and also these parameters don’t make sense
> (when I prespecify sem-derived paths with fsr function the fit, of
> course,  is poor). In short – they are almost the revered findings. So,
> I really also need to ask you if I can use sam function with
> sam.method=”local” argument and cite the Devlieger & Rosseel, 2017? I
> apologize for this pragmatic question but the review is due very soon so
> it would mean a lot to me to have at least that bit of certainty (and
> I’ll be thrilled to see the developments with the bifactors and sam).
>
>> modeSAM.bez.bifactora<-'
>
> + bis=~ p114+p125+p129+p130+p133+p136+p138
>
> + bas=~p116+p118+p127+p131+p137+p140
>
> + fight=~p115+p121+p123+p124+p132+p139
>
> + freez=~p117+p119+p126+p128+p134
>
> + flight=~p113+p120+p122+p135+p141
>
> +
>
> + SOCANX =~
> p142+p143+p144+p145+p146+p147+p148+p149+p150+p151+p152+p153+p154+p155+p156+p157+p158+p159+p160+p161+p162+p163+p164+p165+p166
>
>
> +
>
> + RUM =~
> p167+p168+p169+p170+p171+p172+p173+p174+p175+p176+p177+p178+p179+p180+p181+p183+p184+p185+p186
>
> +
>
> + RUM~ bis+fight+flight+freez+bas
>
> + SOCANX~ RUM+bis+fight+flight+freez+bas
>
> + '
>
>> fit.fsr.model  <-  lavaan:::fsr(model = modeSAM.bez.bifactora, data =
> rsq_rtsq_sas1, cmd = "sem",
>
> +     fsr.method = "Croon", fs.method = "Bartlett")
>
>> summary(fit.fsr.model,
>
> +         fit.measures = TRUE,standardize = TRUE,
>
> +         rsquare = TRUE)
>
> *and when I apply fsr to the model with bifactors it shows a warning
> message: *
>
> Error in lavaan:::fsr(model = proba, data = rsq_rtsq_sas1, cmd = "sem",  :
>
>   lavaan ERROR: corrected covariance matrix of factor scores
>
>                 is not positive definite;
>
> Once again, thank you for your interest and help and all the helpful
> work you so kindly share through lavaan.
>
> Best wishes,
>
> Nikola Ćirović, a junior researcher at the Department of Psychology,
> Faculty of Philosophy, University of Niš (Serbia)
>
> official mail: nikola....@filfak.ni.ac.rs
> <mailto:nikola....@filfak.ni.ac.rs>
>

--
Yves Rosseel
Department of Data Analysis, Ghent University

Nikola Ćirović

unread,
Aug 31, 2020, 4:53:58 PM8/31/20
to Yves Rosseel, 'Anna' via lavaan

Dear Yves, 

 

Thank you a thousand times for your time and effort, and also your kind approach. I am eager to learn about SAM and I am therefore very appreciative of your effort to help. I have one question that is about a problem that, given all this new information, left me confused. 

 

Namely, the global SAM that you have found to be the only to work for my model with bifactors seem to produce a bad fit (which is fair), however, I have noticed that the global SAM-obtained chi-square and df correspond to those I get by applying SEM. The output also produces all these parameters from the measurement model. Now, I do understand that this still is SAM (and I am looking forward to the future papers on SAM), but it seems that the model fit is still evaluated against 2509 degrees of freedom. However, the reviewer that suggested FSR+Croon to me made his suggestion based on the assumption that this will allow me to test the fit of the model that takes only structural relations in consideration (and hence simplifies the model, as  I have hypothesised that the bad fit with MLR SEM is due to model complexity and accompanying misspecifications). More importantly, when I apply local SAM to the model where group-specific factors are taken out (so I have ordinary unidimensional factors for both mediator and outcome instead of the bifactors) - the df is 5 and fit is (no surprise) good. This would allow me to test the fit of the simplified version of my model and answer the review. As I have no publication to rely on, I would be greatly thankful if you told me if I am basing anything here on a wrong assumption on how local SAM works. My question would, in short be, can I use the local SAM as I have described (I get the model with 5 df and only the structural paths and covariances estimated), call this FSR + Croon and cite Devlieger & Rosseel, 2017 (and Devlieger, Mayer, & Rosseel, 2016)? And it uses the total sample? Also, I see that standard errors in local SAM differ when I use MLR as opposed to ML (by a small bit) and so I was wondering if this is relevant.

 

I am sorry to have written my previous question on the google.group as well but the question I asked there is somewhat different (I thought other would find more interesting) and is more about the fsr function which produced strange results for my model - when I take out the group-specific factors of course – fsr function estimates regression paths between the latent variables that are contrary to the ones I get with either MLR or WLSMV SEM (and contrary to those I get from SAM either applied to model with bifactors or not).

 

Best wishes,

Nikola

 

Yves Rosseel

unread,
Sep 2, 2020, 10:30:59 AM9/2/20
to lav...@googlegroups.com, Nikola Ćirović
Dear Nikola,

On 8/31/20 10:53 PM, Nikola Ćirović wrote:
> Namely, the global SAM that you have found to be the only to work for my
> model with bifactors seem to produce a bad fit (which is fair), however,
> I have noticed that the global SAM-obtained chi-square and df correspond
> to those I get by applying SEM.

That is correct. 'global' SAM still estimates the parameters in 2 steps:
first the measurement part, then (keep the measurement part fixed) the
structural part. To evaluate the model, it uses the same chi-square test
statistic (technically, it is just an approximation) as regular sem.

If you get a 'bad' fit, it is very likely that this is due to some of
the measurement models. This is 'global' fit: both the measurement and
structural part of the model are evaluated together (just like in
regular sem).

> However, the reviewer that suggested FSR+Croon to me made his
> suggestion based on the assumption that this will allow me to test the
> fit of the model that takes only structural relations in consideration

If this is what you really want, then you can use fit the CFA part of
the model (all latent variables in the model, but without the
'structural' part). Then you can extract the variance/covariance matrix
of the latent variables, using

COV <- lavInspect(fit, "cov.lv")

and then you can fit the structural part only using 'COV' as the input
covariance matrix. The standard errors will be underestimated, but it
will give you a good sense of the fit of the structural part (only). In
other words, you don't need FSR/SAM for this.

> More importantly, when I apply local SAM to the
> model where group-specific factors are taken out (so I have ordinary
> unidimensional factors for both mediator and outcome instead of the
> bifactors) - the df is 5 and fit is (no surprise) good. This would allow
> me to test the fit of the simplified version of my model and answer the
> review. As I have no publication to rely on, I would be greatly thankful
> if you told me if I am basing anything here on a wrong assumption on how
> local SAM works.

Local SAM is really (almost) identical to FSR+Croon, so you can refer to
the papers of Devlieger et.al.

> My question would, in short be, can I use the local SAM
> as I have described (I get the model with 5 df and only the structural
> paths and covariances estimated), call this FSR + Croon and cite
> Devlieger & Rosseel, 2017 (and Devlieger, Mayer, & Rosseel, 2016)?

Yes.

> Also, I see that standard errors in local SAM
> differ when I use MLR as opposed to ML (by a small bit) and so I was
> wondering if this is relevant.

The MLR part if only used for the 'first step' (the CFA part of the
model). This may indeed lead to small changes, but usually not much.

Yves.
Reply all
Reply to author
Forward
0 new messages