View source: R/makeCorrLoadings.R
| makeCorrLoadings | R Documentation |
Constructs an inter-item correlation matrix based on a user-supplied
matrix of standardised factor loadings and (optionally) a factor
correlation matrix.
The makeCorrLoadings() function does a surprisingly good job of
reproducing a target correlation matrix when all item-factor loadings
are present, as shown in the makeCorrLoadings() validation article.
makeCorrLoadings(
loadings,
factorCor = NULL,
uniquenesses = NULL,
nearPD = FALSE,
diagnostics = FALSE
)
loadings |
Numeric matrix. A |
factorCor |
Optional |
uniquenesses |
Optional vector of length k. If NULL, calculated
as |
nearPD |
Logical.
If |
diagnostics |
Logical.
If |
If diagnostics = FALSE, returns a correlation matrix (class: matrix). If diagnostics = TRUE, returns a list with: - R: correlation matrix - Omega: per-factor Omega or adjusted Omega - OmegaTotal: total Omega across all factors - Diagnostics: dataframe of communalities, uniquenesses, and primary factor
makeCorrLoadings() validation article: https://winzarh.github.io/LikertMakeR/articles/makeCorrLoadings_validate.html
Package website: https://winzarh.github.io/LikertMakeR/
# --------------------------------------------------------
# Example 1: Basic use without diagnostics
# --------------------------------------------------------
factorLoadings <- matrix(
c(
0.05, 0.20, 0.70,
0.10, 0.05, 0.80,
0.05, 0.15, 0.85,
0.20, 0.85, 0.15,
0.05, 0.85, 0.10,
0.10, 0.90, 0.05,
0.90, 0.15, 0.05,
0.80, 0.10, 0.10
),
nrow = 8, ncol = 3, byrow = TRUE
)
rownames(factorLoadings) <- paste0("Q", 1:8)
colnames(factorLoadings) <- c("Factor1", "Factor2", "Factor3")
factorCor <- matrix(
c(
1.0, 0.7, 0.6,
0.7, 1.0, 0.4,
0.6, 0.4, 1.0
),
nrow = 3, byrow = TRUE
)
itemCor <- makeCorrLoadings(factorLoadings, factorCor)
round(itemCor, 3)
# --------------------------------------------------------
# Example 2: Diagnostics with factor correlations (Adjusted Omega)
# --------------------------------------------------------
result_adj <- makeCorrLoadings(
loadings = factorLoadings,
factorCor = factorCor,
diagnostics = TRUE
)
# View outputs
round(result_adj$R, 3) # correlation matrix
round(result_adj$Omega, 3) # adjusted Omega
round(result_adj$OmegaTotal, 3) # total Omega
print(result_adj$Diagnostics) # communality and uniqueness per item
# --------------------------------------------------------
# Example 3: Diagnostics assuming orthogonal factors (Per-Factor Omega)
# --------------------------------------------------------
result_orth <- makeCorrLoadings(
loadings = factorLoadings,
diagnostics = TRUE
)
round(result_orth$Omega, 3) # per-factor Omega
round(result_orth$OmegaTotal, 3) # total Omega
print(result_orth$Diagnostics)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.