if (FALSE) {
# Example of PATHMOX approach in customer satisfaction analysis 
# (Spanish financial company).
# Model with 5 LVs (4 common factor: Image (IMAG), Value (VAL), 
# Satisfaction (SAT), and Loyalty (LOY); and 1 composite construct: 
# Quality (QUAL)
# Load library and dataset csibank
library(genpathmx)
data("csibank")
# Define the model using the laavan syntax. Use a set of regression formulas that define 
# first the structural model and then the measurement model
CSImodel <- "
# Structural model
VAL  ~ QUAL
SAT  ~ IMAG  + QUAL + VAL
LOY  ~ IMAG + SAT
# Measurement model
# composite
QUAL <~ qual1 + qual2 + qual3 + qual4 + qual5 + qual6 + qual7 
     
# common factor
IMAG =~ imag1 + imag2 + imag3 + imag4 + imag5 + imag6 
VAL  =~ val1  + val2  + val3  + val4
SAT  =~ sat1  + sat2  + sat3           
LOY  =~ loy1  + loy2  + loy3          
"
# Identify the categorical variable to be used as input variables 
# in the split process
CSIcatvar = csibank[,1:5]
# Check if variables are well specified (they have to be factors 
# and/or ordered factors)
str(CSIcatvar)
# Transform Age and Education into ordered factors
CSIcatvar$Age = factor(CSIcatvar$Age, levels = c("<=25", 
                                     "26-35", "36-45", "46-55", 
                                     "56-65", ">=66"),ordered = T)
CSIcatvar$Education = factor(CSIcatvar$Education, 
                            levels = c("Unfinished","Elementary", "Highschool",
                            "Undergrad", "Graduated"),ordered = T)
       
# Run Pathmox analysis (Lamberti et al., 2016; 2017)
csi.pathmox = pls.pathmox(
 .model = CSImodel ,
 .data  = csibank,
 .catvar= CSIcatvar,
 .alpha = 0.05,
 .deep = 2
)                     
                      
# Visualize results by summary
# summary(csi.pathmox)
# Run pathmox on one single variable
age = csibank[,2]
#' # Transform Age into an ordered factor
age = factor(age, levels = c("<=25", 
                                     "26-35", "36-45", "46-55", 
                                     "56-65", ">=66"),ordered = T)
csi.pathmox.age = pls.pathmox(
 .model = CSImodel ,
 .data  = csibank,
 .catvar= age,
 .alpha = 0.05,
 .deep = 1
)  
# Run hybrid multigroup analysis (Lamberti, 2021) using 
# the cSEM package (Rademaker and Schuberth, 2020)
# Install and load cSEM library
# Install.packages("cSEM")
# library(cSEM)
# Run cSEM Model for Pathmox terminal nodes
csilocalmodel = csem(
 .model = CSImodel,
 .data = csi.pathmox.age$hybrid)
# Check invariance and run MGA analysis (Hair et al., 2019)
testMICOM(csilocalmodel, .R = 60)
to_compare <- "
#' # Structural model
VAL  ~ QUAL
SAT  ~ IMAG  + QUAL + VAL
LOY  ~ IMAG + SAT
"
testMGD(csilocalmodel, .parameters_to_compare = to_compare, 
.R_bootstrap = 60,.approach_mgd = "Henseler")
}
Run the code above in your browser using DataLab