efaUnrotate speed and oblqRotate factor order

111 views
Skip to first unread message

yleni...@gmail.com

unread,
Mar 12, 2016, 10:22:58 AM3/12/16
to lavaan
Hi,

I wanted to report a couple of (potential) bugs. It looks like the efaUnrotate function takes a very long time, especially with more than 2 factors and more than 8 items. For example, I tried it with 12 items and 4 factors (and N=200) and as you can see it took much much longer than factanal.  

> system.time(efaUnrotate(mydata, nf=4, estimator="MLR"))
user  system elapsed 
10.007   0.173  10.449 
> system.time(factanal(mydata, factors=4))
user  system elapsed 
0.018   0.000   0.019 

With 40 items, the difference was even greater (efaUnrotate was over 2,000 times slower).

> system.time(efaUnrotate(mydata, nf=4, estimator="MLR"))
user  system elapsed 
166.939   2.800 174.268 
> system.time(factanal(mydata, factors=4))
user  system elapsed 
0.049   0.001   0.086 


The second thing is that, in all the programs I've used to date, the factors are ordered by the size of their eigenvalues, in descending order. So the first factor explains the most variance, and the remaining factors explain progressively less variance. It's also like that in factanal. However, in oblqRotate the order of the factors seems to be random. 

Despite these minor things, I must say that I am finding the efa functions very useful and I want to thank you for all your work!

All the best,
Ylenio

Sunthud Pornprasertmanit

unread,
Mar 15, 2016, 11:03:48 PM3/15/16
to lavaan
It is not a real bug per se. I realize that it is very annoying. The speed is a real issue. The function is implemented by writing a lavaan syntax to run unrotated EFA. Actually, I used the results from factanal as starting values. It could be slow but the efaUnrotate function provides SE which could take some time. If you have any suggestions, please let me know.

I will try to check whether I can swap the order of factors based on the size of eigenvalues.

Thanks for your feedback!

Sunthud

--
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.

yleni...@gmail.com

unread,
Mar 16, 2016, 4:02:20 AM3/16/16
to lavaan
Thank you for your reply. That's good to know. 

With regards to efaUnrotate, would it help if this ran without estimating the standard errors? Often people do several EFAs to explore the structure of the data and may not be too concerned about the SE in these initial stages. I'm not sure if that's feasible, but it's just an idea.

Thank you for all your work!

Ylenio

Terrence Jorgensen

unread,
Mar 16, 2016, 7:07:17 AM3/16/16
to lavaan
With regards to efaUnrotate, would it help if this ran without estimating the standard errors? 

You can do that, Ylenio.  The whole point of using semTools::efaUnrotate() instead of stats::factanal() or psych::fa() is that you get all the benefits of using lavaan, including passing any arguments to cfa(), such as specifying se = "none".  See the help pages for more information:

?efaUnrotate
?cfa

Terry

yleni...@gmail.com

unread,
Mar 16, 2016, 7:17:30 AM3/16/16
to lavaan
Thanks Terry. You're right, but unfortunately it doesn't seem to alter the time that much:

> system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="MLR"))
   user  system elapsed 
  46.55    0.00   47.00 
> system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="MLR", se="none"))
   user  system elapsed 
  46.13    0.02   46.94 

In any case, it's far from being a deal breaker. The function itself is great. Hopefully, it will also get a bit faster in future updates (and I need to get a faster computer!).

Cheers,
Ylenio 

yrosseel

unread,
Mar 25, 2016, 2:35:28 PM3/25/16
to lav...@googlegroups.com
On 03/16/2016 12:17 PM, yleni...@gmail.com wrote:
> Thanks Terry. You're right, but unfortunately it doesn't seem to alter
> the time that much:
>
> > system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="MLR"))
> user system elapsed
> 46.55 0.00 47.00
> > system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="MLR", se="none"))

What about estimator="ML" (not MLR), test = "none", se = "none"

Yves.

yleni...@gmail.com

unread,
Apr 3, 2016, 10:00:44 PM4/3/16
to lavaan
I'm currently using an old macbook pro, so everything is slower than the output above. However, if we simply compare different methods and functions using this laptop, efaUnrotate doesn't seem to get much faster:

> system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="MLR"))
   user  system elapsed 
193.712   2.930 169.296 
> system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="MLR", test = "none", se = "none"))
   user  system elapsed 
146.835   1.119 150.979 
> system.time(efaUnrotate(bfi[,1:25], nf=5, estimator="ML", test = "none", se = "none"))
   user  system elapsed 
153.739   1.680 164.960 

#compare these times to a different function
> system.time(fa(bfi[,1:25], nfactors=5))
   user  system elapsed 
  0.394   0.007   0.401 


Again, it's not the end of the world, and the efaUnrotate function is very useful. But it would help if it was faster. Especially when running large simulations.

Best,
Ylenio
Reply all
Reply to author
Forward
0 new messages