简体   繁体   中英

Best way to tidy up factor structure/pattern matrix in R?

I'm looking for a way to quickly tidy up the factor structure/factor pattern matrix after performing exploratory factor analysis in R (package psych , function fa ). For example, after I run the analysis and after I look at the factor loadings by using:

fit.model.efa$loadings

What I get is this:

Loadings:
    ML1    ML4    ML3    ML2   
Q1          0.564              
Q2          0.721              
Q3   0.157  0.540  0.131 -0.114
Q4  -0.106  0.596              
Q5  -0.240  0.180  0.277       
Q6          0.169  0.367       
Q7                 0.855       
Q8                 0.814       
Q9         -0.123  0.841       
Q10         0.545  0.217       
Q11         0.552  0.116       
Q12  0.138  0.525         0.112
Q13  0.198  0.199  0.338       
Q14  0.264  0.155  0.342  0.150
Q15         0.474 -0.176  0.330
Q16         0.410         0.351
Q17         0.343  0.222  0.234
Q18  0.205  0.136  0.312  0.314
Q19  0.192  0.107  0.250  0.293
Q20  0.247  0.129  0.331  0.218
Q21  0.376         0.228  0.262
Q22  0.424  0.397         0.115
Q23  0.340  0.361              
Q24  0.398  0.255              
Q25  0.576                0.149
Q26  0.886                     
Q27  0.864                     
Q28  0.978                     
Q29  0.847                     
Q30  0.935 -0.110              
Q31  0.470         0.212  0.210
Q32  0.628         0.124  0.140
Q33         0.123         0.714
Q34                       0.978
Q35                       0.929

This is not really readable, so we can try the follwing:

fit.model.efa$loadings %>%
  print(sort = T, cutoff = .3)

This will give us the following output:

Loadings:
    ML1    ML4    ML3    ML2   
Q25  0.576                     
Q26  0.886                     
Q27  0.864                     
Q28  0.978                     
Q29  0.847                     
Q30  0.935                     
Q32  0.628                     
Q1          0.564              
Q2          0.721              
Q3          0.540              
Q4          0.596              
Q10         0.545              
Q11         0.552              
Q12         0.525              
Q7                 0.855       
Q8                 0.814       
Q9                 0.841       
Q33                       0.714
Q34                       0.978
Q35                       0.929
Q5                             
Q6                 0.367       
Q13                0.338       
Q14                0.342       
Q15         0.474         0.330
Q16         0.410         0.351
Q17         0.343              
Q18                0.312  0.314
Q19                            
Q20                0.331       
Q21  0.376                     
Q22  0.424  0.397              
Q23  0.340  0.361              
Q24  0.398                     
Q31  0.470 

However, I am still not happy with the output because what I want to see first are all the loadings of the first factor , followed by all the loadings of the second factor , followed by all the loadings of the third factor and at the end all the loadings of the fourth factor . Specifically, I want to see a matrix that looks like this:

Loadings:
    ML1    ML4    ML2    ML3   
Q25  0.576                     
Q26  0.886                     
Q27  0.864                     
Q28  0.978                     
Q29  0.847                     
Q30  0.935                     
Q32  0.628
Q21  0.376                     
Q24  0.398                     
Q31  0.470
Q22  0.424  0.397              
Q23  0.340  0.361                     
Q1          0.564              
Q2          0.721              
Q3          0.540              
Q4          0.596              
Q10         0.545              
Q11         0.552              
Q12         0.525
Q17         0.343
Q15         0.474  0.330       
Q16         0.410  0.351
Q33                0.714
Q34                0.978
Q35                0.929
Q18                0.314  0.312               
Q7                        0.855       
Q8                        0.814       
Q9                        0.841
Q6                        0.367       
Q13                       0.338       
Q14                       0.342
Q20                       0.331       
Q5                             
Q19                            

There we go. Nice, clean, easily readable and interpretable. ( Note that the columns of the 3rd and the 4th factor have been switched to allow this ). However, I would prefer it if I didn't have to do this manually. Is there a way to automatically have such an output? I tried using the broom package, but found nothing useful.

Perhaps I am missing something, but why wouldn't arrange() do it for you?

fit.model.efa$loadings %>%
  filter_all( any_vars( . > .3)) %>% # filter only .3 >
  arrange( ML1, ML4, ML2, ML3) # arrange columnwise

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM