library(LikertMakeR) #library for create the initial cor matrix
items <- 4 # 4 variable per factor
alpha <- 0.999 # alpha for higher correlations
variance <- 0.15
set.seed(141)
cor_matrix141 <- makeCorrAlpha(items = items, alpha = alpha, variance = variance)
## correlation values consistent with desired alpha in 2 iterations
## The correlation matrix is positive definite
library(lavaan) #library to establish models
onef_cor0_load03_05 <- '
F1 =~ 0.35*x1 + 0.40*x2 + 0.45*x3+0.49*x4' #low fact loading
onef_cor0_load05_07 <- '
F1 =~ 0.55*x1 + 0.60*x2 + 0.65*x3+0.70*x4' #moderate fact loading, orthogonal
onef_cor0_load07_9 <- '
F1 =~ 0.75*x1 + 0.80*x2 + 0.85*x3+0.90*x4' #High fact loading, orthogonal
mod1f<- c(onef_cor0_load03_05, onef_cor0_load05_07, onef_cor0_load07_9 )
Se crea la segunda matriz de correlación
library(doParallel) #library for parallel process
library(foreach) #library for conditional coding
data <- list(NULL) # initial data
iter<-500 # iterations
registerDoParallel(cores = 2) # cores for dev.
cor_matrices <- list(NULL) # cor matrix
n <- 100 # sample size
clean_matrix <- function(mat) {
if (is.matrix(mat)) {
# Suppress rows and cols names
rownames(mat) <- NULL
colnames(mat) <- NULL
# Verify every object is numeric
as.matrix(mat)
} else {
stop("No matrix")
}
}
for (i in 1:iter) {
data[[i]] <- lapply(1:3, function(b) {
lavaan::simulateData(model = mod1f[[b]], sample.nobs = n, ov.var = cor_matrix141,
model.type = "cfa", return.type = "data.frame",
return.fit = FALSE, standardized = FALSE)
})
cor_matrices[[i]] <- lapply(data[[i]], function(df) {
cor_matrix <- cor(as.matrix(df))
clean_matrix(cor_matrix)
})
}
Se realizan las bases de datos con 4 y 7 opciones de respuesta
library(MASS)
base_likert4 <- list(NULL) # final data set 4 options
base_likert7 <- list(NULL) # final data set 7 options
set.seed(141)
for (i in 1:iter) {
base_likert4[[i]] <- lapply(1:3, function(j) {
cor_matrix <- cor_matrices[[i]][[j]] #matrix correlations
continuous_data <- mvrnorm(n = n, mu = rep(0, ncol(cor_matrix)), Sigma = cor_matrix) # simulation continous variables
likert_data <- apply(continuous_data, 2, function(x) {
cut(x, breaks = quantile(x, probs = seq(0, 1, by = 0.25)), labels = FALSE, include.lowest = TRUE)
}) #discretization
#data frame - numeric
likert_data <- as.data.frame(likert_data)
likert_data[] <- lapply(likert_data, as.numeric)
return(likert_data)
})
}
set.seed(141)
for (i in 1:iter) {
base_likert7[[i]] <- lapply(1:3, function(j) {
cor_matrix <- cor_matrices[[i]][[j]] #matrix correlations
continuous_data <- mvrnorm(n = n, mu = rep(0, ncol(cor_matrix)), Sigma = cor_matrix) # simulation continous variables
likert_data <- apply(continuous_data, 2, function(x) {
cut(x, breaks = quantile(x, probs = seq(0, 1, by = 1/7)), labels = FALSE, include.lowest = TRUE)
}) #discretization
#data frame - numeric
likert_data <- as.data.frame(likert_data)
likert_data[] <- lapply(likert_data, as.numeric)
return(likert_data)
})
}
Se estiman las correlaciones de Pearson y Spearman para cada caso
cor_pearson4 <- list(NULL) # pearson correlations matrix based on 4 options
cor_spearman4 <- list(NULL) # spearman correlation matrix based on 4 options
cor_pearson7 <- list(NULL) # pearson correlations matrix based on 7 options
cor_spearman7 <- list(NULL) # spearman correlation matrix based on 7 options
set.seed(141)
for (i in 1:iter) {
cor_pearson4[[i]] <- foreach(dataset = base_likert4[[i]], .combine = 'list', .multicombine = TRUE, .options.RNG = 141) %dopar% {
cor_matrixp <- cor(as.matrix(dataset))
clean_matrix(cor_matrixp)
}
cor_spearman4[[i]] <- foreach(dataset = base_likert4[[i]], .combine = 'list', .multicombine = TRUE, .options.RNG = 141) %dopar% {
cor_matrixsp <- cor(as.matrix(dataset), method = "spearman")
clean_matrix(cor_matrixsp)
}
}
set.seed(141)
for (i in 1:iter) {
cor_pearson7[[i]] <- foreach(dataset = base_likert7[[i]], .combine = 'list', .multicombine = TRUE, .options.RNG = 141) %dopar% {
cor_matrixp <- cor(as.matrix(dataset))
clean_matrix(cor_matrixp)
}
cor_spearman7[[i]] <- foreach(dataset = base_likert7[[i]], .combine = 'list', .multicombine = TRUE, .options.RNG = 141) %dopar% {
cor_matrixsp <- cor(as.matrix(dataset), method = "spearman")
clean_matrix(cor_matrixsp)
}
}
Comparación matrices promediando todos los modelos latentes
mean_cor_lavaan <- matrix(0, nrow = nrow(cor_matrices[[1]][[1]]), ncol = ncol(cor_matrices[[1]][[1]]))
for (i in 1:iter) {
for (j in 1:3) { # Tienes 3 modelos
mean_cor_lavaan <- mean_cor_lavaan + abs(cor_matrices[[i]][[j]])
}
}
mean_cor_lavaan <- mean_cor_lavaan / (iter * 3)
Se obtiene el promedio de las matrices de Pearson y Spearman acorde al número de opciones
mean_cor_pearson4 <- matrix(0, nrow = nrow(cor_pearson4[[1]][[1]]), ncol = ncol(cor_pearson4[[1]][[1]]))
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_pearson4 <- mean_cor_pearson4 + abs(cor_pearson4[[i]][[j]])
}
}
mean_cor_pearson4 <- mean_cor_pearson4 / (iter * 3)
mean_cor_spearman4 <- matrix(0, nrow = nrow(cor_spearman4[[1]][[1]]), ncol = ncol(cor_spearman4[[1]][[1]]))
# Promediar las matrices Spearman de 4 opciones
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_spearman4 <- mean_cor_spearman4 + abs(cor_spearman4[[i]][[j]])
}
}
# Dividir por el número total de matrices
mean_cor_spearman4 <- mean_cor_spearman4 / (iter * 3)
mean_cor_pearson7 <- matrix(0, nrow = nrow(cor_pearson7[[1]][[1]]), ncol = ncol(cor_pearson7[[1]][[1]]))
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_pearson7 <- mean_cor_pearson7 + abs(cor_pearson7[[i]][[j]])
}
}
mean_cor_pearson7 <- mean_cor_pearson7 / (iter * 3)
mean_cor_spearman7 <- matrix(0, nrow = nrow(cor_spearman7[[1]][[1]]), ncol = ncol(cor_spearman7[[1]][[1]]))
# Promediar las matrices Spearman de 4 opciones
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_spearman7 <- mean_cor_spearman7 + abs(cor_spearman7[[i]][[j]])
}
}
# Dividir por el número total de matrices
mean_cor_spearman7 <- mean_cor_spearman7 / (iter * 3)
Matriz inicial
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.9955042 0.9958058 0.9958635
## [2,] 0.9955042 1.0000000 0.9959174 0.9963027
## [3,] 0.9958058 0.9959174 1.0000000 0.9967578
## [4,] 0.9958635 0.9963027 0.9967578 1.0000000
Matriz simulada lavaan promediada
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2476993 0.2679162 0.2773663
## [2,] 0.2476993 1.0000000 0.2772855 0.2917548
## [3,] 0.2679162 0.2772855 1.0000000 0.3071225
## [4,] 0.2773663 0.2917548 0.3071225 1.0000000
Matriz simulada Pearson 4 opciones promediada
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2129173 0.2369227 0.2421120
## [2,] 0.2129173 1.0000000 0.2616160 0.2679520
## [3,] 0.2369227 0.2616160 1.0000000 0.2737867
## [4,] 0.2421120 0.2679520 0.2737867 1.0000000
Matriz simulada Spearman 4 opciones promediada
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2129173 0.2369227 0.2421120
## [2,] 0.2129173 1.0000000 0.2616160 0.2679520
## [3,] 0.2369227 0.2616160 1.0000000 0.2737867
## [4,] 0.2421120 0.2679520 0.2737867 1.0000000
Matriz simulada Pearson 7 opciones promediada
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2254878 0.2514862 0.2552472
## [2,] 0.2254878 1.0000000 0.2760374 0.2845691
## [3,] 0.2514862 0.2760374 1.0000000 0.2905301
## [4,] 0.2552472 0.2845691 0.2905301 1.0000000
Matriz simulada Spearman 7 opciones promediada
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2257557 0.2517522 0.2555605
## [2,] 0.2257557 1.0000000 0.2763827 0.2848551
## [3,] 0.2517522 0.2763827 1.0000000 0.2908951
## [4,] 0.2555605 0.2848551 0.2908951 1.0000000
diff_pearson4 <- mean_cor_lavaan - mean_cor_pearson4
diff_spearman4 <- mean_cor_lavaan - mean_cor_spearman4
diff_pearson7 <- mean_cor_lavaan - mean_cor_pearson7
diff_spearman7 <- mean_cor_lavaan - mean_cor_spearman7
library(reshape2)
library(dplyr)
# Melt de las diferencias y añadir una columna indicando la matriz
melt_diff_pearson4 <- melt(diff_pearson4) %>% mutate(method = "Pearson (4 opciones)")
melt_diff_spearman4 <- melt(diff_spearman4) %>% mutate(method = "Spearman (4 opciones)")
melt_diff_pearson7 <- melt(diff_pearson7) %>% mutate(method = "Pearson (7 opciones)")
melt_diff_spearman7 <- melt(diff_spearman7) %>% mutate(method = "Spearman (7 opciones)")
# Combinar todas las matrices en un solo data frame
all_diffs <- bind_rows(melt_diff_pearson4, melt_diff_spearman4, melt_diff_pearson7, melt_diff_spearman7)
library(ggplot2)
# Crear el heatmap con facetas para visualizar las diferencias de todas las matrices
ggplot(data = all_diffs, aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
scale_fill_gradient2(low = "blue", high = "red", mid = "white",
midpoint = 0, limit = c(min(all_diffs$value), max(all_diffs$value))) +
theme_minimal() +
labs(title = "Diferencias entre Lavaan y Pearson/Spearman",
x = "Variable 1", y = "Variable 2", fill = "Diferencia") +
facet_wrap(~method) # Facetear por el tipo de método y número de opciones
Diferencias entre Lavaan y Pearson (4 opciones)
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.03478194 0.03099349 0.03525434
## [2,] 0.03478194 0.00000000 0.01566946 0.02380277
## [3,] 0.03099349 0.01566946 0.00000000 0.03333579
## [4,] 0.03525434 0.02380277 0.03333579 0.00000000
Diferencias entre Lavaan y Spearman (4 opciones):
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.03478194 0.03099349 0.03525434
## [2,] 0.03478194 0.00000000 0.01566946 0.02380277
## [3,] 0.03099349 0.01566946 0.00000000 0.03333579
## [4,] 0.03525434 0.02380277 0.03333579 0.00000000
Diferencias entre Lavaan y Pearson (7 opciones)
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.022211471 0.016429977 0.022119188
## [2,] 0.02221147 0.000000000 0.001248058 0.007185665
## [3,] 0.01642998 0.001248058 0.000000000 0.016592371
## [4,] 0.02211919 0.007185665 0.016592371 0.000000000
Diferencias entre Lavaan y Spearman (7 opciones)
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.0219435647 0.0161639212 0.021805863
## [2,] 0.02194356 0.0000000000 0.0009027912 0.006899705
## [3,] 0.01616392 0.0009027912 0.0000000000 0.016227315
## [4,] 0.02180586 0.0068997050 0.0162273146 0.000000000
MATRIZ INICIAL lavaan
mean_cor_lavaan_esp <- list()
for (j in 1:3) {
mean_cor_lavaan_esp[[j]] <- matrix(0, nrow = nrow(cor_matrices[[1]][[1]]), ncol = ncol(cor_matrices[[1]][[1]]))
}
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_lavaan_esp[[j]] <- mean_cor_lavaan_esp[[j]] + abs(cor_matrices[[i]][[j]])
}
}
for (j in 1:3) {
mean_cor_lavaan_esp[[j]] <- mean_cor_lavaan_esp[[j]] / iter
}
names(mean_cor_lavaan_esp) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(mean_cor_lavaan_esp)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.1238907 0.1470803 0.1545039
## [2,] 0.1238907 1.0000000 0.1499845 0.1635760
## [3,] 0.1470803 0.1499845 1.0000000 0.1849105
## [4,] 0.1545039 0.1635760 0.1849105 1.0000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2506329 0.2709827 0.2830966
## [2,] 0.2506329 1.0000000 0.2811292 0.2952121
## [3,] 0.2709827 0.2811292 1.0000000 0.3058688
## [4,] 0.2830966 0.2952121 0.3058688 1.0000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.3685742 0.3856854 0.3944985
## [2,] 0.3685742 1.0000000 0.4007427 0.4164762
## [3,] 0.3856854 0.4007427 1.0000000 0.4305880
## [4,] 0.3944985 0.4164762 0.4305880 1.0000000
Matrices de Pearson por modelo con 4 opciones de respuesta
mean_cor_pearson_esp <- list()
for (j in 1:3) {
mean_cor_pearson_esp[[j]] <- matrix(0, nrow = nrow(cor_pearson4[[1]][[1]]), ncol = ncol(cor_pearson4[[1]][[1]]))
}
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_pearson_esp[[j]] <- mean_cor_pearson_esp[[j]] + abs(cor_pearson4[[i]][[j]])
}
}
for (j in 1:3) {
mean_cor_pearson_esp[[j]] <- mean_cor_pearson_esp[[j]] / iter
}
names(mean_cor_pearson_esp) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(mean_cor_pearson_esp)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 1.000000 0.125712 0.151104 0.149776
## [2,] 0.125712 1.000000 0.162192 0.162288
## [3,] 0.151104 0.162192 1.000000 0.177264
## [4,] 0.149776 0.162288 0.177264 1.000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 1.000000 0.208976 0.237408 0.242464
## [2,] 0.208976 1.000000 0.265616 0.270176
## [3,] 0.237408 0.265616 1.000000 0.269936
## [4,] 0.242464 0.270176 0.269936 1.000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 1.000000 0.304064 0.322256 0.334096
## [2,] 0.304064 1.000000 0.357040 0.371392
## [3,] 0.322256 0.357040 1.000000 0.374160
## [4,] 0.334096 0.371392 0.374160 1.000000
Matrices de Spearman por modelo con 4 opciones de respuesta
mean_cor_spearman_esp <- list()
for (j in 1:3) {
mean_cor_spearman_esp[[j]] <- matrix(0, nrow = nrow(cor_spearman4[[1]][[1]]), ncol = ncol(cor_spearman4[[1]][[1]]))
}
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_spearman_esp[[j]] <- mean_cor_spearman_esp[[j]] + abs(cor_spearman4[[i]][[j]])
}
}
for (j in 1:3) {
mean_cor_spearman_esp[[j]] <- mean_cor_spearman_esp[[j]] / iter
}
names(mean_cor_spearman_esp) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(mean_cor_spearman_esp)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 1.000000 0.125712 0.151104 0.149776
## [2,] 0.125712 1.000000 0.162192 0.162288
## [3,] 0.151104 0.162192 1.000000 0.177264
## [4,] 0.149776 0.162288 0.177264 1.000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 1.000000 0.208976 0.237408 0.242464
## [2,] 0.208976 1.000000 0.265616 0.270176
## [3,] 0.237408 0.265616 1.000000 0.269936
## [4,] 0.242464 0.270176 0.269936 1.000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 1.000000 0.304064 0.322256 0.334096
## [2,] 0.304064 1.000000 0.357040 0.371392
## [3,] 0.322256 0.357040 1.000000 0.374160
## [4,] 0.334096 0.371392 0.374160 1.000000
Matrices de Pearson por modelo con 7 opciones de respuesta
mean_cor_pearson_esp7 <- list()
for (j in 1:3) {
mean_cor_pearson_esp7[[j]] <- matrix(0, nrow = nrow(cor_pearson7[[1]][[1]]), ncol = ncol(cor_pearson7[[1]][[1]]))
}
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_pearson_esp7[[j]] <- mean_cor_pearson_esp7[[j]] + abs(cor_pearson7[[i]][[j]])
}
}
for (j in 1:3) {
mean_cor_pearson_esp7[[j]] <- mean_cor_pearson_esp7[[j]] / iter
}
names(mean_cor_pearson_esp7) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(mean_cor_pearson_esp7)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.1308878 0.1585366 0.1559073
## [2,] 0.1308878 1.0000000 0.1704390 0.1699415
## [3,] 0.1585366 0.1704390 1.0000000 0.1887902
## [4,] 0.1559073 0.1699415 0.1887902 1.0000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2210829 0.2523073 0.2563756
## [2,] 0.2210829 1.0000000 0.2794341 0.2882878
## [3,] 0.2523073 0.2794341 1.0000000 0.2869512
## [4,] 0.2563756 0.2882878 0.2869512 1.0000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.3244927 0.3436146 0.3534585
## [2,] 0.3244927 1.0000000 0.3782390 0.3954780
## [3,] 0.3436146 0.3782390 1.0000000 0.3958488
## [4,] 0.3534585 0.3954780 0.3958488 1.0000000
Matrices de Spearman para cada modelo 7 opciones de respuesta
mean_cor_spearman_esp7 <- list()
for (j in 1:3) {
mean_cor_spearman_esp7[[j]] <- matrix(0, nrow = nrow(cor_spearman7[[1]][[1]]), ncol = ncol(cor_spearman7[[1]][[1]]))
}
for (i in 1:iter) {
for (j in 1:3) {
mean_cor_spearman_esp7[[j]] <- mean_cor_spearman_esp7[[j]] + abs(cor_spearman7[[i]][[j]])
}
}
for (j in 1:3) {
mean_cor_spearman_esp7[[j]] <- mean_cor_spearman_esp7[[j]] / iter
}
names(mean_cor_spearman_esp7) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(mean_cor_spearman_esp7)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.1310475 0.1586771 0.1560705
## [2,] 0.1310475 1.0000000 0.1706251 0.1701150
## [3,] 0.1586771 0.1706251 1.0000000 0.1890619
## [4,] 0.1560705 0.1701150 0.1890619 1.0000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.2213206 0.2525819 0.2567399
## [2,] 0.2213206 1.0000000 0.2798527 0.2885685
## [3,] 0.2525819 0.2798527 1.0000000 0.2873143
## [4,] 0.2567399 0.2885685 0.2873143 1.0000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 1.0000000 0.3248991 0.3439977 0.3538711
## [2,] 0.3248991 1.0000000 0.3786702 0.3958817
## [3,] 0.3439977 0.3786702 1.0000000 0.3963092
## [4,] 0.3538711 0.3958817 0.3963092 1.0000000
#Estimando las diferencias entre las matrices Diferencias entre Lavaan y Pearson (4 opciones) por modelo
diff_lavaan_pearson4_esp <- list()
diff_lavaan_spearman4_esp <- list()
diff_lavaan_pearson7_esp <- list()
diff_lavaan_spearman7_esp <- list()
for (j in 1:3) {
diff_lavaan_pearson4_esp[[j]] <- mean_cor_lavaan_esp[[j]] - mean_cor_pearson_esp[[j]]
diff_lavaan_spearman4_esp[[j]] <- mean_cor_lavaan_esp[[j]] - mean_cor_spearman_esp[[j]]
diff_lavaan_pearson7_esp[[j]] <- mean_cor_lavaan_esp[[j]] - mean_cor_pearson_esp7[[j]]
diff_lavaan_spearman7_esp[[j]] <- mean_cor_lavaan_esp[[j]] - mean_cor_spearman_esp7[[j]]
}
names(diff_lavaan_pearson4_esp) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(diff_lavaan_pearson4_esp)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 0.000000000 -0.001821276 -0.004023717 0.004727869
## [2,] -0.001821276 0.000000000 -0.012207488 0.001288036
## [3,] -0.004023717 -0.012207488 0.000000000 0.007646512
## [4,] 0.004727869 0.001288036 0.007646512 0.000000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.04165689 0.03357473 0.04063264
## [2,] 0.04165689 0.00000000 0.01551320 0.02503609
## [3,] 0.03357473 0.01551320 0.00000000 0.03593282
## [4,] 0.04063264 0.02503609 0.03593282 0.00000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.06451022 0.06342945 0.06040252
## [2,] 0.06451022 0.00000000 0.04370265 0.04508419
## [3,] 0.06342945 0.04370265 0.00000000 0.05642802
## [4,] 0.06040252 0.04508419 0.05642802 0.00000000
Diferencias entre Lavaan y Spearman (4 opciones) por modelo
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 0.000000000 -0.001821276 -0.004023717 0.004727869
## [2,] -0.001821276 0.000000000 -0.012207488 0.001288036
## [3,] -0.004023717 -0.012207488 0.000000000 0.007646512
## [4,] 0.004727869 0.001288036 0.007646512 0.000000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.04165689 0.03357473 0.04063264
## [2,] 0.04165689 0.00000000 0.01551320 0.02503609
## [3,] 0.03357473 0.01551320 0.00000000 0.03593282
## [4,] 0.04063264 0.02503609 0.03593282 0.00000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.06451022 0.06342945 0.06040252
## [2,] 0.06451022 0.00000000 0.04370265 0.04508419
## [3,] 0.06342945 0.04370265 0.00000000 0.05642802
## [4,] 0.06040252 0.04508419 0.05642802 0.00000000
Diferencias entre Lavaan y Pearson (7 opciones) por modelo
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 0.000000000 -0.006997081 -0.011456302 -0.001403448
## [2,] -0.006997081 0.000000000 -0.020454513 -0.006365427
## [3,] -0.011456302 -0.020454513 0.000000000 -0.003879732
## [4,] -0.001403448 -0.006365427 -0.003879732 0.000000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.029549959 0.018675418 0.026721027
## [2,] 0.02954996 0.000000000 0.001695057 0.006924282
## [3,] 0.01867542 0.001695057 0.000000000 0.018917601
## [4,] 0.02672103 0.006924282 0.018917601 0.000000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.04408154 0.04207081 0.04103998
## [2,] 0.04408154 0.00000000 0.02250363 0.02099814
## [3,] 0.04207081 0.02250363 0.00000000 0.03473924
## [4,] 0.04103998 0.02099814 0.03473924 0.00000000
Diferencias entre Lavaan y Spearman (7 opciones) por modelo
names(diff_lavaan_spearman7_esp) <- c("Carga factorial baja", "Carga factorial moderada", "Carga factorial alta")
print(diff_lavaan_spearman7_esp)
## $`Carga factorial baja`
## [,1] [,2] [,3] [,4]
## [1,] 0.000000000 -0.007156784 -0.011596804 -0.001566585
## [2,] -0.007156784 0.000000000 -0.020640596 -0.006538974
## [3,] -0.011596804 -0.020640596 0.000000000 -0.004151415
## [4,] -0.001566585 -0.006538974 -0.004151415 0.000000000
##
## $`Carga factorial moderada`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.029312332 0.018400835 0.026356708
## [2,] 0.02931233 0.000000000 0.001276495 0.006643596
## [3,] 0.01840084 0.001276495 0.000000000 0.018554558
## [4,] 0.02635671 0.006643596 0.018554558 0.000000000
##
## $`Carga factorial alta`
## [,1] [,2] [,3] [,4]
## [1,] 0.00000000 0.04367515 0.04168773 0.04062747
## [2,] 0.04367515 0.00000000 0.02207247 0.02059449
## [3,] 0.04168773 0.02207247 0.00000000 0.03427880
## [4,] 0.04062747 0.02059449 0.03427880 0.00000000