factor scores from cfa

3,257 views
Skip to first unread message

Dr. Hans Hansen

unread,
Nov 1, 2012, 6:47:50 AM11/1/12
to lav...@googlegroups.com
dear lavaan-users,

is it possible to access individual factor scores (the latent score) in a stored cfa-object?

best, hans

yrosseel

unread,
Nov 1, 2012, 8:22:00 AM11/1/12
to lav...@googlegroups.com
predict(fit)

computes factor scores. For continuous data only.

Yves.

Dr. Hans Hansen

unread,
Nov 1, 2012, 11:13:25 AM11/1/12
to lav...@googlegroups.com
Ups, that simple. Thanks a lot! Hans

Dr. Hans Hansen

unread,
Nov 7, 2012, 2:44:53 PM11/7/12
to lav...@googlegroups.com

Dear Yves,

i used the predict function on a cfa-object estimated previously with full-information maximum likelihood. I get an NA estimate for every individual which hasn't answered every item. Is there a way to get estimates on these individuals too?

Best, Hans

yrosseel

unread,
Nov 7, 2012, 3:22:14 PM11/7/12
to lav...@googlegroups.com
Not with the current version of lavaan (0.5-10). Essentially, the
predict() function can not handle missing data (yet). This has been on
my todo list for some time... (any volunteers?)

In the meantime, I would suggest to use multiple imputation (perhaps
using packages mice or amelia) to get a set of complete datasets; fit
the model on each dataset, and compute factor scores for each dataset. I
believe taking the average of those factor scores will get you close enough.

Yves.

Dr. Hans Hansen

unread,
Nov 7, 2012, 3:47:10 PM11/7/12
to lav...@googlegroups.com
Dear Yves, thanks for clarifying this. Unfortunately, neither my programming skills nor my statistical knowledge seems sufficient to implement methods like this, altough it might be a nice opportunity to aquire some new skills. However, maybe it's more simple than i can think of it? How would the prediction work?

Best, Hans

yrosseel

unread,
Nov 8, 2012, 4:31:45 PM11/8/12
to lav...@googlegroups.com
Well, suppose 'HS.model' contains the model syntax, and 'HS.missing'
contains missing data, something very rudimentary could be this (using
the 'mice' package):

# generate 5 multiple complete datasets
out <- mice(HS.missing, m=5)
D1 <- complete(out, 1)
D2 <- complete(out, 2)
D3 <- complete(out, 3)
D4 <- complete(out, 4)
D5 <- complete(out, 5)

# fit model for each complete dataset
fit1 <- cfa(HS.model, data=D1)
fit2 <- cfa(HS.model, data=D2)
fit3 <- cfa(HS.model, data=D3)
fit4 <- cfa(HS.model, data=D4)
fit5 <- cfa(HS.model, data=D5)

# predict scores for all models
p1 <- predict(fit1)
p2 <- predict(fit2)
p3 <- predict(fit3)
p4 <- predict(fit4)
p5 <- predict(fit5)

# compute 'average' across 5 sets of scores:
scores <- (p1 + p2 + p3 + p4 + p5)/5



Hope this helps,

Yves.






Dr. Hans Hansen

unread,
Nov 9, 2012, 3:33:44 AM11/9/12
to lav...@googlegroups.com
Dear Yves,

thanks for giving a example, but i was referring to volunteer to implement the predict method for fiml-cfa objects. Anyway, I might try the mice approach.

However, i would have thought that when doing ml-estimation of a cfa, factor scores would be estimated as well? Wouldn't it be possible to store those values when doing the initial estimation? Just a thought, i am not too familiar with what happens under the hood of cfa-estimation.

Best, Hans

yrosseel

unread,
Nov 9, 2012, 3:47:33 AM11/9/12
to lav...@googlegroups.com
On 11/09/2012 09:33 AM, Dr. Hans Hansen wrote:
> Dear Yves,
>
> thanks for giving a example, but i was referring to volunteer to
> implement the predict method for fiml-cfa objects. Anyway, I might try
> the mice approach.
>
> However, i would have thought that when doing ml-estimation of a cfa,
> factor scores would be estimated as well?

No, they are 'integrated out', not computed. This usually requires
integration, except in the (common) case where both response and latent
variables are continuous.

Yves.

Dr. Hans Hansen

unread,
Nov 9, 2012, 3:59:31 AM11/9/12
to lav...@googlegroups.com
Ah, ok, interesting (but certainly wide beyond my scope of statistical knowledge)! Thanks!

Craig Waterman

unread,
May 30, 2013, 11:19:18 AM5/30/13
to lav...@googlegroups.com
I am using this factor scores function for my dissertation. I am sorry if this information is posted elsewhere. Is there a way I can find a brief explanation of how these scores are computed? There are several of different potential methods. Thank you.

yrosseel

unread,
May 30, 2013, 11:26:25 AM5/30/13
to lav...@googlegroups.com
On 05/30/2013 05:19 PM, Craig Waterman wrote:
> I am using this factor scores function for my dissertation. I am sorry
> if this information is posted elsewhere. Is there a way I can find a
> brief explanation of how these scores are computed?

See Appendix 11 in this document (from the Mplus website):

https://www.statmodel.com/download/techappen.pdf

Yves.

Margarita Olivera

unread,
Jun 27, 2016, 4:57:58 PM6/27/16
to lavaan
Dear Yves,

I want to save factor scores based on a multiple group analysis (measurement invariance). I was able to do it using the , and I get a List of 2, one for each group. 
However, I want to be able to merge this factor scores with other variables I have in the data set and since the objet with the factor scores does not contain any other info (id variable) I cannot merge the scores.
Any suggestion on how to do it? How to get the factor scores in a way that also saves the ID variables) or how to directly save them in the original object with all the variables? 

Thanks
Margarita

Terrence Jorgensen

unread,
Jun 30, 2016, 4:58:56 AM6/30/16
to lavaan
How to get the factor scores in a way that also saves the ID variables) or how to directly save them in the original object with all the variables? 

You can use the approach I described here:


Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Gloria Ma

unread,
Sep 23, 2017, 8:34:58 AM9/23/17
to lavaan
Dear Margarita,

I was also trying to save factor scores based on multi-group SEM. but I got an error when saving the scores. Do you mind sharing with me what your code is?

Thank you very much!

Gloria

在 2016年6月27日星期一 UTC+2下午10:57:58,Margarita Olivera写道:

Thomas Rockstuhl

unread,
May 21, 2018, 1:40:28 AM5/21/18
to lavaan
Dear Yves,

I am trying to computer factor scores from a bi-factor model (each item loading onto two factors - one general factor and a set of four orthogonal specific factors).

Although the predict(fit) saves factor scores, the scores themselves are still correlated, contrary to how the bi-factor model is specified. Do you have any suggestions for how to compute factor scores in this scenario?

Best,
Thomas 

Jeremy Miles

unread,
May 21, 2018, 3:59:30 PM5/21/18
to lav...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.
--
--
My employer has nothing to do with this email. 

Thomas Rockstuhl

unread,
May 23, 2018, 1:46:17 PM5/23/18
to lav...@googlegroups.com
Thanks Jeremy!
With best regards,

Thomas Rockstuhl, PhD
---------------------
Assistant Professor
Division of Strategy, Management & Organization
Nanyang Business School
S3-1C-96
Nanyang Technological University
Singapore 639798
+65 6790 6135

Reply all
Reply to author
Forward
0 new messages