
Loadings of a multilevel factor analysis as a parameters table
Source:R/fa_multilevel.R
model_parameters.experdyn_fa_multilevel.RdMethods for parameters::model_parameters(), returning the loadings of
fa_multilevel() in the same format as parameters::factor_analysis()
(an object of class parameters_efa). The result can then be used with
the usual easystats tools: printing (with threshold, sort,
labels), summary() (variance explained and factor correlations),
predict() (factor scores), parameters::closest_component(),
parameters::convert_efa_to_cfa(), and plot() from the see
package (type = "bar", "line" or "graph").
Usage
# S3 method for class 'experdyn_fa_multilevel'
model_parameters(
model,
sort = FALSE,
threshold = NULL,
labels = NULL,
verbose = TRUE,
...
)
# S3 method for class 'experdyn_fa_multilevel_comparison'
model_parameters(model, ...)Arguments
- model
An object returned by
fa_multilevel().- sort
[logical(1): FALSE]
Sort the items by their main factor.- threshold
[numeric(1), "max" or NULL: NULL]
Loadings below this (absolute) value are hidden when printing;"max"only shows the highest loading of each item.- labels
[character or NULL: NULL]
Labels for the items (e.g., the questions), added as aLabelcolumn.- verbose
[logical(1): TRUE]
Toggle warnings.- ...
Passed to
parameters::model_parameters().
Value
A data frame of class parameters_efa, with one row per item: the
loadings on each factor, the item Complexity (Hofmann's index) and its
Uniqueness.
Details
As in the print method of fa_multilevel(), the loadings, uniquenesses
and variance explained are within-level quantities when random is
used (relative to the observation-level variance of each item, once the
differences between groups are removed).
predict() without newdata returns the factor scores (one row per row of
the original data, NA for rows with all items missing). Scores for new
data are not available. The fa_multilevel() object is stored in the
model attribute.
For a comparison of several numbers of factors (nfactors = 1:4), the
parameters of the best solution ($best) are returned.
Examples
# \donttest{
if (requireNamespace("glmmTMB", quietly = TRUE) &&
requireNamespace("GPArotation", quietly = TRUE) &&
requireNamespace("parameters", quietly = TRUE)) {
set.seed(1)
L <- cbind(c(.8, .7, .6, 0, 0, 0), c(0, 0, 0, .8, .7, .6))
d <- do.call(rbind, lapply(1:30, function(i) {
f <- matrix(rnorm(30 * 2), 30, 2)
y <- f %*% t(L) + matrix(rnorm(30 * 6, sd = .6), 30, 6)
y <- sweep(y, 2, rnorm(6, sd = .7), `+`)
data.frame(Participant = i, Prompt = 1:30, y)
}))
efa <- fa_multilevel(
d,
nfactors = 2,
random = ~ (1 | Participant),
items = paste0("X", 1:6),
verbose = FALSE
)
loadings <- parameters::model_parameters(efa, sort = TRUE, threshold = 0.3)
print(loadings)
print(summary(loadings))
print(head(predict(loadings))) # factor scores
if (requireNamespace("see", quietly = TRUE)) {
print(plot(loadings))
}
}
#> # Rotated loadings from Factor Analysis (oblimin-rotation)
#>
#> Variable | F1 | F2 | Complexity | Uniqueness
#> ------------------------------------------------
#> X4 | 0.81 | | 1.00 | 0.34
#> X5 | 0.75 | | 1.00 | 0.44
#> X6 | 0.69 | | 1.00 | 0.52
#> X1 | | 0.82 | 1.00 | 0.32
#> X2 | | 0.75 | 1.00 | 0.44
#> X3 | | 0.67 | 1.01 | 0.56
#>
#> The 2 latent factors (oblimin rotation) accounted for 56.52% of the total variance of the original data (F1 = 28.49%, F2 = 28.03%).
#> # (Explained) Variance of Components
#>
#> Parameter | F1 | F2
#> -----------------------------------------------
#> Eigenvalues | 1.725 | 1.666
#> Variance Explained | 0.285 | 0.280
#> Variance Explained (Cumulative) | 0.285 | 0.565
#> Variance Explained (Proportion) | 0.504 | 0.496
#>
#> # Factor Correlations
#>
#> Factor | F1 | F2
#> ----------------------
#> F1 | 1.000 | 0.025
#> F2 | 0.025 | 1.000
#> F1 F2
#> 1 0.80337441 0.0221792
#> 2 0.04801586 0.6121435
#> 3 0.06353698 -0.2377482
#> 4 -0.99414379 1.4109547
#> 5 -1.36422762 0.3557540
#> 6 -0.53137200 -0.3702923
# }