library(psych) library(lavaan) library(mirt) library(semPlot) library(semTools) library(SBSDiff) pacman::p_load(tidyverse, lavaan, semPlot) devtools::install_github("simsem/semTools/semTools") library(semTools) library(pacman) names(ADAPTACIÓN_COPE) da<-ADAPTACIÓN_COPE ## MODELO DE LOS 4 ESTILOS DE AFRONTAMIENTO My_model1<-'Afrocognit=~P2+P3+P6+P10+P14+P18+P21+P26 Apoyosoc=~P1+P9+P17+P28 Bloqueo=~P13+P5+P4+P22+P8+P27+P11+P25+P12+P23+P15+P24+P7+P19 Afronespirtu=~P16+P20' My_model2<-'Afrocognit=~P2+P6+P10+P14+P18+P26 Apoyosoc=~P1+P9+P17+P28 Bloqueo=~P12+P15+P24+P25+P27+P7+P19 Afronespirtu=~P16+P20' ## MODELO FINAL (17 ITEMS 4 ESTILOS) My_model3<-'Afrocognit=~P2+P6+P10+P14+P18 Apoyosoc=~P1+P9+P17+P28 Bloqueo=~P12+P15+P22+P24+P25+P27 Afronespirtu=~P16+P20' ## MODELO DE LAS ESTRATEGIAS DE AFRONTAMIENTO ## MODELO DE 12 ESTRATEGIAS DE AFRONTAMIENTO. My_model4<-'activo=~P2+P10 Planif=~P6+P26 Reevpost=~P14+P18 Apoyemoc=~P9+P17 Apoysocia=~P1+P28 Autodistr=~P4+P22 Autoincul=~P8+P27 Desconex=~P11+P25 Desahog=~P12+P23 Usodesust=~P15+P24 EstrHumor=~P7+P19 Religi=~P16+P20' ## MODELO DE DE 13 ESTRATEGIAS DE AFONTAMIENTO My_model5<-'activo=~P2+P10 Planif=~P6+P26 Reevpost=~P14+P18 Apoyemoc=~P9+P17 Apoysocia=~P1+P28 Negaci=~P13+P5 Autodistr=~P4+P22 Autoincul=~P8+P27 Desconex=~P11+P25 Desahog=~P12+P23 Usodesust=~P15+P24 afrontHumor=~P7+P19 Religi=~P16+P20' ### MODELO DE 10 FACTORES O ESTRATEGIAS My_model6<-'activo=~P2+P10 Planif=~P6+P26 Reevpost=~P14+P18 Apoyemoc=~P9+P17 Apoysocia=~P1+P28 Autodistr=~P4+P22 Desconex=~P11+P25 Usodesust=~P15+P24 EstrHumor=~P7+P19 Religi=~P16+P20' fit<-cfa(model = My_model3, data = da, estimator="WLSMV",mimic= "Mplus", ordered = TRUE ) summary(fit, fit.measures = TRUE, standardized=T) #INFORME CARGAS FACTORIALES standardizedSolution(fit) %>% filter(op == "=~") %>% relocate(ci.lower, ci.upper, .after = "est.std") %>% mutate( pvalue = scales::pvalue(pvalue, accuracy = .001, prefix = c("< ", "", "> ")), pvalue = stringr::str_replace(pvalue, "0.", ".") ) # MODELO ESTRCUTURAL semPaths(fit,what="std",residuals=FALSE, nCharNodes = 0,edge.label.cex =1,legend=FALSE, style = "lisrel", layaut="tree",rotation = 2, sizeLat=5,sizeMan = 5,layout = "tree", whatLabels = "std") semPlot::semPaths(fit, whatLabels = "std", label.cex= 0.9, label.prop = 0.8, edge.label.cex = 0.8, nCharEdges = 3, nCharNodes = 0, sizeLat = 10, sizeLat2 = 5, sizeMan = 6, sizeMan2 = 2.2, rotation = 2, intercepts = FALSE, thresholds = FALSE, groups = "latents", pastel = TRUE, exoVar = FALSE, edge.color = "black", curvature = 3, curve = 1.1, manifests = rev(fit@pta[["vnames"]][["ov"]][[1]]), latents = rev(fit@pta[["vnames"]][["lv"]][[1]]), mar = c(1, 15, 3.5, 15), layout = "tree2") X11() semTools::reliability(fit)