makeCorrLoadings()
generates a correlation matrix of
inter-item correlations based on item factor loadings as might be seen in
Exploratory Factor Analysis (EFA) or a Structural Equation Model
(SEM).
Such a correlation matrix can be applied to the makeItems()
function to generate synthetic data with those predefined factor structures.
Arguments
- loadings
(numeric matrix) k (items) by f (factors) matrix of standardised factor loadings. Item names and Factor names are taken from the row_names (items) and the column_names (factors), if present.
@note "Censored" loadings (for example, where loadings less than '0.30' are removed for clarity) tend to severely reduce the accuracy of the
makeCorrLoadings()
function. For a detailed demonstration, see the file makeCorrLoadings_Validate.pdf in the package website on GitHub.- factorCor
(numeric matrix) f x f factor correlation matrix
- uniquenesses
(numeric vector) length k vector of uniquenesses. If NULL, the default, compute from the calculated communalities.
- nearPD
(logical) If TRUE, project factorCor and the final correlation matrix onto nearest Positive Definite matrix, if needed.
Note
The nearPD option applies the Matrix::nearPD() function to force a non-positive-definite matrix to be positive-definite. It should be used only when a matrix is "nearly" PD. In most cases, a non-PD matrix that appears in the makeCorrLoadings() function means that there is a problem with the input parameters.
Examples
# Example loadings
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
)
# row and column names
rownames(factorLoadings) <- c("Q1", "Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8")
colnames(factorLoadings) <- c("Factor1", "Factor2", "Factor3")
# Factor correlation matrix
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
)
# Apply the function
itemCorrelations <- makeCorrLoadings(factorLoadings, factorCor)
round(itemCorrelations, 3)
#> Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
#> Q1 1.000 0.638 0.683 0.537 0.477 0.484 0.552 0.521
#> Q2 0.638 1.000 0.735 0.503 0.434 0.436 0.557 0.531
#> Q3 0.683 0.735 1.000 0.569 0.499 0.503 0.601 0.570
#> Q4 0.537 0.503 0.569 1.000 0.799 0.839 0.751 0.676
#> Q5 0.477 0.434 0.499 0.799 1.000 0.805 0.670 0.599
#> Q6 0.484 0.436 0.503 0.839 0.805 1.000 0.709 0.633
#> Q7 0.552 0.557 0.601 0.751 0.670 0.709 1.000 0.790
#> Q8 0.521 0.531 0.570 0.676 0.599 0.633 0.790 1.000