
Conversion between EFA results and CFA structure
Source:R/convert_efa_to_cfa.R
convert_efa_to_cfa.Rd
Enables a conversion between Exploratory Factor Analysis (EFA) and
Confirmatory Factor Analysis (CFA) lavaan
-ready structure.
Usage
convert_efa_to_cfa(model, ...)
# S3 method for fa
convert_efa_to_cfa(model, threshold = "max", names = NULL, ...)
efa_to_cfa(model, ...)
Arguments
- model
An EFA model (e.g., a
psych::fa
object).- ...
Arguments passed to or from other methods.
- threshold
A value between 0 and 1 indicates which (absolute) values from the loadings should be removed. An integer higher than 1 indicates the n strongest loadings to retain. Can also be
"max"
, in which case it will only display the maximum loading per variable (the most simple structure).- names
Vector containing dimension names.
Examples
# \donttest{
library(parameters)
if (require("psych") && require("lavaan")) {
efa <- psych::fa(attitude, nfactors = 3)
model1 <- efa_to_cfa(efa)
model2 <- efa_to_cfa(efa, threshold = 0.3)
suppressWarnings(anova(
lavaan::cfa(model1, data = attitude),
lavaan::cfa(model2, data = attitude)
))
}
#> Loading required package: psych
#>
#> Attaching package: ‘psych’
#> The following object is masked from ‘package:mclust’:
#>
#> sim
#> The following objects are masked from ‘package:ggplot2’:
#>
#> %+%, alpha
#> The following object is masked from ‘package:boot’:
#>
#> logit
#> Loading required package: lavaan
#> This is lavaan 0.6-15
#> lavaan is FREE software! Please report any bugs.
#>
#> Attaching package: ‘lavaan’
#> The following object is masked from ‘package:psych’:
#>
#> cor2cov
#> Loading required namespace: GPArotation
#>
#> Chi-Squared Difference Test
#>
#> Df AIC BIC Chisq Chisq diff RMSEA
#> lavaan::cfa(model2, data = attitude) 10 1540.5 1565.7 9.1827
#> lavaan::cfa(model1, data = attitude) 12 1549.8 1572.2 22.4374 13.255 0.4331
#> Df diff Pr(>Chisq)
#> lavaan::cfa(model2, data = attitude)
#> lavaan::cfa(model1, data = attitude) 2 0.001324 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# }