############################################################################# 
#                                                                           #                            
#  Copyright: Florian Schuberth                                             #
#  Contact: f.schuberth@utwente.nl                                          #
#                                                                           #
############################################################################# 
# Load cSEM:
library(cSEM)

# Specify model
# Second-order constructs can be specified with the <~ or =~ command.
model_HOC='
# Measurement models
PR =~ PR1 + PR2 + PR3
IM =~ IM1 + IM2 + IM3
DI =~ DI1 + DI2 + DI3
AD =~ AD1 + AD2 + AD3
DL =~ DL1 + DL2 + DL3

# Dimensions forming the second-order construct, i.e., dimensions of brand equity
AA =~ AA1 + AA2 + AA3 + AA4 + AA5 + AA6
LO =~ LO1 + LO3
QL =~ QL1 + QL2 + QL3 + QL4 + QL5 + QL6

# SOC emergent variable (brand equity)
BE <~ QL + LO + AA

# Structural model
BE~ PR + IM + DI + AD + DL
'

# Estimate the model. 
# Internally the three-stage approach proposed by Van Riel et al. (2017) is applied.
out <- csem(.data = Yooetal2000, .model = model_HOC,
            .PLS_weight_scheme_inner = 'factorial',
            .tolerance = 1e-06,
            .resample_method = 'bootstrap'
)


summarize(out)