# principles and practice of sem, 5th ed. # rex b. kline, guilford press, 2023 # chapter 16, table 16.2, analysis 5 # cca of a composite model with the ML estimator # for henseler–ogasawara (ho) specification # to avoid the problem that some R packages share the same name # for different functions, all functions are specified next as # package::function # which prevents masking, or the default hiding of # a function with a redundant name from a package used next date() v <- R.Version() print(paste0(v$language, " version ", v$major, ".", v$minor, " (", v$year, "-", v$month, "-", v$day, ")")) library(lavaan) # get citation information citation("lavaan", auto = TRUE) # input the correlations in lower diagnonal form shenLower.cor <- ' 1.00 .44 1.00 .69 .54 1.00 .21 .08 .16 1.00 .23 .15 .19 .19 1.00 .12 .08 .08 .08 -.03 1.00 .09 .06 .04 .01 -.02 .38 1.00 .03 .02 -.02 -.07 -.11 .37 .46 1.00 ' # name the variables and convert to full correlation matrix shen.cor <- lavaan::getCov(shenLower.cor, names = c("acculscl", "status", "percent", "educ", "income", "interpers", "job", "scl90d")) # add the standard deviations and convert to covariances shen.cov <- lavaan::cor2cov(shen.cor, sds = c(3.60,3.30,2.45,3.27,3.44,2.99, 3.58,3.70)) # display correlations and covariances options(width = 130) shen.cor shen.cov # ho specification # excrescent variables, ex1 to ex4 # error variances of all indicators fixed to zero # start values of zero are needed for two indicators # of the acculturation composite for estimation # to normally converge shenHO.model <- ' # composites, excrescent variables, and indicators # acculturation Acculturation =~ acculscl+ start(0)*percent+ start(0)*status ex1 =~ percent + acculscl + status ex2 =~ status + acculscl + 0*percent acculscl ~~ 0*acculscl percent ~~ 0*percent status ~~ 0*status # SES SES =~ educ + income ex4 =~ income + educ educ ~~ 0*educ income ~~ 0*income # stress Stress =~ interpers + job ex3 =~ job + interpers interpers ~~ 0*interpers job ~~ 0*job # depression, fix indicator error variance # to 1.369 Depression =~ scl90d scl90d ~~ 1.369*scl90d # covariance between SES and acculturation # is a free parameter Acculturation ~~ SES # constrain covariances to zero ex1 ~~ 0*Acculturation + 0*Stress + 0*SES + 0*Depression + 0*ex2 + 0*ex3 + 0*ex4 ex2 ~~ 0*Acculturation + 0*Stress + 0*SES + 0*Depression + 0*ex3 + 0*ex4 ex3 ~~ 0*Acculturation + 0*Stress + 0*SES + 0*Depression + 0*ex4 ex4 ~~ 0*Acculturation + 0*Stress + 0*SES + 0*Depression # structural model Stress ~ a*Acculturation Depression ~ b*Stress + SES # define indirect effect ab := a * b ' # fit ho-specified model to data # estimates for excrescent variables have # no interpretive value shenHO = lavaan::sem(model = shenHO.model, sample.cov = shen.cov, sample.nobs = 983) lavaan::summary(shenHO, standardized = TRUE, fit.measures = TRUE, rsquare = TRUE) # predicted covariances lavaan::fitted(shenHO) # predicted correlations lavaan::lavInspect(shenHO, "cor.lv") lavaan::lavInspect(shenHO, "cor.ov") # residuals lavaan::residuals(shenHO, type = "raw") lavaan::residuals(shenHO, type = "standardized.mplus") lavaan::residuals(shenHO, type = "cor.bollen")