library(efast) library(corrplot) library(GPArotation) options(width = 70) set.seed(45)
The lavaan
[^lavaan] syntax since version 0.6.4
allows for exploratory blocks for latent variables. The EFAST package builds on this functionality to combine exploratory latent variable models (such as EFA) with structural parameters (in EFAST the residual covariance structure). Here is how to create a basic 3-factor EFA model in lavaan
using the x1 - x9
variables from the famous Holzinger and Swineford data included in the lavaan
package:
data("HolzingerSwineford1939") efa_model <- " efa('block1')*F1 =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 efa('block1')*F2 =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 efa('block1')*F3 =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 "
The efa('block1')
modifier indicates that the factors F1
, F2
, and F3
comprise an exploratory block (with the name block1
) and thus that we do not exactly know the loading structure of the variables x1 - x9
on these three factors.
The EFA model can then be estimated as follows, (releasing the residual variances and implying the EFA constraints):
efa_hs39 <- lavaan( model = efa_model, data = HolzingerSwineford1939, auto.var = TRUE, auto.efa = TRUE )
In the results, among the parameter estimates we will see the pattern of factor loadings resulting from the oblique geomin rotation:
summary(efa_hs39)
In this summary, we can see that the geomin rotation has produced the structure we expect for this data: the first factor is most associated with the first three variables, the second with x4 - x6
, and the last three variables load mostly on the third factor.
This is also the same structure we get when we run an oblique geomin-rotated exploratory factor analysis using the same data in the psych
package (except for the ordering of the factors):
efa_psych <- psych::fa(r = HolzingerSwineford1939[, 7:15], nfactors = 3, rotate = "geominQ") loadings(efa_psych)
The EFAST package implements this exact pattern, and allows for extracting the loadings similar to the psych
package:
efa_efast <- efast_efa(data = HolzingerSwineford1939[, 7:15], M = 3) efast_loadings(efa_efast)
Bonus: a shorter way to write the same syntax would be:
efa('block1')*F1 + efa('block1')*F2 + efa('block1')*F3 =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9
which is how the EFAST package works (see Extending EFAST models).
[^lavaan]: Yves Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. URL http://www.jstatsoft.org/v48/i02/.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.