library(lavaan)
## This is lavaan 0.6-14
## lavaan is FREE software! Please report any bugs.
library(lavaanPlot)
lavaan = Latent Variable Analysis
library(readxl)
bd <- readxl::read_excel("Datos_SEM_Eng.xlsx")
View(bd)
Tipos de fórmulas: Regresión ~ Definición de variable latente =~ Varianzas y covarianzas ~~ Intercepto ~1
modelo <- ' # Regresiones
#Definiciones de Variables Latentes
desapego=~ RPD02 + RPD03 + RPD07 + RPD10
relajacion =~ RRE02 + RRE07 + RRE10
dominio =~ RMA03+RMA04+RMA08+RMA10
control =~ RCO02+RCO04+RCO06+RCO07
#V Varianzas y Covarianzas
# Interceptos
# regressions
desapego ~ relajacion
dominio ~ desapego + relajacion
# residual covariances
RPD02 ~ RPD03
RMA03 ~ RMA08 + RMA10
RRE02~ RRE07
RMA10 ~ RCO04
'
fit <- cfa(modelo, bd)
fit
## lavaan 0.6.14 ended normally after 58 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 39
##
## Number of observations 223
##
## Model Test User Model:
##
## Test statistic 162.844
## Degrees of freedom 81
## P-value (Chi-square) 0.000
summary(fit, standardized = TRUE)
## lavaan 0.6.14 ended normally after 58 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 39
##
## Number of observations 223
##
## Model Test User Model:
##
## Test statistic 162.844
## Degrees of freedom 81
## P-value (Chi-square) 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## desapego =~
## RPD02 1.000 1.801 0.925
## RPD03 0.874 0.079 11.119 0.000 1.573 0.792
## RPD07 0.993 0.101 9.820 0.000 1.789 0.886
## RPD10 0.944 0.099 9.494 0.000 1.700 0.800
## relajacion =~
## RRE02 1.000 0.716 0.478
## RRE07 1.979 0.480 4.125 0.000 1.418 0.822
## RRE10 1.503 0.393 3.822 0.000 1.077 0.724
## dominio =~
## RMA03 1.000 1.364 0.671
## RMA04 1.236 0.340 3.638 0.000 1.685 0.887
## RMA08 1.136 0.286 3.970 0.000 1.549 0.850
## RMA10 0.955 0.250 3.824 0.000 1.303 0.698
## control =~
## RCO02 1.000 1.610 0.844
## RCO04 0.787 0.048 16.561 0.000 1.267 0.865
## RCO06 0.870 0.048 18.237 0.000 1.400 0.915
## RCO07 0.860 0.049 17.735 0.000 1.385 0.900
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## desapego ~
## relajacion 1.612 0.454 3.554 0.000 0.641 0.641
## dominio ~
## desapego -0.116 0.077 -1.513 0.130 -0.153 -0.153
## relajacion 1.338 0.522 2.564 0.010 0.703 0.703
## RPD02 ~
## RPD03 -0.026 0.079 -0.324 0.746 -0.026 -0.026
## RMA03 ~
## RMA08 -0.047 0.144 -0.330 0.741 -0.047 -0.043
## RMA10 0.216 0.093 2.316 0.021 0.216 0.198
## RRE02 ~
## RRE07 0.254 0.097 2.625 0.009 0.254 0.292
## RMA10 ~
## RCO04 0.201 0.065 3.108 0.002 0.201 0.158
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## relajacion ~~
## control 0.890 0.241 3.695 0.000 0.772 0.772
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .RPD02 0.694 0.129 5.379 0.000 0.694 0.183
## .RPD03 1.476 0.184 8.033 0.000 1.476 0.374
## .RPD07 0.873 0.132 6.618 0.000 0.873 0.214
## .RPD10 1.624 0.183 8.886 0.000 1.624 0.360
## .RRE02 1.028 0.111 9.245 0.000 1.028 0.457
## .RRE07 0.963 0.149 6.479 0.000 0.963 0.324
## .RRE10 1.055 0.123 8.580 0.000 1.055 0.476
## .RMA03 1.512 0.199 7.612 0.000 1.512 0.366
## .RMA04 0.766 0.149 5.159 0.000 0.766 0.213
## .RMA08 0.919 0.142 6.456 0.000 0.919 0.277
## .RMA10 1.388 0.158 8.781 0.000 1.388 0.399
## .RCO02 1.050 0.119 8.858 0.000 1.050 0.288
## .RCO04 0.540 0.064 8.496 0.000 0.540 0.252
## .RCO06 0.383 0.055 6.970 0.000 0.383 0.163
## .RCO07 0.450 0.060 7.563 0.000 0.450 0.190
## .desapego 1.910 0.405 4.713 0.000 0.589 0.589
## relajacion 0.513 0.258 1.989 0.047 1.000 1.000
## .dominio 1.154 0.614 1.881 0.060 0.621 0.621
## control 2.591 0.336 7.702 0.000 1.000 1.000
lavaanPlot(model = fit, coefs = TRUE, covs = TRUE)
modelo2 = ' # regresiones
# Definciones de variables latentes
energia =~ EN01+EN02+EN04+EN05+EN06+EN07+EN08
# Second Order Factor recuperacion
# Varianzas y covarianzas
# Interceptos
'
### Analisis Factorial Confirmatorio (CFA)
fit2 = cfa(modelo2, bd)
summary(fit2,fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6.14 ended normally after 32 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 14
##
## Number of observations 223
##
## Model Test User Model:
##
## Test statistic 47.222
## Degrees of freedom 14
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 2324.436
## Degrees of freedom 21
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.986
## Tucker-Lewis Index (TLI) 0.978
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -2017.154
## Loglikelihood unrestricted model (H1) -1993.543
##
## Akaike (AIC) 4062.308
## Bayesian (BIC) 4110.008
## Sample-size adjusted Bayesian (SABIC) 4065.641
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.103
## 90 Percent confidence interval - lower 0.072
## 90 Percent confidence interval - upper 0.136
## P-value H_0: RMSEA <= 0.050 0.004
## P-value H_0: RMSEA >= 0.080 0.892
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.012
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## energia =~
## EN01 1.000 1.674 0.893
## EN02 1.029 0.044 23.192 0.000 1.723 0.933
## EN04 0.999 0.044 22.583 0.000 1.672 0.924
## EN05 0.999 0.042 23.649 0.000 1.672 0.939
## EN06 0.986 0.042 23.722 0.000 1.651 0.940
## EN07 1.049 0.046 22.856 0.000 1.755 0.928
## EN08 1.036 0.043 24.173 0.000 1.734 0.946
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .EN01 0.711 0.074 9.651 0.000 0.711 0.202
## .EN02 0.444 0.049 9.012 0.000 0.444 0.130
## .EN04 0.481 0.052 9.214 0.000 0.481 0.147
## .EN05 0.375 0.042 8.830 0.000 0.375 0.118
## .EN06 0.359 0.041 8.798 0.000 0.359 0.116
## .EN07 0.499 0.055 9.129 0.000 0.499 0.139
## .EN08 0.353 0.041 8.580 0.000 0.353 0.105
## energia 2.801 0.327 8.565 0.000 1.000 1.000
lavaanPlot(model = fit2, coefs = TRUE, covs = TRUE)
##ENGAGEMENT LABORAL
modelo3 <- ' # Regresiones
#Definiciones de Variables Latentes
vigor=~ EVI01+EVI02+EVI03
dedicacion =~ EDE01 + EDE02 + EDE03
absorbcion =~ EAB01 +EAB02+EAB03
#V Varianzas y Covarianzas
# Interceptos
# regressions
vigor~ dedicacion
absorbcion~ vigor + dedicacion
# residual covariances
EVI01 ~ EVI02
EDE01 ~ EDE02 + EDE03
EAB01~ EAB02
EVI03 ~ EAB03
'
fit3 <- cfa(modelo3, bd)
## Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
## variances are negative
fit3
## lavaan 0.6.14 ended normally after 123 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 26
##
## Number of observations 223
##
## Model Test User Model:
##
## Test statistic 129.783
## Degrees of freedom 19
## P-value (Chi-square) 0.000
summary(fit3, standardized = TRUE)
## lavaan 0.6.14 ended normally after 123 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 26
##
## Number of observations 223
##
## Model Test User Model:
##
## Test statistic 129.783
## Degrees of freedom 19
## P-value (Chi-square) 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## vigor =~
## EVI01 1.000 0.384 0.221
## EVI02 3.890 0.918 4.240 0.000 1.496 0.867
## EVI03 4.904 1.171 4.187 0.000 1.885 0.940
## dedicacion =~
## EDE01 1.000 2.610 1.330
## EDE02 0.643 0.119 5.396 0.000 1.678 0.913
## EDE03 0.437 0.087 5.030 0.000 1.140 0.806
## absorbcion =~
## EAB01 1.000 3.289 1.876
## EAB02 0.412 0.083 4.944 0.000 1.354 0.891
## EAB03 0.363 0.097 3.738 0.000 1.195 0.678
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## vigor ~
## dedicacion 0.140 0.044 3.164 0.002 0.948 0.948
## absorbcion ~
## vigor 1.062 2.319 0.458 0.647 0.124 0.124
## dedicacion 0.875 0.511 1.712 0.087 0.694 0.694
## EVI01 ~
## EVI02 0.753 0.051 14.740 0.000 0.753 0.745
## EDE01 ~
## EDE02 -0.070 0.230 -0.303 0.762 -0.070 -0.065
## EDE03 -0.498 0.105 -4.738 0.000 -0.498 -0.359
## EAB01 ~
## EAB02 -1.164 0.506 -2.301 0.021 -1.164 -1.009
## EVI03 ~
## EAB03 -0.066 0.047 -1.427 0.154 -0.066 -0.058
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .EVI01 0.336 0.033 10.238 0.000 0.336 0.111
## .EVI02 0.740 0.087 8.471 0.000 0.740 0.249
## .EVI03 0.691 0.102 6.749 0.000 0.691 0.172
## .EDE01 -0.032 0.216 -0.146 0.884 -0.032 -0.008
## .EDE02 0.561 0.104 5.373 0.000 0.561 0.166
## .EDE03 0.700 0.078 8.952 0.000 0.700 0.350
## .EAB01 -0.503 0.523 -0.962 0.336 -0.503 -0.164
## .EAB02 0.474 0.128 3.707 0.000 0.474 0.205
## .EAB03 1.674 0.172 9.710 0.000 1.674 0.540
## .vigor 0.015 0.009 1.636 0.102 0.102 0.102
## dedicacion 6.812 2.753 2.475 0.013 1.000 1.000
## .absorbcion 3.674 2.072 1.773 0.076 0.340 0.340
lavaanPlot(model = fit3, coefs = TRUE, covs = TRUE)
modelo4 <-' # regresiones
# Definciones de variables latentes
desapego =~ RPD01+RPD02+RPD03+RPD05+RPD06+RPD07+RPD08+RPD09+RPD10
relajacion =~ RRE02+RRE03+RRE04+RRE05+RRE06+RRE07+RRE10
dominio =~ RMA02+RMA03+RMA04+RMA05+RMA06+RMA07+RMA08+RMA09+RMA10
control_tiempo =~ RCO02+RCO03+RCO04+RCO05+RCO06+RCO07
# Second Order Factor recuperacion
recuperacion =~ desapego + relajacion + dominio + control_tiempo
# Definciones de variables latentes
energia =~ EN01+EN02+EN04+EN05+EN06+EN07+EN08
# Definciones de variables latentes
vigor =~EVI01+EVI02+EVI03
dedicacion =~ EDE01+EDE02+EDE03
absorcion =~ EAB01+EAB02+EAB03
# Second Order Factor recuperacion
engagement =~ vigor + dedicacion + absorcion
# Third Order Factor ambiente
ambiente =~ recuperacion+energia+engagement
# Varianzas y covarianzas
# Interceptos
'
## Analisis Factorial Confirmatorio (CFA)
fit4 <- cfa(modelo4, bd)
summary(fit4,fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6.14 ended normally after 67 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 104
##
## Number of observations 223
##
## Model Test User Model:
##
## Test statistic 2501.954
## Degrees of freedom 1024
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 13350.303
## Degrees of freedom 1081
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.880
## Tucker-Lewis Index (TLI) 0.873
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -15454.903
## Loglikelihood unrestricted model (H1) -14203.926
##
## Akaike (AIC) 31117.805
## Bayesian (BIC) 31472.151
## Sample-size adjusted Bayesian (SABIC) 31142.562
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.080
## 90 Percent confidence interval - lower 0.076
## 90 Percent confidence interval - upper 0.084
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 0.578
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.074
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## desapego =~
## RPD01 1.000 1.387 0.789
## RPD02 1.209 0.081 14.865 0.000 1.677 0.861
## RPD03 1.144 0.085 13.419 0.000 1.587 0.798
## RPD05 1.313 0.086 15.317 0.000 1.822 0.879
## RPD06 1.082 0.089 12.214 0.000 1.501 0.742
## RPD07 1.229 0.085 14.487 0.000 1.705 0.845
## RPD08 1.157 0.086 13.375 0.000 1.604 0.796
## RPD09 1.315 0.087 15.163 0.000 1.824 0.873
## RPD10 1.343 0.088 15.247 0.000 1.863 0.877
## relajacion =~
## RRE02 1.000 1.275 0.850
## RRE03 1.120 0.065 17.296 0.000 1.429 0.871
## RRE04 1.021 0.058 17.625 0.000 1.301 0.880
## RRE05 1.051 0.056 18.687 0.000 1.341 0.908
## RRE06 1.246 0.074 16.924 0.000 1.588 0.861
## RRE07 1.121 0.071 15.838 0.000 1.430 0.829
## RRE10 0.814 0.067 12.134 0.000 1.038 0.698
## dominio =~
## RMA02 1.000 1.407 0.729
## RMA03 1.152 0.096 12.041 0.000 1.621 0.798
## RMA04 1.178 0.089 13.265 0.000 1.658 0.873
## RMA05 1.141 0.087 13.057 0.000 1.605 0.860
## RMA06 0.648 0.075 8.625 0.000 0.911 0.581
## RMA07 1.104 0.085 13.062 0.000 1.553 0.861
## RMA08 1.110 0.085 13.001 0.000 1.561 0.857
## RMA09 1.030 0.084 12.257 0.000 1.448 0.811
## RMA10 1.056 0.088 12.047 0.000 1.486 0.798
## control_tiempo =~
## RCO02 1.000 1.632 0.855
## RCO03 0.945 0.049 19.173 0.000 1.543 0.910
## RCO04 0.794 0.044 18.100 0.000 1.295 0.884
## RCO05 0.814 0.043 18.926 0.000 1.329 0.904
## RCO06 0.837 0.045 18.407 0.000 1.365 0.892
## RCO07 0.836 0.046 18.205 0.000 1.365 0.887
## recuperacion =~
## desapego 1.000 0.711 0.711
## relajacion 1.070 0.121 8.840 0.000 0.827 0.827
## dominio 0.900 0.129 6.960 0.000 0.631 0.631
## control_tiempo 1.423 0.157 9.063 0.000 0.860 0.860
## energia =~
## EN01 1.000 1.678 0.896
## EN02 1.027 0.044 23.415 0.000 1.723 0.933
## EN04 0.998 0.044 22.871 0.000 1.675 0.925
## EN05 0.996 0.042 23.836 0.000 1.671 0.939
## EN06 0.983 0.041 23.857 0.000 1.649 0.939
## EN07 1.045 0.045 22.964 0.000 1.753 0.926
## EN08 1.033 0.042 24.398 0.000 1.733 0.946
## vigor =~
## EVI01 1.000 1.684 0.967
## EVI02 0.985 0.028 35.282 0.000 1.659 0.962
## EVI03 0.996 0.048 20.546 0.000 1.677 0.836
## dedicacion =~
## EDE01 1.000 1.868 0.952
## EDE02 0.907 0.034 26.376 0.000 1.695 0.922
## EDE03 0.571 0.037 15.539 0.000 1.066 0.754
## absorcion =~
## EAB01 1.000 1.607 0.917
## EAB02 0.711 0.051 13.823 0.000 1.143 0.752
## EAB03 0.735 0.063 11.600 0.000 1.181 0.671
## engagement =~
## vigor 1.000 0.901 0.901
## dedicacion 1.213 0.061 19.812 0.000 0.985 0.985
## absorcion 0.958 0.059 16.371 0.000 0.904 0.904
## ambiente =~
## recuperacion 1.000 0.880 0.880
## energia 1.814 0.225 8.058 0.000 0.938 0.938
## engagement 1.186 0.160 7.402 0.000 0.678 0.678
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .RPD01 1.168 0.119 9.781 0.000 1.168 0.378
## .RPD02 0.983 0.107 9.202 0.000 0.983 0.259
## .RPD03 1.434 0.147 9.729 0.000 1.434 0.363
## .RPD05 0.972 0.109 8.938 0.000 0.972 0.227
## .RPD06 1.836 0.184 9.980 0.000 1.836 0.449
## .RPD07 1.165 0.124 9.377 0.000 1.165 0.286
## .RPD08 1.486 0.153 9.740 0.000 1.486 0.366
## .RPD09 1.037 0.115 9.036 0.000 1.037 0.238
## .RPD10 1.046 0.116 8.984 0.000 1.046 0.232
## .RRE02 0.623 0.067 9.252 0.000 0.623 0.277
## .RRE03 0.647 0.072 8.976 0.000 0.647 0.241
## .RRE04 0.492 0.056 8.829 0.000 0.492 0.225
## .RRE05 0.384 0.047 8.203 0.000 0.384 0.176
## .RRE06 0.880 0.097 9.122 0.000 0.880 0.259
## .RRE07 0.930 0.098 9.460 0.000 0.930 0.313
## .RRE10 1.136 0.113 10.087 0.000 1.136 0.513
## .RMA02 1.741 0.175 9.935 0.000 1.741 0.468
## .RMA03 1.499 0.156 9.594 0.000 1.499 0.363
## .RMA04 0.857 0.098 8.785 0.000 0.857 0.238
## .RMA05 0.903 0.101 8.983 0.000 0.903 0.260
## .RMA06 1.626 0.158 10.280 0.000 1.626 0.662
## .RMA07 0.844 0.094 8.979 0.000 0.844 0.259
## .RMA08 0.882 0.098 9.031 0.000 0.882 0.266
## .RMA09 1.090 0.115 9.498 0.000 1.090 0.342
## .RMA10 1.257 0.131 9.592 0.000 1.257 0.363
## .RCO02 0.978 0.104 9.391 0.000 0.978 0.269
## .RCO03 0.493 0.058 8.474 0.000 0.493 0.172
## .RCO04 0.468 0.052 9.016 0.000 0.468 0.218
## .RCO05 0.393 0.046 8.621 0.000 0.393 0.182
## .RCO06 0.479 0.054 8.884 0.000 0.479 0.205
## .RCO07 0.505 0.056 8.972 0.000 0.505 0.213
## .EN01 0.696 0.072 9.660 0.000 0.696 0.198
## .EN02 0.443 0.049 9.064 0.000 0.443 0.130
## .EN04 0.473 0.051 9.236 0.000 0.473 0.144
## .EN05 0.378 0.042 8.907 0.000 0.378 0.119
## .EN06 0.366 0.041 8.899 0.000 0.366 0.119
## .EN07 0.507 0.055 9.209 0.000 0.507 0.142
## .EN08 0.353 0.041 8.658 0.000 0.353 0.105
## .EVI01 0.199 0.039 5.047 0.000 0.199 0.065
## .EVI02 0.224 0.040 5.620 0.000 0.224 0.075
## .EVI03 1.213 0.124 9.773 0.000 1.213 0.301
## .EDE01 0.363 0.065 5.605 0.000 0.363 0.094
## .EDE02 0.506 0.067 7.567 0.000 0.506 0.150
## .EDE03 0.864 0.087 9.921 0.000 0.864 0.432
## .EAB01 0.490 0.103 4.767 0.000 0.490 0.159
## .EAB02 1.003 0.109 9.186 0.000 1.003 0.434
## .EAB03 1.706 0.176 9.719 0.000 1.706 0.550
## .desapego 0.952 0.149 6.396 0.000 0.495 0.495
## .relajacion 0.514 0.085 6.023 0.000 0.316 0.316
## .dominio 1.191 0.200 5.956 0.000 0.602 0.602
## .control_tiempo 0.694 0.125 5.538 0.000 0.261 0.261
## .recuperacion 0.219 0.073 3.021 0.003 0.226 0.226
## .energia 0.339 0.168 2.015 0.044 0.120 0.120
## .vigor 0.536 0.085 6.327 0.000 0.189 0.189
## .dedicacion 0.102 0.090 1.142 0.253 0.029 0.029
## .absorcion 0.472 0.112 4.233 0.000 0.183 0.183
## .engagement 1.243 0.172 7.213 0.000 0.540 0.540
## ambiente 0.753 0.172 4.381 0.000 1.000 1.000
lavaanPlot(model = fit4, coefs = TRUE, covs = TRUE)