# define parameters
items <- 4
alpha <- 0.85
variance <- 0.5
# apply function
set.seed(42)
cor_matrix <- makeCorrAlpha(
items = items,
alpha = alpha,
variance = variance
)
# test function output
print(cor_matrix)
alpha(cor_matrix)
eigenvalues(cor_matrix, 1)
# higher alpha, more items
cor_matrix2 <- makeCorrAlpha(
items = 8,
alpha = 0.95
)
# test output
cor_matrix2 |> round(2)
alpha(cor_matrix2) |> round(3)
eigenvalues(cor_matrix2, 1) |> round(3)
# large random variation around alpha
set.seed(42)
cor_matrix3 <- makeCorrAlpha(
items = 6,
alpha = 0.85,
precision = 2
)
# test output
cor_matrix3 |> round(2)
alpha(cor_matrix3) |> round(3)
eigenvalues(cor_matrix3, 1) |> round(3)
# with diagnostics
cor_matrix4 <- makeCorrAlpha(
items = 4,
alpha = 0.80,
diagnostics = TRUE
)
# test output
cor_matrix4
Run the code above in your browser using DataLab