Skip to contents

The EFAtools package performs exploratory factor analysis (EFA) and compares EFA solutions. It offers current factor retention methods and many estimation, rotation, and correlation options. The package implements core iterative procedures, including principal axis factoring (PAF), rotation, and polychoric correlation estimation, in C++ to increase speed.

Installation

You can install the release version from CRAN with:

install.packages("EFAtools")

You can install the development version from GitHub with:

# install.packages("pak")
pak::pak("mdsteiner/EFAtools")

Package Overview

The efa_* functions cover the steps of an EFA workflow:

The uppercase names of the older package versions (EFA(), N_FACTORS(), …) still work and keep their arguments. Use the efa_* names for new code.

The following vignettes and articles cover these in detail:

Examples

The following examples show some EFAtools functions.

# load the package
library(EFAtools)

Factor Retention

Use efa_retain() to find how many factors to retain. It runs several factor retention criteria in a single call. It also checks with Bartlett’s test and the KMO whether your data are suitable for factor analysis.

With raw data, efa_retain() runs all its default criteria:


# Run multiple factor retention methods
efa_retain(GRiPS_raw)
#> ── Sampling adequacy and sphericity ────────────────────────────────────────────
#> 
#> ✔ Overall KMO = 0.955: marvellous (Kaiser & Rice, 1974).
#> ✔ Bartlett's test of sphericity: χ²(28) = 5054.06, p < .001 (significant).
#> 
#> ── Suggested number of factors ─────────────────────────────────────────────────
#> 
#> 7 suggestions from 6 criteria, all suggesting 1 factor.
#> 
#> Comparison data
#> • Suggested number of factors: 1
#> 
#> Empirical Kaiser Criterion
#> • Braeken & van Assen (2017): 1
#> 
#> Hull method
#> Estimator: ML
#> • CAF: 1
#> 
#> Minimum average partial
#> • Original implementation (TR2): 1
#> • Revised implementation (TR4): 1
#> 
#> Next Eigenvalue Sufficiency Test
#> • Suggested number of factors: 1
#> 
#> Parallel analysis
#> Eigenvalues found using PCA; 1000 simulated datasets.
#> • PCA: 1

With a correlation matrix, efa_retain() skips the criteria that need raw data:


efa_retain(DOSPERT$cormat, N = DOSPERT$N)
#> ── Sampling adequacy and sphericity ────────────────────────────────────────────
#> 
#> ✔ Overall KMO = 0.9: meritorious (Kaiser & Rice, 1974).
#> ✔ Bartlett's test of sphericity: χ²(780) = 16071.13, p < .001 (significant).
#> 
#> ── Suggested number of factors ─────────────────────────────────────────────────
#> 
#> 6 suggestions from 5 criteria, ranging from 1 to 10 factors (most common: 10).
#> 
#> Empirical Kaiser Criterion
#> • Braeken & van Assen (2017): 10
#> 
#> Hull method
#> Estimator: ML
#> • CAF: 1
#> 
#> Minimum average partial
#> • Original implementation (TR2): 5
#> • Revised implementation (TR4): 6
#> 
#> Next Eigenvalue Sufficiency Test
#> • Suggested number of factors: 10
#> 
#> Parallel analysis
#> Eigenvalues found using PCA; 1000 simulated datasets.
#> • PCA: 7
#> 
#> ── Criteria not run ────────────────────────────────────────────────────────────
#> 
#> • CD: needs raw data, but a correlation matrix was supplied

Here the criteria disagree. The Hull method suggests one factor. The first factor improves its fit index (the CAF) much more than each further factor does, so the elbow of the fit curve is at one factor. When the criteria disagree, compare several of them and use your judgement (see the EFAtools vignette).

EFA

Raw-Data Input

With raw data, you can use every feature: sandwich and bootstrap standard errors, DWLS estimation with polychoric correlations, and two-stage FIML estimation of correlations.

In the first example below, which uses bootstrap SEs (se = "np-boot"), the confidence intervals are percentile intervals over refitted resamples. summary() shows them for the loadings and factor correlations. For CFI and TLI, print() shows bootstrap intervals from cases transformed so that their misfit equals the estimated misfit (Yuan, Hayashi, & Yanagihara, 2007; see ?efa_fit). Without this transformation, each resample adds sampling misfit to the misfit the sample already has, and the intervals move toward worse fit.


# ULS / MINRES estimation with (the default) oblimin rotation and bootstrap SEs
mod <- efa_fit(DOSPERT_raw, n_factors = 5, estimator = "uls",
               se = "np-boot", seed = 1)
mod
#> 
#> EFA performed with estimator = 'ULS' and rotation = 'oblimin' (N = 3123).
#> 
#> ── Rotated Loadings ────────────────────────────────────────────────────────────
#> 
#>           F1     F2     F3     F4     F5    h2    u2
#> ethR_1   .513  -.018   .030  -.016   .130  .309  .691
#> ethR_2   .518  -.044   .078   .019   .045  .304  .696
#> ethR_3   .639  -.001   .024  -.223   .081  .490  .510
#> ethR_4   .586  -.122  -.050  -.060   .046  .295  .705
#> ethR_5   .477   .065  -.010  -.127   .032  .267  .733
#> ethR_6   .621  -.098  -.007  -.016  -.021  .345  .655
#> finR_1  -.004  -.005   .841  -.021   .025  .717  .283
#> finR_2  -.066   .029  -.045   .068   .688  .476  .524
#> finR_3  -.005  -.013   .856   .010   .016  .730  .270
#> finR_4   .072   .041   .090  -.040   .710  .600  .400
#> finR_5  -.005  -.029   .873   .000   .040  .768  .232
#> finR_6   .054   .064   .093   .085   .683  .599  .401
#> heaR_1   .426   .087   .101   .087  -.036  .273  .727
#> heaR_2   .453   .053   .050   .136  -.050  .262  .738
#> heaR_3   .415   .130   .071   .019  -.052  .257  .743
#> heaR_4   .362   .163   .123  -.015  -.066  .254  .746
#> heaR_5   .382   .091  -.019   .123  -.057  .185  .815
#> heaR_6   .430   .206   .026   .138   .003  .338  .662
#> recR_1   .017   .407  -.035   .217   .026  .254  .746
#> recR_2   .117   .531   .111  -.101   .038  .410  .590
#> recR_3   .060   .619   .026   .003   .054  .452  .548
#> recR_4  -.072   .861  -.033  -.059   .027  .682  .318
#> recR_5  -.008   .805   .013  -.091  -.003  .628  .372
#> recR_6  -.020   .637   .031   .025   .102  .467  .533
#> socR_1  -.029  -.085  -.071   .646  -.004  .419  .581
#> socR_2   .093  -.027   .031   .679   .039  .474  .526
#> socR_3  -.133  -.058   .018   .640  -.005  .416  .584
#> socR_4  -.004   .018   .032   .614   .007  .383  .617
#> socR_5   .049   .103  -.045   .379   .051  .185  .815
#> socR_6   .004  -.008   .016   .549   .041  .308  .692
#> 
#> ── Factor Intercorrelations ────────────────────────────────────────────────────
#> 
#>       F1     F2     F3     F4     F5
#> F1  1.000
#> F2   .372  1.000
#> F3   .448   .319  1.000
#> F4   .006   .200  -.042  1.000
#> F5   .154   .290   .344   .145  1.000
#> 
#> ── Variances Accounted for ─────────────────────────────────────────────────────
#> 
#>                      F1     F2     F3     F4     F5
#> SS loadings        3.163  2.940  2.457  2.323  1.664
#> Prop Tot Var        .105   .098   .082   .077   .055
#> Cum Prop Tot Var    .105   .203   .285   .363   .418
#> Prop Comm Var       .252   .234   .196   .185   .133
#> Cum Prop Comm Var   .252   .486   .682   .867  1.000
#> 
#> ── Model Fit ───────────────────────────────────────────────────────────────────
#> 
#> χ²(295) = 3604.56, p < .001
#> CFI [95% bootstrap CI]: .90 [.88; .91]
#> TLI [95% bootstrap CI]: .85 [.83; .86]
#> RMSEA [90% CI]: .06 [.06; .06]
#> SRMR: .03
# detailed output with summary()
summary(mod)
#> 
#> EFA performed with estimator = 'ULS' and rotation = 'oblimin' (N = 3123).
#> 
#> ── Model Diagnostics ───────────────────────────────────────────────────────────
#> 
#> N: 3123
#> Bootstrap samples: 1000
#> Valid target-rotated samples: 1000 out of 1000
#> Rotation local optima: 1 distinct from 101 starts
#> Heywood cases: 0
#> Factor intercorrelations > .85: none
#> 
#> ── Rotated Loadings ────────────────────────────────────────────────────────────
#> 
#>           F1     F2     F3     F4     F5    h2    u2
#> ethR_1   .513  -.018   .030  -.016   .130  .309  .691
#> ethR_2   .518  -.044   .078   .019   .045  .304  .696
#> ethR_3   .639  -.001   .024  -.223   .081  .490  .510
#> ethR_4   .586  -.122  -.050  -.060   .046  .295  .705
#> ethR_5   .477   .065  -.010  -.127   .032  .267  .733
#> ethR_6   .621  -.098  -.007  -.016  -.021  .345  .655
#> finR_1  -.004  -.005   .841  -.021   .025  .717  .283
#> finR_2  -.066   .029  -.045   .068   .688  .476  .524
#> finR_3  -.005  -.013   .856   .010   .016  .730  .270
#> finR_4   .072   .041   .090  -.040   .710  .600  .400
#> finR_5  -.005  -.029   .873   .000   .040  .768  .232
#> finR_6   .054   .064   .093   .085   .683  .599  .401
#> heaR_1   .426   .087   .101   .087  -.036  .273  .727
#> heaR_2   .453   .053   .050   .136  -.050  .262  .738
#> heaR_3   .415   .130   .071   .019  -.052  .257  .743
#> heaR_4   .362   .163   .123  -.015  -.066  .254  .746
#> heaR_5   .382   .091  -.019   .123  -.057  .185  .815
#> heaR_6   .430   .206   .026   .138   .003  .338  .662
#> recR_1   .017   .407  -.035   .217   .026  .254  .746
#> recR_2   .117   .531   .111  -.101   .038  .410  .590
#> recR_3   .060   .619   .026   .003   .054  .452  .548
#> recR_4  -.072   .861  -.033  -.059   .027  .682  .318
#> recR_5  -.008   .805   .013  -.091  -.003  .628  .372
#> recR_6  -.020   .637   .031   .025   .102  .467  .533
#> socR_1  -.029  -.085  -.071   .646  -.004  .419  .581
#> socR_2   .093  -.027   .031   .679   .039  .474  .526
#> socR_3  -.133  -.058   .018   .640  -.005  .416  .584
#> socR_4  -.004   .018   .032   .614   .007  .383  .617
#> socR_5   .049   .103  -.045   .379   .051  .185  .815
#> socR_6   .004  -.008   .016   .549   .041  .308  .692
#> 
#> ── 95% bootstrap CIs for salient rotated loadings ──────────────────────────────
#> 
#> Variable  Factor  est    lower  upper
#> ethR_1    F1       .513   .465   .553
#> ethR_2    F1       .518   .472   .558
#> ethR_3    F1       .639   .589   .677
#> ethR_4    F1       .586   .532   .630
#> ethR_5    F1       .477   .431   .523
#> ethR_6    F1       .621   .572   .662
#> heaR_1    F1       .426   .381   .472
#> heaR_2    F1       .453   .407   .497
#> heaR_3    F1       .415   .361   .472
#> heaR_4    F1       .362   .306   .419
#> heaR_5    F1       .382   .326   .435
#> heaR_6    F1       .430   .382   .475
#> recR_1    F2       .407   .366   .447
#> recR_2    F2       .531   .487   .572
#> recR_3    F2       .619   .578   .654
#> recR_4    F2       .861   .825   .891
#> recR_5    F2       .805   .771   .835
#> recR_6    F2       .637   .600   .669
#> finR_1    F3       .841   .801   .868
#> finR_3    F3       .856   .819   .881
#> finR_5    F3       .873   .837   .899
#> socR_1    F4       .646   .612   .680
#> socR_2    F4       .679   .648   .708
#> socR_3    F4       .640   .602   .674
#> socR_4    F4       .614   .581   .648
#> socR_5    F4       .379   .339   .418
#> socR_6    F4       .549   .511   .587
#> finR_2    F5       .688   .646   .723
#> finR_4    F5       .710   .667   .740
#> finR_6    F5       .683   .642   .715
#> 
#> ── Factor Intercorrelations ────────────────────────────────────────────────────
#> 
#>       F1     F2     F3     F4     F5
#> F1  1.000
#> F2   .372  1.000
#> F3   .448   .319  1.000
#> F4   .006   .200  -.042  1.000
#> F5   .154   .290   .344   .145  1.000
#> 
#> ── 95% bootstrap CIs for factor intercorrelations ──────────────────────────────
#> 
#> Factors   est    lower  upper
#> F1 ~~ F2   .372   .327   .405
#> F1 ~~ F3   .448   .400   .481
#> F1 ~~ F4   .006  -.037   .049
#> F1 ~~ F5   .154   .108   .196
#> F2 ~~ F3   .319   .270   .359
#> F2 ~~ F4   .200   .160   .236
#> F2 ~~ F5   .290   .241   .326
#> F3 ~~ F4  -.042  -.082   .002
#> F3 ~~ F5   .344   .293   .373
#> F4 ~~ F5   .145   .098   .185
#> 
#> ── Structure Matrix ────────────────────────────────────────────────────────────
#> 
#>           F1    F2     F3     F4    F5
#> ethR_1   .540  .217   .299   .001  .212
#> ethR_2   .543  .190   .310   .017  .142
#> ethR_3   .661  .223   .348  -.209  .155
#> ethR_4   .525  .081   .192  -.072  .075
#> ethR_5   .500  .223   .240  -.106  .102
#> ethR_6   .578  .121   .233  -.035  .042
#> finR_1   .374  .265   .846  -.054  .309
#> finR_2   .031  .203   .168   .175  .681
#> finR_3   .376  .265   .854  -.027  .307
#> finR_4   .237  .294   .382   .068  .759
#> finR_5   .382  .260   .875  -.037  .331
#> finR_6   .225  .329   .369   .193  .754
#> heaR_1   .499  .284   .303   .097  .102
#> heaR_2   .488  .250   .247   .140  .072
#> heaR_3   .487  .296   .279   .037  .077
#> heaR_4   .467  .315   .315   .005  .077
#> heaR_5   .399  .235   .156   .136  .039
#> heaR_6   .519  .402   .279   .181  .158
#> recR_1   .158  .453   .103   .304  .166
#> recR_2   .370  .601   .350   .007  .234
#> recR_3   .310  .666   .269   .134  .252
#> recR_4   .237  .820   .221   .118  .246
#> recR_5   .297  .787   .270   .069  .221
#> recR_6   .247  .674   .260   .165  .298
#> socR_1  -.089  .010  -.140   .631  .036
#> socR_2   .107  .164   .049   .678  .155
#> socR_3  -.143  .025  -.089   .626  .057
#> socR_4   .022  .152   .013   .617  .111
#> socR_5   .078  .197   .012   .409  .128
#> socR_6   .018  .120   .006   .553  .124
#> 
#> ── Simple Structure Diagnostics ────────────────────────────────────────────────
#> 
#> Items with primary-loading gap < .200:
#> • heaR_4: F1 = .362, F2 = .163
#> • recR_1: F2 = .407, F4 = .217
#> 
#> 
#> ── Variances Accounted for ─────────────────────────────────────────────────────
#> 
#>                      F1     F2     F3     F4     F5
#> SS loadings        3.163  2.940  2.457  2.323  1.664
#> Prop Tot Var        .105   .098   .082   .077   .055
#> Cum Prop Tot Var    .105   .203   .285   .363   .418
#> Prop Comm Var       .252   .234   .196   .185   .133
#> Cum Prop Comm Var   .252   .486   .682   .867  1.000
#> 
#> ── Model Fit ───────────────────────────────────────────────────────────────────
#> 
#> χ²(295) = 3604.56, p < .001
#> CFI [95% bootstrap CI]: .90 [.88; .91]
#> TLI [95% bootstrap CI]: .85 [.83; .86]
#> RMSEA [90% CI]: .06 [.06; .06]
#> SRMR: .03
#> AIC: 3014.56
#> BIC: 1230.83
#> ECVI: 1.26
#> 
#> Note: Bootstrap CIs based on 1000 bootstrap samples.
#> 
#> ── Residual Diagnostics ────────────────────────────────────────────────────────
#> 
#> Residual cutoff: |r| > .100
#> Number of large residuals: 7
#> Largest absolute residual: .246
#> 
#> Largest residuals:
#> • heaR_3 ~~ heaR_4: .246
#> • socR_5 ~~ socR_6: .190
#> • socR_2 ~~ socR_4: .145
#> • recR_4 ~~ recR_5: .138
#> • heaR_1 ~~ heaR_2: .135
#> • recR_2 ~~ recR_3: .126
#> • recR_1 ~~ recR_3: .112
#> 
#> Inspect the residual matrix for details (e.g., with residuals()).

# DWLS estimation based on polychoric correlations, with robust sandwich SEs
mod <- efa_fit(GRiPS_raw, n_factors = 1, estimator = "dwls", cor_method = "poly",
               se = "sandwich")
mod
#> 
#> EFA performed with estimator = 'DWLS' and rotation = 'none'
#>   (polychoric correlations, N = 810).
#> 
#> ── Unrotated Loadings ──────────────────────────────────────────────────────────
#> 
#>             F1    h2    u2
#> fun        .818  .669  .331
#> friends    .855  .731  .269
#> enjoy      .893  .797  .203
#> hurt       .775  .601  .399
#> part       .824  .679  .321
#> commonly   .843  .711  .289
#> chances    .817  .668  .332
#> attracted  .859  .738  .262
#> 
#> ── Variances Accounted for ─────────────────────────────────────────────────────
#> 
#>                 F1
#> SS loadings   5.594
#> Prop Tot Var   .699
#> 
#> ── Model Fit ───────────────────────────────────────────────────────────────────
#> 
#> scaled χ²(20) = 237.21, p < .001
#> CFI (robust): .98
#> TLI (robust): .98
#> RMSEA (robust) [90% CI]: .07 [.06; .08]
#> SRMR: .02
# summary(mod) shows the confidence intervals

Correlation Input

When you do not have raw data, you can enter a correlation matrix and sample size instead. With ML estimation, you can still get information-based SEs (from the expected information matrix), but these assume multivariate normality.


# ML estimation with oblimin rotation and information SEs, based on correlation
# matrix and N
mod <- efa_fit(test_models$baseline$cormat, N = 500,  n_factors = 3, estimator = "ml",
           rotation = "oblimin", se = "information")
mod
#> 
#> EFA performed with estimator = 'ML' and rotation = 'oblimin' (N = 500).
#> 
#> ── Rotated Loadings ────────────────────────────────────────────────────────────
#> 
#>        F1     F2     F3    h2    u2
#> V1   -.036   .043   .607  .373  .627
#> V2    .013   .087   .458  .274  .726
#> V3    .074   .074   .430  .280  .720
#> V4    .111   .007   .536  .379  .621
#> V5    .164   .005   .418  .290  .710
#> V6   -.055  -.036   .687  .402  .598
#> V7    .017   .524   .095  .355  .645
#> V8   -.003   .562   .044  .345  .655
#> V9    .044   .535   .017  .328  .672
#> V10  -.019   .661  -.051  .385  .615
#> V11   .030   .352   .230  .296  .704
#> V12   .034   .649  -.015  .437  .563
#> V13   .612   .095  -.068  .397  .603
#> V14   .540  -.053   .086  .320  .680
#> V15   .552   .137  -.065  .363  .637
#> V16   .550  -.039   .092  .345  .655
#> V17   .652  -.035  -.013  .390  .610
#> V18   .549   .012   .052  .349  .651
#> 
#> ── Factor Intercorrelations ────────────────────────────────────────────────────
#> 
#>       F1     F2     F3
#> F1  1.000
#> F2   .591  1.000
#> F3   .621   .596  1.000
#> 
#> ── Variances Accounted for ─────────────────────────────────────────────────────
#> 
#>                      F1     F2     F3
#> SS loadings        2.225  2.088  1.994
#> Prop Tot Var        .124   .116   .111
#> Cum Prop Tot Var    .124   .240   .350
#> Prop Comm Var       .353   .331   .316
#> Cum Prop Comm Var   .353   .684  1.000
#> 
#> ── Model Fit ───────────────────────────────────────────────────────────────────
#> 
#> χ²(102) = 123.75, p = .070
#> CFI: .99
#> TLI: .98
#> RMSEA [90% CI]: .02 [.00; .03]
#> SRMR: .03
# summary(mod) shows the confidence intervals

Citation

If you use this package in your research, please acknowledge it by citing:

Steiner, M.D., & Grieder, S.G. (2020). EFAtools: An R package with fast and flexible implementations of exploratory factor analysis tools. Journal of Open Source Software, 5(53), 2521. https://doi.org/10.21105/joss.02521

Contribute or Report Bugs

If you want to contribute or report bugs, please open an issue on GitHub or email us at or .