Sunday, April 25, 2021

Multigroup Analysis for SEM

 #R 3.6 version is needed for MGA analysis 

#More than two option in a variable Mga is not possible

#install.packages("devtools") 

#library(devtools)

# install "plspm"

#install_github("gastonstat/plspm")

# load plspm

library(plspm)

#require(plspm)

dataset <- read.csv(file.choose())


#make a model

CO=c(0,0,0,0,0)

AT=c(1,0,0,0,0)

SN=c(1,0,0,0,0)

PBC=c(1,0,0,0,0)

PMO=c(0,1,1,1,0)


x=rbind(CO,AT,SN,PBC,PMO)

colnames(x)=rownames(x)

innerplot(x, arr.pos=.6)   #plot the data



out=list(6:9, 10:12, 13:17, 18:21, 22:23)


################

#running modle for total:

xx=plspm(dataset, x, out,

         scheme="path",

         boot.val=T, br=1247)


#Multigroup Analysis using bootstrap 

plspm.groups(xx, dataset$gender,

             method="bootstrap",

             reps=500)

#a

#Multigroup Analysis using bootstrap

plspm.groups(xx, as.factor(gender),

             method="bootstrap",

             reps=500)


#Multigroup Analysis using bootstrap

plspm.groups(xx, dataset$Education.level,

             method="bootstrap",

             reps=500)

#Multigroup Analysis using bootstrap

plspm.groups(xx, dataset$income,

             method="bootstrap",

             reps=500)

#Multigroup Analysis using bootstrap

plspm.groups(xx, dataset$living,

             method="bootstrap",

             reps=500)



0 comments:

Post a Comment