library("foreign") library("psych") library("lavaan") library("semTools") library("semPlot") rm(list = ls()) Mydata=read.spss("ECPP.sav",to.data.frame=T,use.value.labels=F) #Mydata=subset(Mydata,DeEstudio==1) ###...Estableciendo el modelo Mymodel<-' Impescol =~ cp04+cp11+cp13+cp15+cp21 Dedipers =~ cp05+cp09+cp10+cp12+cp20 Ociocomp =~ cp06+cp07+cp08+cp19 Aseorien =~ cp14+cp16+cp17+cp18 Asunpama =~ cp01+cp02+cp03+cp22' #############...WLSMV estimator y summary......########### #sem.fit = sem(Mymodel,estimator="MLR",data=Mydata) sem.fit = sem(Mymodel,ordered=names(Mydata),estimator="WLSMV",data=Mydata) summary(sem.fit,fit.measures=T,standardized=T,nd=3) semPaths(sem.fit,whatLabels="std",layout="tree",edge.label.cex=0.9,rotation=2,nCharNodes=15, sizeLat=7,sizeMan=7,style="lisrel") head(modificationindices(sem.fit)[order((modificationindices(sem.fit))$mi,decreasing=TRUE),],15) #############...Matrices de correlaciones polic?ricas......########### Vars.for.correl<-c('cp01','cp02','cp03','cp04','cp05','cp06','cp07','cp08','cp09','cp10','cp11','cp12','cp13', 'cp14','cp15','cp16','cp17','cp18','cp19','cp20','cp21','cp22') Mydataforcorrel<-Mydata[Vars.for.correl] #Correlaciones polic?ricas round(polychoric(Mydataforcorrel)$rho,2) #Correlaciones pearson round(cor(Mydataforcorrel),2) ####################### (normalidad multivariada) library(MVN) result <- mvn(data = Mydataforcorrel, mvnTest = "mardia") result #fitmeasures(sem.fit)