The introduction composed on Lecture Notes from authors: Michael
Zyphur, Lesa Hoffman and Johnny Lin;
Review of SEM;
Read correlation/covariance matrix as input in Mplus & lavaan
(R);
Run SEM in Mplus & lavaan (R);
Model fit indices
Specification (estimating in our models) \(\Rightarrow\) Measurement model specification (relationships among observed and latent variables, including variances and covariance) \(\Rightarrow\) Structural model specification (classic regression relationships among (latent) variables of substantive interest)
SEM = measurement model + structural model
SEM solves two regression problems:
Quick reference of
lavaan
syntax
Introduce some of the most frequently used syntax in lavaan
Model in Mplus:
f1 BY y1-y3;
f2 BY y4-y6;
f2 ON f1;
Model in lavaan (R):
f1 =~ y1+y2+y3
f2 =~ y4+y5+y6
f2 ~ f1
! Required code to estimate regression
paths
D ON A B;
E ON D C;
F ON E;
! Outcome intercepts and residual variances
estimated by default
[D E F]; D E
! To bring A, B, and C predictors into the
likelihood,
! Request their covariances
A B C WITH A B C;
! Predictor means and variances then estimated
by default
[A B C]; A B C;
D ~ A+B
E ~ D+C
F ~ E
D ~ 1; D ~~ D
A B C ~~ A B C
A ~ 1; A~~A
Refer more in Web Page (2022)
How set up in Mplus to run FIML:
2-step (Anderson and Gerbing (1988))
4-step (Mulaik and Millsap (2000), Hayduk and Glaser (2000), and Bollen (2000))
Mathieu and Farr (1991) article about “Further evidence for the discriminant validity of measures of organizational commitment, job involvement, and job satisfaction”
print("Mathieu & Farr 1991.txt")
[1] "Mathieu & Farr 1991.txt"
writeLines(readLines("Mathieu & Farr 1991.txt"))
5.58 4.89 3.76 4.35 3.82 3.87 5.19 5.07 5.14 3.32 3.44 3.14 6.7 6.29 6.69 6.45 6.25 6.69 1.6 5.95 11.3 37.32
.89 1 1.11 1.1 1.31 1.11 .86 .88 .89 .43 .4 .41 .85 .92 .77 1.11 1.11 1.09 1.05 6.18 8.62 9.92
1
.76 1
.67 .68 1
.26 .2 .22 1
.28 .25 .17 .43 1
.34 .33 .26 .52 .52 1
.57 .57 .55 .09 .2 .21 1
.55 .53 .55 .16 .2 .21 .84 1
.48 .46 .49 .15 .23 .21 .79 .71 1
.36 .31 .31 .14 .13 .16 .46 .42 .48 1
.42 .36 .38 .15 .12 .14 .51 .5 .5 .7 1
.32 .34 .37 .11 .13 .13 .47 .46 .46 .65 .64 1
.21 .19 .13 .14 .18 .15 .31 .29 .31 .32 .5 .1 1
.21 .17 .1 .14 .16 .15 .25 .23 .29 .37 .25 .17 .81 1
.22 .18 .12 .15 .14 .12 .33 .29 .31 .39 .29 .15 .82 .82 1
.15 .13 .02 .23 .13 .18 .09 .07 .04 .19 .16 .08 .23 .15 .14 1
.16 .09 -.01 .17 .07 .05 .09 .09 .07 .25 .24 .16 .22 .28 .19 .59 1
.14 .09 -.01 .13 .04 .06 .07 .05 .07 .2 .17 .09 .22 .19 .23 .59 .62 1
.06 .09 .01 .07 .11 .16 .09 .1 .04 .14 .04 .05 .2 .19 .15 .15 .17 .15 1
.03 .06 .1 .17 .19 .17 .02 .01 .1 .15 .04 .09 .03 .05 .06 .1 .16 .07 .1 1
.1 .09 .1 .1 .16 .15 -.001 .02 .04 .12 .05 -.01 .03 .03 .05 .001 .18 .02 .05 .52 1
.14 .1 .12 .07 .15 .17 -.01 .01 -.001 .12 .03 .06 .1 .01 .12 .06 .18 .04 .07 .46 .8 1
::opts_chunk$set(engine.path = list(
knitrmplus = "C:/Program Files/Mplus/Mplus"
))
::knit_engines$set(mplus = function(options) {
knitr<- paste(options$code, collapse = "\n")
code <-file("formplus.inp")
fileConnwriteLines(code, fileConn)
close(fileConn)
<- system2("C:/Program Files/Mplus/Mplus", "formplus.inp")
out <- file("formplus.out")
fileConnOutput <- readLines(fileConnOutput)
mplusOutput ::engine_output(options, code, mplusOutput)
knitr })
Title: CFA Example
Data: File is Mathieu & Farr 1991.txt;
Type is Means Stdeviations Correlation;
Nobservations = 483;
Variable:
Names are
OC1 OC2 OC3 ! Organizational commitment
JI1 JI2 JI3 ! Job involvement
SAT1 SAT2 SAT3 ! Job satisfaction
JS1 JS2 JS3 ! Job scope
SELF1 SELF2 SELF3 ! Self ratings of performance
SUPR1 SUPR2 SUPR3 ! Supervisor ratings of performance
Education
PostTen ! Position tenure
OrgTen ! Organizational tenure
Age;
UseVariables are OC1-OC3 SAT1-SAT3
JS1-JS3 SUPR1-SUPR3 Education;
Analysis:
Model:
OC by OC1 OC2 OC3;
SAT by SAT1 SAT2 SAT3;
JS by JS1 JS2 JS3;
PERF by SUPR1 SUPR2 SUPR3;
PERF on OC SAT JS Education;
OC on SAT;
SAT on JS;
Output: Tech1 Tech8 standardized sampstat;
Mplus VERSION 8.6
MUTHEN & MUTHEN
02/25/2023 12:47 AM
INPUT INSTRUCTIONS
Title: CFA Example
Data: File is Mathieu & Farr 1991.txt;
Type is Means Stdeviations Correlation;
Nobservations = 483;
Variable:
Names are
OC1 OC2 OC3 ! Organizational commitment
JI1 JI2 JI3 ! Job involvement
SAT1 SAT2 SAT3 ! Job satisfaction
JS1 JS2 JS3 ! Job scope
SELF1 SELF2 SELF3 ! Self ratings of performance
SUPR1 SUPR2 SUPR3 ! Supervisor ratings of performance
Education
PostTen ! Position tenure
OrgTen ! Organizational tenure
Age;
UseVariables are OC1-OC3 SAT1-SAT3
JS1-JS3 SUPR1-SUPR3 Education;
Analysis:
Model:
OC by OC1 OC2 OC3;
SAT by SAT1 SAT2 SAT3;
JS by JS1 JS2 JS3;
PERF by SUPR1 SUPR2 SUPR3;
PERF on OC SAT JS Education;
OC on SAT;
SAT on JS;
Output: Tech1 Tech8 standardized sampstat;
*** WARNING in VARIABLE command
Note that only the first 8 characters of variable names are used in the output.
Shorten variable names to avoid any confusion.
*** WARNING in OUTPUT command
TECH8 option is available only with analysis types MIXTURE, RANDOM, or
TWOLEVEL with estimators ML, MLF, or MLR or ALGORITHM=INTEGRATION.
Request for TECH8 is ignored.
2 WARNING(S) FOUND IN THE INPUT INSTRUCTIONS
CFA Example
SUMMARY OF ANALYSIS
Number of groups 1
Number of observations 483
Number of dependent variables 12
Number of independent variables 1
Number of continuous latent variables 4
Observed dependent variables
Continuous
OC1 OC2 OC3 SAT1 SAT2 SAT3
JS1 JS2 JS3 SUPR1 SUPR2 SUPR3
Observed independent variables
EDUCATIO
Continuous latent variables
OC SAT JS PERF
Estimator ML
Information matrix EXPECTED
Maximum number of iterations 1000
Convergence criterion 0.500D-04
Maximum number of steepest descent iterations 20
Input data file(s)
Mathieu & Farr 1991.txt
Input data format FREE
SAMPLE STATISTICS
SAMPLE STATISTICS
Means/Intercepts/Thresholds
OC1 OC2 OC3 SAT1 SAT2
________ ________ ________ ________ ________
5.580 4.890 3.760 5.190 5.070
Means/Intercepts/Thresholds
SAT3 JS1 JS2 JS3 SUPR1
________ ________ ________ ________ ________
5.140 3.320 3.440 3.140 6.450
Means/Intercepts/Thresholds
SUPR2 SUPR3 EDUCATIO
________ ________ ________
6.250 6.690 1.600
Covariances/Correlations/Residual Correlations
OC1 OC2 OC3 SAT1 SAT2
________ ________ ________ ________ ________
OC1 0.792
OC2 0.676 1.000
OC3 0.662 0.755 1.232
SAT1 0.436 0.490 0.525 0.740
SAT2 0.431 0.466 0.537 0.636 0.774
SAT3 0.380 0.409 0.484 0.605 0.556
JS1 0.138 0.133 0.148 0.170 0.159
JS2 0.150 0.144 0.169 0.175 0.176
JS3 0.117 0.139 0.168 0.166 0.166
SUPR1 0.148 0.144 0.025 0.086 0.068
SUPR2 0.158 0.100 -0.012 0.086 0.088
SUPR3 0.136 0.098 -0.012 0.066 0.048
EDUCATIO 0.056 0.095 0.012 0.081 0.092
Covariances/Correlations/Residual Correlations
SAT3 JS1 JS2 JS3 SUPR1
________ ________ ________ ________ ________
SAT3 0.792
JS1 0.184 0.185
JS2 0.178 0.120 0.160
JS3 0.168 0.115 0.105 0.168
SUPR1 0.040 0.091 0.071 0.036 1.232
SUPR2 0.069 0.119 0.107 0.073 0.727
SUPR3 0.068 0.094 0.074 0.040 0.714
EDUCATIO 0.037 0.063 0.017 0.022 0.175
Covariances/Correlations/Residual Correlations
SUPR2 SUPR3 EDUCATIO
________ ________ ________
SUPR2 1.232
SUPR3 0.750 1.188
EDUCATIO 0.198 0.172 1.103
THE MODEL ESTIMATION TERMINATED NORMALLY
MODEL FIT INFORMATION
Number of Free Parameters 42
Loglikelihood
H0 Value -5138.829
H1 Value -5075.557
Information Criteria
Akaike (AIC) 10361.657
Bayesian (BIC) 10537.218
Sample-Size Adjusted BIC 10403.913
(n* = (n + 2) / 24)
Chi-Square Test of Model Fit
Value 126.544
Degrees of Freedom 60
P-Value 0.0000
RMSEA (Root Mean Square Error Of Approximation)
Estimate 0.048
90 Percent C.I. 0.036 0.060
Probability RMSEA <= .05 0.599
CFI/TLI
CFI 0.981
TLI 0.976
Chi-Square Test of Model Fit for the Baseline Model
Value 3614.872
Degrees of Freedom 78
P-Value 0.0000
SRMR (Standardized Root Mean Square Residual)
Value 0.040
MODEL RESULTS
Two-Tailed
Estimate S.E. Est./S.E. P-Value
OC BY
OC1 1.000 0.000 999.000 999.000
OC2 1.124 0.049 22.934 0.000
OC3 1.128 0.056 20.156 0.000
SAT BY
SAT1 1.000 0.000 999.000 999.000
SAT2 0.949 0.031 30.970 0.000
SAT3 0.900 0.034 26.719 0.000
JS BY
JS1 1.000 0.000 999.000 999.000
JS2 0.950 0.048 19.671 0.000
JS3 0.886 0.049 17.969 0.000
PERF BY
SUPR1 1.000 0.000 999.000 999.000
SUPR2 1.071 0.073 14.751 0.000
SUPR3 1.028 0.070 14.666 0.000
PERF ON
OC 0.115 0.084 1.370 0.171
SAT -0.207 0.093 -2.214 0.027
JS 0.800 0.173 4.620 0.000
OC ON
SAT 0.667 0.041 16.421 0.000
SAT ON
JS 1.471 0.107 13.733 0.000
PERF ON
EDUCATION 0.145 0.038 3.781 0.000
Intercepts
OC1 5.580 0.040 137.933 0.000
OC2 4.890 0.045 107.581 0.000
OC3 3.760 0.050 74.523 0.000
SAT1 5.190 0.039 132.768 0.000
SAT2 5.070 0.040 126.751 0.000
SAT3 5.140 0.040 127.057 0.000
JS1 3.320 0.020 169.861 0.000
JS2 3.440 0.018 189.200 0.000
JS3 3.140 0.019 168.488 0.000
SUPR1 6.219 0.079 78.778 0.000
SUPR2 6.002 0.082 73.107 0.000
SUPR3 6.452 0.080 81.098 0.000
Variances
JS 0.127 0.012 10.489 0.000
Residual Variances
OC1 0.195 0.021 9.514 0.000
OC2 0.246 0.026 9.479 0.000
OC3 0.473 0.038 12.491 0.000
SAT1 0.072 0.012 6.089 0.000
SAT2 0.173 0.015 11.389 0.000
SAT3 0.250 0.019 13.186 0.000
JS1 0.058 0.006 10.172 0.000
JS2 0.046 0.005 9.427 0.000
JS3 0.068 0.006 12.061 0.000
SUPR1 0.547 0.050 11.028 0.000
SUPR2 0.446 0.049 9.106 0.000
SUPR3 0.464 0.047 9.814 0.000
OC 0.298 0.029 10.122 0.000
SAT 0.392 0.033 11.982 0.000
PERF 0.595 0.071 8.417 0.000
QUALITY OF NUMERICAL RESULTS
Condition Number for the Information Matrix 0.496E-03
(ratio of smallest to largest eigenvalue)
STANDARDIZED MODEL RESULTS
STDYX Standardization
Two-Tailed
Estimate S.E. Est./S.E. P-Value
OC BY
OC1 0.868 0.016 53.099 0.000
OC2 0.868 0.016 53.248 0.000
OC3 0.784 0.021 37.284 0.000
SAT BY
SAT1 0.950 0.009 106.178 0.000
SAT2 0.881 0.013 69.396 0.000
SAT3 0.827 0.016 50.580 0.000
JS BY
JS1 0.828 0.020 41.273 0.000
JS2 0.845 0.019 43.921 0.000
JS3 0.770 0.023 33.257 0.000
PERF BY
SUPR1 0.743 0.028 26.563 0.000
SUPR2 0.797 0.026 30.319 0.000
SUPR3 0.779 0.027 29.027 0.000
PERF ON
OC 0.108 0.078 1.377 0.169
SAT -0.205 0.092 -2.238 0.025
JS 0.346 0.070 4.912 0.000
OC ON
SAT 0.706 0.028 25.614 0.000
SAT ON
JS 0.641 0.032 19.908 0.000
PERF ON
EDUCATION 0.185 0.047 3.893 0.000
Intercepts
OC1 6.276 0.207 30.320 0.000
OC2 4.895 0.164 29.859 0.000
OC3 3.391 0.118 28.686 0.000
SAT1 6.041 0.200 30.262 0.000
SAT2 5.767 0.191 30.186 0.000
SAT3 5.781 0.191 30.190 0.000
JS1 7.729 0.253 30.573 0.000
JS2 8.609 0.281 30.669 0.000
JS3 7.666 0.251 30.565 0.000
SUPR1 5.623 0.206 27.316 0.000
SUPR2 5.429 0.202 26.917 0.000
SUPR3 5.943 0.217 27.434 0.000
Variances
JS 1.000 0.000 999.000 999.000
Residual Variances
OC1 0.247 0.028 8.723 0.000
OC2 0.246 0.028 8.694 0.000
OC3 0.385 0.033 11.653 0.000
SAT1 0.098 0.017 5.745 0.000
SAT2 0.224 0.022 10.002 0.000
SAT3 0.317 0.027 11.730 0.000
JS1 0.314 0.033 9.447 0.000
JS2 0.285 0.033 8.760 0.000
JS3 0.408 0.036 11.441 0.000
SUPR1 0.447 0.042 10.750 0.000
SUPR2 0.365 0.042 8.714 0.000
SUPR3 0.394 0.042 9.426 0.000
OC 0.501 0.039 12.872 0.000
SAT 0.589 0.041 14.243 0.000
PERF 0.881 0.034 25.794 0.000
STDY Standardization
Two-Tailed
Estimate S.E. Est./S.E. P-Value
OC BY
OC1 0.868 0.016 53.099 0.000
OC2 0.868 0.016 53.248 0.000
OC3 0.784 0.021 37.284 0.000
SAT BY
SAT1 0.950 0.009 106.178 0.000
SAT2 0.881 0.013 69.396 0.000
SAT3 0.827 0.016 50.580 0.000
JS BY
JS1 0.828 0.020 41.273 0.000
JS2 0.845 0.019 43.921 0.000
JS3 0.770 0.023 33.257 0.000
PERF BY
SUPR1 0.743 0.028 26.563 0.000
SUPR2 0.797 0.026 30.319 0.000
SUPR3 0.779 0.027 29.027 0.000
PERF ON
OC 0.108 0.078 1.377 0.169
SAT -0.205 0.092 -2.238 0.025
JS 0.346 0.070 4.912 0.000
OC ON
SAT 0.706 0.028 25.614 0.000
SAT ON
JS 0.641 0.032 19.908 0.000
PERF ON
EDUCATION 0.176 0.045 3.921 0.000
Intercepts
OC1 6.276 0.207 30.320 0.000
OC2 4.895 0.164 29.859 0.000
OC3 3.391 0.118 28.686 0.000
SAT1 6.041 0.200 30.262 0.000
SAT2 5.767 0.191 30.186 0.000
SAT3 5.781 0.191 30.190 0.000
JS1 7.729 0.253 30.573 0.000
JS2 8.609 0.281 30.669 0.000
JS3 7.666 0.251 30.565 0.000
SUPR1 5.623 0.206 27.316 0.000
SUPR2 5.429 0.202 26.917 0.000
SUPR3 5.943 0.217 27.434 0.000
Variances
JS 1.000 0.000 999.000 999.000
Residual Variances
OC1 0.247 0.028 8.723 0.000
OC2 0.246 0.028 8.694 0.000
OC3 0.385 0.033 11.653 0.000
SAT1 0.098 0.017 5.745 0.000
SAT2 0.224 0.022 10.002 0.000
SAT3 0.317 0.027 11.730 0.000
JS1 0.314 0.033 9.447 0.000
JS2 0.285 0.033 8.760 0.000
JS3 0.408 0.036 11.441 0.000
SUPR1 0.447 0.042 10.750 0.000
SUPR2 0.365 0.042 8.714 0.000
SUPR3 0.394 0.042 9.426 0.000
OC 0.501 0.039 12.872 0.000
SAT 0.589 0.041 14.243 0.000
PERF 0.881 0.034 25.794 0.000
STD Standardization
Two-Tailed
Estimate S.E. Est./S.E. P-Value
OC BY
OC1 0.771 0.034 22.930 0.000
OC2 0.867 0.038 22.957 0.000
OC3 0.870 0.044 19.799 0.000
SAT BY
SAT1 0.816 0.030 27.461 0.000
SAT2 0.775 0.032 24.210 0.000
SAT3 0.735 0.034 21.915 0.000
JS BY
JS1 0.356 0.017 20.978 0.000
JS2 0.338 0.016 21.597 0.000
JS3 0.315 0.017 18.955 0.000
PERF BY
SUPR1 0.822 0.048 17.215 0.000
SUPR2 0.881 0.047 18.653 0.000
SUPR3 0.845 0.047 18.158 0.000
PERF ON
OC 0.108 0.078 1.377 0.169
SAT -0.205 0.092 -2.238 0.025
JS 0.346 0.070 4.912 0.000
OC ON
SAT 0.706 0.028 25.614 0.000
SAT ON
JS 0.641 0.032 19.908 0.000
PERF ON
EDUCATION 0.176 0.045 3.921 0.000
Intercepts
OC1 5.580 0.040 137.933 0.000
OC2 4.890 0.045 107.581 0.000
OC3 3.760 0.050 74.523 0.000
SAT1 5.190 0.039 132.768 0.000
SAT2 5.070 0.040 126.751 0.000
SAT3 5.140 0.040 127.057 0.000
JS1 3.320 0.020 169.861 0.000
JS2 3.440 0.018 189.200 0.000
JS3 3.140 0.019 168.488 0.000
SUPR1 6.219 0.079 78.778 0.000
SUPR2 6.002 0.082 73.107 0.000
SUPR3 6.452 0.080 81.098 0.000
Variances
JS 1.000 0.000 999.000 999.000
Residual Variances
OC1 0.195 0.021 9.514 0.000
OC2 0.246 0.026 9.479 0.000
OC3 0.473 0.038 12.491 0.000
SAT1 0.072 0.012 6.089 0.000
SAT2 0.173 0.015 11.389 0.000
SAT3 0.250 0.019 13.186 0.000
JS1 0.058 0.006 10.172 0.000
JS2 0.046 0.005 9.427 0.000
JS3 0.068 0.006 12.061 0.000
SUPR1 0.547 0.050 11.028 0.000
SUPR2 0.446 0.049 9.106 0.000
SUPR3 0.464 0.047 9.814 0.000
OC 0.501 0.039 12.872 0.000
SAT 0.589 0.041 14.243 0.000
PERF 0.881 0.034 25.794 0.000
R-SQUARE
Observed Two-Tailed
Variable Estimate S.E. Est./S.E. P-Value
OC1 0.753 0.028 26.549 0.000
OC2 0.754 0.028 26.624 0.000
OC3 0.615 0.033 18.642 0.000
SAT1 0.902 0.017 53.089 0.000
SAT2 0.776 0.022 34.698 0.000
SAT3 0.683 0.027 25.290 0.000
JS1 0.686 0.033 20.636 0.000
JS2 0.715 0.033 21.961 0.000
JS3 0.592 0.036 16.629 0.000
SUPR1 0.553 0.042 13.282 0.000
SUPR2 0.635 0.042 15.159 0.000
SUPR3 0.606 0.042 14.514 0.000
Latent Two-Tailed
Variable Estimate S.E. Est./S.E. P-Value
OC 0.499 0.039 12.807 0.000
SAT 0.411 0.041 9.954 0.000
PERF 0.119 0.034 3.484 0.000
TECHNICAL 1 OUTPUT
PARAMETER SPECIFICATION
NU
OC1 OC2 OC3 SAT1 SAT2
________ ________ ________ ________ ________
1 2 3 4 5
NU
SAT3 JS1 JS2 JS3 SUPR1
________ ________ ________ ________ ________
6 7 8 9 10
NU
SUPR2 SUPR3 EDUCATIO
________ ________ ________
11 12 0
LAMBDA
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
OC1 0 0 0 0 0
OC2 13 0 0 0 0
OC3 14 0 0 0 0
SAT1 0 0 0 0 0
SAT2 0 15 0 0 0
SAT3 0 16 0 0 0
JS1 0 0 0 0 0
JS2 0 0 17 0 0
JS3 0 0 18 0 0
SUPR1 0 0 0 0 0
SUPR2 0 0 0 19 0
SUPR3 0 0 0 20 0
EDUCATIO 0 0 0 0 0
THETA
OC1 OC2 OC3 SAT1 SAT2
________ ________ ________ ________ ________
OC1 21
OC2 0 22
OC3 0 0 23
SAT1 0 0 0 24
SAT2 0 0 0 0 25
SAT3 0 0 0 0 0
JS1 0 0 0 0 0
JS2 0 0 0 0 0
JS3 0 0 0 0 0
SUPR1 0 0 0 0 0
SUPR2 0 0 0 0 0
SUPR3 0 0 0 0 0
EDUCATIO 0 0 0 0 0
THETA
SAT3 JS1 JS2 JS3 SUPR1
________ ________ ________ ________ ________
SAT3 26
JS1 0 27
JS2 0 0 28
JS3 0 0 0 29
SUPR1 0 0 0 0 30
SUPR2 0 0 0 0 0
SUPR3 0 0 0 0 0
EDUCATIO 0 0 0 0 0
THETA
SUPR2 SUPR3 EDUCATIO
________ ________ ________
SUPR2 31
SUPR3 0 32
EDUCATIO 0 0 0
ALPHA
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
0 0 0 0 0
BETA
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
OC 0 33 0 0 0
SAT 0 0 34 0 0
JS 0 0 0 0 0
PERF 35 36 37 0 38
EDUCATIO 0 0 0 0 0
PSI
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
OC 39
SAT 0 40
JS 0 0 41
PERF 0 0 0 42
EDUCATIO 0 0 0 0 0
STARTING VALUES
NU
OC1 OC2 OC3 SAT1 SAT2
________ ________ ________ ________ ________
5.580 4.890 3.760 5.190 5.070
NU
SAT3 JS1 JS2 JS3 SUPR1
________ ________ ________ ________ ________
5.140 3.320 3.440 3.140 6.450
NU
SUPR2 SUPR3 EDUCATIO
________ ________ ________
6.250 6.690 0.000
LAMBDA
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
OC1 1.000 0.000 0.000 0.000 0.000
OC2 1.000 0.000 0.000 0.000 0.000
OC3 1.000 0.000 0.000 0.000 0.000
SAT1 0.000 1.000 0.000 0.000 0.000
SAT2 0.000 1.000 0.000 0.000 0.000
SAT3 0.000 1.000 0.000 0.000 0.000
JS1 0.000 0.000 1.000 0.000 0.000
JS2 0.000 0.000 1.000 0.000 0.000
JS3 0.000 0.000 1.000 0.000 0.000
SUPR1 0.000 0.000 0.000 1.000 0.000
SUPR2 0.000 0.000 0.000 1.000 0.000
SUPR3 0.000 0.000 0.000 1.000 0.000
EDUCATIO 0.000 0.000 0.000 0.000 1.000
THETA
OC1 OC2 OC3 SAT1 SAT2
________ ________ ________ ________ ________
OC1 0.396
OC2 0.000 0.500
OC3 0.000 0.000 0.616
SAT1 0.000 0.000 0.000 0.370
SAT2 0.000 0.000 0.000 0.000 0.387
SAT3 0.000 0.000 0.000 0.000 0.000
JS1 0.000 0.000 0.000 0.000 0.000
JS2 0.000 0.000 0.000 0.000 0.000
JS3 0.000 0.000 0.000 0.000 0.000
SUPR1 0.000 0.000 0.000 0.000 0.000
SUPR2 0.000 0.000 0.000 0.000 0.000
SUPR3 0.000 0.000 0.000 0.000 0.000
EDUCATIO 0.000 0.000 0.000 0.000 0.000
THETA
SAT3 JS1 JS2 JS3 SUPR1
________ ________ ________ ________ ________
SAT3 0.396
JS1 0.000 0.092
JS2 0.000 0.000 0.080
JS3 0.000 0.000 0.000 0.084
SUPR1 0.000 0.000 0.000 0.000 0.616
SUPR2 0.000 0.000 0.000 0.000 0.000
SUPR3 0.000 0.000 0.000 0.000 0.000
EDUCATIO 0.000 0.000 0.000 0.000 0.000
THETA
SUPR2 SUPR3 EDUCATIO
________ ________ ________
SUPR2 0.616
SUPR3 0.000 0.594
EDUCATIO 0.000 0.000 0.000
ALPHA
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
0.000 0.000 0.000 0.000 1.600
BETA
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
OC 0.000 0.000 0.000 0.000 0.000
SAT 0.000 0.000 0.000 0.000 0.000
JS 0.000 0.000 0.000 0.000 0.000
PERF 0.000 0.000 0.000 0.000 0.000
EDUCATIO 0.000 0.000 0.000 0.000 0.000
PSI
OC SAT JS PERF EDUCATIO
________ ________ ________ ________ ________
OC 0.050
SAT 0.000 0.050
JS 0.000 0.000 0.050
PERF 0.000 0.000 0.000 0.050
EDUCATIO 0.000 0.000 0.000 0.000 1.100
Beginning Time: 00:47:25
Ending Time: 00:47:25
Elapsed Time: 00:00:00
MUTHEN & MUTHEN
3463 Stoner Ave.
Los Angeles, CA 90066
Tel: (310) 391-9971
Fax: (310) 391-8971
Web: www.StatModel.com
Support: Support@StatModel.com
Copyright (c) 1998-2021 Muthen & Muthen
We have no full dataset, but do have a sample mean, standard
deviation and correlation matrix. Due to lavaan
supports covariance matrix as input but not correlation matrix, we
need to convert correlation matrix to covariance matrix to fit your
model.
First, I run SAS
(proc iml) for easier manipulate the correlation matrix transfer to
covariance matrix. However, we could use
rcompanion::fullPTable()
function in R to do the job.
# in SAS
PROC IML;/** convert correlation matrix to covariance matrix **/
={1 . . . . . . . . . . . . . . . . . . . . .,
lR76 1 . . . . . . . . . . . . . . . . . . . .,
.67 .68 1 . . . . . . . . . . . . . . . . . . .,
.26 .2 .22 1 . . . . . . . . . . . . . . . . . .,
.28 .25 .17 .43 1 . . . . . . . . . . . . . . . . .,
.34 .33 .26 .52 .52 1 . . . . . . . . . . . . . . . .,
.57 .57 .55 .09 .2 .21 1 . . . . . . . . . . . . . . .,
.55 .53 .55 .16 .2 .21 .84 1 . . . . . . . . . . . . . .,
.48 .46 .49 .15 .23 .21 .79 .71 1 . . . . . . . . . . . . .,
.36 .31 .31 .14 .13 .16 .46 .42 .48 1 . . . . . . . . . . . .,
.42 .36 .38 .15 .12 .14 .51 .5 .5 .7 1 . . . . . . . . . . .,
.32 .34 .37 .11 .13 .13 .47 .46 .46 .65 .64 1 . . . . . . . . . .,
.21 .19 .13 .14 .18 .15 .31 .29 .31 .32 .5 .1 1 . . . . . . . . .,
.21 .17 .1 .14 .16 .15 .25 .23 .29 .37 .25 .17 .81 1 . . . . . . . .,
.22 .18 .12 .15 .14 .12 .33 .29 .31 .39 .29 .15 .82 .82 1 . . . . . . .,
.15 .13 .02 .23 .13 .18 .09 .07 .04 .19 .16 .08 .23 .15 .14 1 . . . . . .,
.16 .09 -.01 .17 .07 .05 .09 .09 .07 .25 .24 .16 .22 .28 .19 .59 1 . . . . .,
.14 .09 -.01 .13 .04 .06 .07 .05 .07 .2 .17 .09 .22 .19 .23 .59 .62 1 . . . .,
.06 .09 .01 .07 .11 .16 .09 .1 .04 .14 .04 .05 .2 .19 .15 .15 .17 .15 1 . . .,
.03 .06 .1 .17 .19 .17 .02 .01 .1 .15 .04 .09 .03 .05 .06 .1 .16 .07 .1 1 . .,
.1 .09 .1 .1 .16 .15 -.001 .02 .04 .12 .05 -.01 .03 .03 .05 .001 .18 .02 .05 .52 1 .,
.14 .1 .12 .07 .15 .17 -.01 .01 -.001 .12 .03 .06 .1 .01 .12 .06 .18 .04 .07 .46 .8 1 };
.
=ncol(lR); * Number of columns in the lower triangular correlation matrix;
p=J(p,p,0); * Initialize the correlation matrix;
R=(lR`); * Transpose the lower triangular matrix to upper;
uRR=lR<>uR; * Select the max of the lower and upper matrices;
print R; * Complete correlation matrix;
/** standard deviations of each variable **/
c = {.89 1 1.11 1.1 1.31 1.11 .86 .88 .89 .43 .4 .41 .85 .92 .77 1.11 1.11 1.09 1.05 6.18 8.62 9.92};
D = diag(c);
S = D*R*D; /** covariance matrix **/
print S;
quit;
Second, load lavaan
library(lavaan)
Third, we read in the lower half of the covariance matrix (including the diagonal)
options(width = 300)
<- '
lower 0.7921
0.6764 1
0.661893 0.7548 1.2321
0.25454 0.22 0.26862 1.21
0.326452 0.3275 0.247197 0.61963 1.7161
0.335886 0.3663 0.320346 0.63492 0.756132 1.2321
0.436278 0.4902 0.52503 0.08514 0.22532 0.200466 0.7396
0.43076 0.4664 0.53724 0.15488 0.23056 0.205128 0.635712 0.7744
0.380208 0.4094 0.484071 0.14685 0.268157 0.207459 0.604666 0.556072 0.7921
0.137772 0.1333 0.147963 0.06622 0.073229 0.076368 0.170108 0.158928 0.183696 0.1849
0.14952 0.144 0.16872 0.066 0.06288 0.06216 0.17544 0.176 0.178 0.1204 0.16
0.116768 0.1394 0.168387 0.04961 0.069823 0.059163 0.165722 0.165968 0.167854 0.114595 0.10496 0.1681
0.158865 0.1615 0.122655 0.1309 0.20043 0.141525 0.22661 0.21692 0.234515 0.11696 0.17 0.03485 0.7225
0.171948 0.1564 0.10212 0.14168 0.192832 0.15318 0.1978 0.186208 0.237452 0.146372 0.092 0.064124 0.63342 0.8464
0.150766 0.1386 0.102564 0.12705 0.141218 0.102564 0.218526 0.196504 0.212443 0.129129 0.08932 0.047355 0.53669 0.580888 0.5929
0.148185 0.1443 0.024642 0.28083 0.189033 0.221778 0.085914 0.068376 0.039516 0.090687 0.07104 0.036408 0.217005 0.15318 0.119658 1.2321
0.158064 0.0999 -0.012321 0.20757 0.101787 0.061605 0.085914 0.087912 0.069153 0.119325 0.10656 0.072816 0.20757 0.285936 0.162393 0.726939 1.2321
0.135814 0.0981 -0.012099 0.15587 0.057116 0.072594 0.065618 0.04796 0.067907 0.09374 0.07412 0.040221 0.20383 0.190532 0.193039 0.713841 0.750138 1.1881
0.05607 0.0945 0.011655 0.08085 0.151305 0.18648 0.08127 0.0924 0.03738 0.06321 0.0168 0.021525 0.1785 0.18354 0.121275 0.174825 0.198135 0.171675 1.1025
0.165006 0.3708 0.68598 1.15566 1.538202 1.166166 0.106296 0.054384 0.55002 0.39861 0.09888 0.228042 0.15759 0.28428 0.285516 0.68598 1.097568 0.471534 0.6489 38.1924
0.76718 0.7758 0.95682 0.9482 1.806752 1.43523 -0.007413 0.151712 0.306872 0.444792 0.1724 -0.035342 0.21981 0.237912 0.33187 0.0095682 1.722276 0.187916 0.45255 27.701232 74.3044
1.236032 0.992 1.321344 0.76384 1.94928 1.871904 -0.085312 0.087296 -0.008829 0.511872 0.11904 0.244032 0.8432 0.091264 0.916608 0.660672 1.982016 0.432512 0.72912 28.200576 68.40832 98.4064 '
<-
mathieu.cov getCov(lower, names = c(
"OC1", "OC2", "OC3", # Organizational commitment
"JI1", "JI2", "JI3", # Job involvement
"SAT1", "SAT2", "SAT3", # Job satisfaction
"JS1", "JS2", "JS3", # Job scope
"SELF1", "SELF2", "SELF3", # Self ratings of performance
"SUPR1", "SUPR2", "SUPR3", # Supervisor ratings of performance
"Education",
"PostTen", # Position tenure
"OrgTen", # Organizational tenure
"Age"
))
Fourth, we fit model
options(width = 300)
<- '
mathieu.model # latent variables
OC =~ OC1 + OC2 + OC3
SAT =~ SAT1 + SAT2 + SAT3
JS =~ JS1 + JS2 + JS3
PERF=~ SUPR1+ SUPR2 + SUPR3
# regressions
PERF ~ OC + SAT + JS + Education
OC ~ SAT
SAT ~ JS
'
<- sem(mathieu.model,
fit sample.cov = mathieu.cov,
sample.nobs = 483)
summary(fit, standardized = TRUE)
lavaan 0.6-10 ended normally after 47 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 30
Number of observations 483
Model Test User Model:
Test statistic 126.544
Degrees of freedom 60
P-value (Chi-square) 0.000
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Latent Variables:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
OC =~
OC1 1.000 0.771 0.868
OC2 1.124 0.049 22.934 0.000 0.867 0.868
OC3 1.128 0.056 20.156 0.000 0.870 0.784
SAT =~
SAT1 1.000 0.816 0.950
SAT2 0.949 0.031 30.970 0.000 0.775 0.881
SAT3 0.900 0.034 26.719 0.000 0.735 0.827
JS =~
JS1 1.000 0.356 0.828
JS2 0.950 0.048 19.671 0.000 0.338 0.845
JS3 0.886 0.049 17.969 0.000 0.315 0.770
PERF =~
SUPR1 1.000 0.822 0.743
SUPR2 1.071 0.073 14.751 0.000 0.881 0.797
SUPR3 1.028 0.070 14.666 0.000 0.845 0.779
Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
PERF ~
OC 0.115 0.084 1.370 0.171 0.108 0.108
SAT -0.207 0.093 -2.214 0.027 -0.205 -0.205
JS 0.800 0.173 4.619 0.000 0.346 0.346
Education 0.145 0.038 3.781 0.000 0.176 0.185
OC ~
SAT 0.667 0.041 16.421 0.000 0.706 0.706
SAT ~
JS 1.471 0.107 13.733 0.000 0.641 0.641
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.OC1 0.195 0.021 9.514 0.000 0.195 0.247
.OC2 0.246 0.026 9.479 0.000 0.246 0.246
.OC3 0.473 0.038 12.491 0.000 0.473 0.385
.SAT1 0.072 0.012 6.089 0.000 0.072 0.098
.SAT2 0.173 0.015 11.389 0.000 0.173 0.224
.SAT3 0.250 0.019 13.186 0.000 0.250 0.317
.JS1 0.058 0.006 10.172 0.000 0.058 0.314
.JS2 0.046 0.005 9.427 0.000 0.046 0.285
.JS3 0.068 0.006 12.061 0.000 0.068 0.408
.SUPR1 0.547 0.050 11.028 0.000 0.547 0.447
.SUPR2 0.446 0.049 9.106 0.000 0.446 0.365
.SUPR3 0.464 0.047 9.814 0.000 0.464 0.394
.OC 0.298 0.029 10.122 0.000 0.501 0.501
.SAT 0.392 0.033 11.982 0.000 0.589 0.589
JS 0.127 0.012 10.489 0.000 1.000 1.000
.PERF 0.595 0.071 8.417 0.000 0.881 0.881
Fifth, fit indices
options(width = 300)
#fit statistics
summary(fit, fit.measures=TRUE)
lavaan 0.6-10 ended normally after 47 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 30
Number of observations 483
Model Test User Model:
Test statistic 126.544
Degrees of freedom 60
P-value (Chi-square) 0.000
Model Test Baseline Model:
Test statistic 3614.872
Degrees of freedom 78
P-value 0.000
User Model versus Baseline Model:
Comparative Fit Index (CFI) 0.981
Tucker-Lewis Index (TLI) 0.976
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -5138.829
Loglikelihood unrestricted model (H1) -5075.557
Akaike (AIC) 10337.657
Bayesian (BIC) 10463.058
Sample-size adjusted Bayesian (BIC) 10367.840
Root Mean Square Error of Approximation:
RMSEA 0.048
90 Percent confidence interval - lower 0.036
90 Percent confidence interval - upper 0.060
P-value RMSEA <= 0.05 0.599
Standardized Root Mean Square Residual:
SRMR 0.042
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Latent Variables:
Estimate Std.Err z-value P(>|z|)
OC =~
OC1 1.000
OC2 1.124 0.049 22.934 0.000
OC3 1.128 0.056 20.156 0.000
SAT =~
SAT1 1.000
SAT2 0.949 0.031 30.970 0.000
SAT3 0.900 0.034 26.719 0.000
JS =~
JS1 1.000
JS2 0.950 0.048 19.671 0.000
JS3 0.886 0.049 17.969 0.000
PERF =~
SUPR1 1.000
SUPR2 1.071 0.073 14.751 0.000
SUPR3 1.028 0.070 14.666 0.000
Regressions:
Estimate Std.Err z-value P(>|z|)
PERF ~
OC 0.115 0.084 1.370 0.171
SAT -0.207 0.093 -2.214 0.027
JS 0.800 0.173 4.619 0.000
Education 0.145 0.038 3.781 0.000
OC ~
SAT 0.667 0.041 16.421 0.000
SAT ~
JS 1.471 0.107 13.733 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.OC1 0.195 0.021 9.514 0.000
.OC2 0.246 0.026 9.479 0.000
.OC3 0.473 0.038 12.491 0.000
.SAT1 0.072 0.012 6.089 0.000
.SAT2 0.173 0.015 11.389 0.000
.SAT3 0.250 0.019 13.186 0.000
.JS1 0.058 0.006 10.172 0.000
.JS2 0.046 0.005 9.427 0.000
.JS3 0.068 0.006 12.061 0.000
.SUPR1 0.547 0.050 11.028 0.000
.SUPR2 0.446 0.049 9.106 0.000
.SUPR3 0.464 0.047 9.814 0.000
.OC 0.298 0.029 10.122 0.000
.SAT 0.392 0.033 11.982 0.000
JS 0.127 0.012 10.489 0.000
.PERF 0.595 0.071 8.417 0.000
We focus on the 5 commonly used:
1- Model chi-square is the chi-square statistic we
obtain from the maximum likelihood statistic (in lavaan
,
this is known as the Test Statistic for the Model Test User Model)
2- CFI is the Comparative Fit Index – values can range
between 0 and 1 (values greater than 0.90, conservatively 0.95 indicate
good fit)
3- TLI Tucker Lewis Index which also ranges between 0
and 1 (if it’s greater than 1 it should be rounded to 1) with values
greater than 0.90 indicating good fit. If the CFI and TLI are less than
one, the CFI is always greater than the TLI.
4- RMSEA is the root mean square error of approximation
In lavaan, you also obtain a p-value of close fit, that the RMSEA <
0.05. If you reject the model, it means your model is not a close
fitting model.
5- SRMR is standardized root mean squared residual to
test close fit. Also we also obtain a p-value of close fit, that the
RMSEA < 0.05. If you reject the model, it means your model is not a
close fitting model.
In general, researchers should avoid sample sizes less than 100 when testing small degrees of freedom models. In fact, science and math education researchers should avoid reporting the RMSEA when sample sizes are smaller than 200, particularly when combined with small degrees of freedom. Small degrees of freedom do not tend to result in rejection of correctly specified models for the TLI, CFI, and SRMR, particularly if they tested using larger sample sizes (Taasoobshirazi and Wang (2016)).
(be continued)
If you see mistakes or want to suggest changes, please create an issue on the source repository.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/hai-mn/hai-mn.github.io, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Nguyen (2022, June 20). HaiBiostat: Structural Equation Modeling: What Fun if We Cannot Run in Mplus. Retrieved from https://hai-mn.github.io/posts/2022-06-20-SEM/
BibTeX citation
@misc{nguyen2022structural, author = {Nguyen, Hai}, title = {HaiBiostat: Structural Equation Modeling: What Fun if We Cannot Run in Mplus}, url = {https://hai-mn.github.io/posts/2022-06-20-SEM/}, year = {2022} }