0% found this document useful (0 votes)
89 views33 pages

User-Sem-Lavaan (SEM)

The document describes using lavaan in R to conduct several structural equation models (SEMs) on personality data. It first prepares the data and specifies a regression model (Model 1) to predict prejudice from openness and agreeableness. Model 1 is estimated, evaluated, and further tested. The document then repeats Model 1 with bootstrapped standard errors. Subsequent models include a mediation model (Model 2), a confirmatory factor analysis (Model 3), and a full SEM (Model 4). Additional models examine multi-group SEMs to test for gender differences. The document provides code and output to specify, estimate, evaluate, and interpret each SEM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views33 pages

User-Sem-Lavaan (SEM)

The document describes using lavaan in R to conduct several structural equation models (SEMs) on personality data. It first prepares the data and specifies a regression model (Model 1) to predict prejudice from openness and agreeableness. Model 1 is estimated, evaluated, and further tested. The document then repeats Model 1 with bootstrapped standard errors. Subsequent models include a mediation model (Model 2), a confirmatory factor analysis (Model 3), and a full SEM (Model 4). Additional models examine multi-group SEMs to test for gender differences. The document provides code and output to specify, estimate, evaluate, and interpret each SEM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

A Mild Introduction to Structural Equation Modeling Using

lavaan

UseR! Oslo Group Workshop

28 May 2020

Contents
Data preparation 2
Install and load relevant R packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Data input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Model 1: Regression model with manifest variables only 2


Specifying, estimating, and evaluating the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
ADD-ON–Model 1 with bootstrapping of standard errors . . . . . . . . . . . . . . . . . . . . . . . 6

Model 2: Mediation model with manifest variables only 8

Model 3: Measurement model (CFA) 10


Correlation matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Specifying, estimating, and evaluating the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Model 3b: Refined CFA of personality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Model 4: Structural equation model 18

ADD-ON–Model 5: Multi-group SEM (Gender differences in the structural parameters) 23

ADD-ON–Model 6: Multi-group SEM with equal structural parameters 27

R session info 32

1
Data preparation

Install and load relevant R packages

# Install R packages (if needed)


# install.packages(c("lavaan", "semPlot", "MPsychoR", "corrplot"))

## Load relevant libraries


library(lavaan)
library(semPlot)
library(MPsychoR)
library(corrplot)

Data input

# Select the data


data("Bergh")
View(Bergh)
attach(Bergh)

# Sample size
nrow(Bergh)

## [1] 861
## Create mean scores per construct
Bergh$Open <- (O1+O2+O3)/3
Bergh$Agree <- (A1+A2+A3)/3
Bergh$Prejudice <- (EP+SP+DP+HP)/4

Model 1: Regression model with manifest variables only

Specifying, estimating, and evaluating the model

# Step 1: Model specification


model1 <- '
# Structural model
Prejudice ~ b1*Open + b2*Agree

# Covariance structure of exogenous variables


Open ~~ Open + Agree
Agree ~~ Agree

'

# Step 2: Model estimation


model1.fit <- sem(model1,
data = Bergh,
meanstructure = FALSE,
estimator = "ML")

2
# Step 3: Evaluate the model
# Summary
summary(model1.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 21 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 6
##
## Number of observations 861
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 335.486
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1689.786
## Loglikelihood unrestricted model (H1) -1689.786
##
## Akaike (AIC) 3391.572
## Bayesian (BIC) 3420.121
## Sample-size adjusted Bayesian (BIC) 3401.066
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value RMSEA <= 0.05 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##

3
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Prejudice ~
## Open (b1) -0.612 0.043 -14.118 0.000 -0.612 -0.423
## Agree (b2) -0.324 0.043 -7.522 0.000 -0.324 -0.225
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Open ~~
## Agree 0.049 0.007 7.148 0.000 0.049 0.251
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Open 0.192 0.009 20.748 0.000 0.192 1.000
## Agree 0.194 0.009 20.748 0.000 0.194 1.000
## .Prejudice 0.291 0.014 20.748 0.000 0.291 0.723
##
## R-Square:
## Estimate
## Prejudice 0.277
# Visualize the path model
semPaths(model1.fit,
rotation = 2,
layout = "tree2",
what = "std",
posCol = "black",
edge.width = 0.5,
style = "Lisrel",
fade = T,
edge.label.position = 0.55)

4
Agr

−0.23

0.25

Prj 0.72

−0.42

Opn

# Fitted values of the covariance matrix


fitted(model1.fit)

## $cov
## Prejdc Open Agree
## Prejudice 0.402
## Open -0.133 0.192
## Agree -0.093 0.049 0.194
# List all parameter values
parameterEstimates(model1.fit)

## lhs op rhs label est se z pvalue ci.lower ci.upper


## 1 Prejudice ~ Open b1 -0.612 0.043 -14.118 0 -0.697 -0.527
## 2 Prejudice ~ Agree b2 -0.324 0.043 -7.522 0 -0.408 -0.239
## 3 Open ~~ Open 0.192 0.009 20.748 0 0.174 0.210
## 4 Open ~~ Agree 0.049 0.007 7.148 0 0.035 0.062
## 5 Agree ~~ Agree 0.194 0.009 20.748 0 0.176 0.213
## 6 Prejudice ~~ Prejudice 0.291 0.014 20.748 0 0.263 0.318
# Step 4: Further hypothesis testing
# H0: b1=b2
lavTestWald(model1.fit, constraints = "b1==b2")

## $stat
## [1] 17.76479
##
## $df
## [1] 1
##
## $p.value
## [1] 2.499661e-05
##
## $se
## [1] "standard"

5
ADD-ON–Model 1 with bootstrapping of standard errors

# Step 2: Model estimation with bootstrapping


set.seed(616)
model1.fit.boot <- sem(model1,
data = Bergh,
meanstructure = FALSE,
estimator = "ML",
se = "bootstrap",
bootstrap = 1000)

# Step 3: Evaluate the model


# Summary
summary(model1.fit.boot,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE,
ci = TRUE)

## lavaan 0.6-5 ended normally after 21 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 6
##
## Number of observations 861
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 335.486
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1689.786
## Loglikelihood unrestricted model (H1) -1689.786
##
## Akaike (AIC) 3391.572
## Bayesian (BIC) 3420.121
## Sample-size adjusted Bayesian (BIC) 3401.066
##
## Root Mean Square Error of Approximation:
##

6
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value RMSEA <= 0.05 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## Prejudice ~
## Open (b1) -0.612 0.044 -13.905 0.000 -0.704 -0.528
## Agree (b2) -0.324 0.043 -7.576 0.000 -0.410 -0.238
## Std.lv Std.all
##
## -0.612 -0.423
## -0.324 -0.225
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## Open ~~
## Agree 0.049 0.007 6.802 0.000 0.034 0.061
## Std.lv Std.all
##
## 0.049 0.251
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## Open 0.192 0.009 22.345 0.000 0.174 0.209
## Agree 0.194 0.008 24.159 0.000 0.177 0.211
## .Prejudice 0.291 0.017 17.440 0.000 0.258 0.323
## Std.lv Std.all
## 0.192 1.000
## 0.194 1.000
## 0.291 0.723
##
## R-Square:
## Estimate
## Prejudice 0.277
# List all parameter values
parameterEstimates(model1.fit.boot, ci = TRUE, boot.ci.type = "basic")

## lhs op rhs label est se z pvalue ci.lower ci.upper


## 1 Prejudice ~ Open b1 -0.612 0.044 -13.905 0 -0.696 -0.520
## 2 Prejudice ~ Agree b2 -0.324 0.043 -7.576 0 -0.409 -0.238
## 3 Open ~~ Open 0.192 0.009 22.345 0 0.175 0.210
## 4 Open ~~ Agree 0.049 0.007 6.802 0 0.036 0.063

7
## 5 Agree ~~ Agree 0.194 0.008 24.159 0 0.178 0.212
## 6 Prejudice ~~ Prejudice 0.291 0.017 17.440 0 0.258 0.324

Model 2: Mediation model with manifest variables only

# Step 1: Model specification


model2 <- '
# Structural model
Prejudice ~ b1*Open + b2*Agree
Open ~ b3*Agree

# Covariance structure of exogenous variables


Agree ~~ Agree

# New parameters (indirect effect)


ind := b1*b3

'

# Step 2: Model estimation


model2.fit <- sem(model2,
data = Bergh,
meanstructure = FALSE,
estimator = "ML")

# Step 3: Evaluate the model


# Summary
summary(model2.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 19 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 6
##
## Number of observations 861
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 335.486
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:

8
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1689.786
## Loglikelihood unrestricted model (H1) -1689.786
##
## Akaike (AIC) 3391.572
## Bayesian (BIC) 3420.121
## Sample-size adjusted Bayesian (BIC) 3401.066
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value RMSEA <= 0.05 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Prejudice ~
## Open (b1) -0.612 0.043 -14.118 0.000 -0.612 -0.423
## Agree (b2) -0.324 0.043 -7.522 0.000 -0.324 -0.225
## Open ~
## Agree (b3) 0.250 0.033 7.614 0.000 0.250 0.251
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Agree 0.194 0.009 20.748 0.000 0.194 1.000
## .Prejudice 0.291 0.014 20.748 0.000 0.291 0.723
## .Open 0.180 0.009 20.748 0.000 0.180 0.937
##
## R-Square:
## Estimate
## Prejudice 0.277
## Open 0.063
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ind -0.153 0.023 -6.701 0.000 -0.153 -0.106

9
# Visualize the path model
semPaths(model2.fit,
rotation = 2,
layout = "tree2",
what = "std",
posCol = "black",
edge.width = 0.5,
style = "Lisrel",
fade = T,
edge.label.position = 0.55)

Opn 0.94

0.25

Agr
−0.42

−0.23

Prj 0.72

Model 3: Measurement model (CFA)

Correlation matrix

# Extract the correlation matrix


Bergh.cor <- cor(Bergh[,1:10], method = "pearson", use = "pairwise.complete.obs")
Bergh.cor

## EP SP HP DP A1 A2 A3
## EP 1.0000000 0.5328577 0.2545270 0.5314828 -0.2486889 -0.3889079 -0.3031269
## SP 0.5328577 1.0000000 0.2219292 0.5252140 -0.1710822 -0.2973829 -0.1987969
## HP 0.2545270 0.2219292 1.0000000 0.2415626 -0.1120012 -0.1510590 -0.0827062
## DP 0.5314828 0.5252140 0.2415626 1.0000000 -0.3292610 -0.4709318 -0.3936544
## A1 -0.2486889 -0.1710822 -0.1120012 -0.3292610 1.0000000 0.6867541 0.7835360
## A2 -0.3889079 -0.2973829 -0.1510590 -0.4709318 0.6867541 1.0000000 0.7453925
## A3 -0.3031269 -0.1987969 -0.0827062 -0.3936544 0.7835360 0.7453925 1.0000000
## O1 -0.3543605 -0.3317130 -0.2332906 -0.2994080 0.0861290 0.2293831 0.1488831
## O2 -0.3622272 -0.3127873 -0.2972669 -0.3327277 0.1393367 0.2698570 0.2082816
## O3 -0.4089230 -0.3300734 -0.2930209 -0.3407396 0.1904259 0.3178221 0.2584276
## O1 O2 O3

10
## EP -0.3543605 -0.3622272 -0.4089230
## SP -0.3317130 -0.3127873 -0.3300734
## HP -0.2332906 -0.2972669 -0.2930209
## DP -0.2994080 -0.3327277 -0.3407396
## A1 0.0861290 0.1393367 0.1904259
## A2 0.2293831 0.2698570 0.3178221
## A3 0.1488831 0.2082816 0.2584276
## O1 1.0000000 0.6624692 0.7444363
## O2 0.6624692 1.0000000 0.7140617
## O3 0.7444363 0.7140617 1.0000000
# Correlogram
corrplot(Bergh.cor, type = "upper", order = "hclust",
tl.col = "black", tl.srt = 60,
addCoef.col = "white",
number.cex = 0.75,
cl.cex = 1,
tl.cex = 0.9)
HP

DP

EP

SP

O2

O1

O3
A3
A2

A1

1
HP 1 0.24 0.25 0.22 −0.15 −0.11 −0.08 −0.3 −0.23 −0.29
0.8
DP 1 0.53 0.53 −0.47 −0.33 −0.39 −0.33 −0.3 −0.34
0.6
EP 1 0.53 −0.39 −0.25 −0.3 −0.36 −0.35 −0.41
0.4
SP 1 −0.3 −0.17 −0.2 −0.31 −0.33 −0.33
0.2
A2 1 0.69 0.75 0.27 0.23 0.32
0
A1 1 0.78 0.14 0.09 0.19
−0.2
A3 1 0.21 0.15 0.26
−0.4
O2 1 0.66 0.71
−0.6
O1 1 0.74
−0.8
O3 1
−1
Variables that represent the same underlying concept (i.e., agreeableness, openness, and prejudice) correlate
positively, significantly, and substantially. Do they really measure the same concept?

Specifying, estimating, and evaluating the model

# Step 1: Model specification


model3 <- '

11
# Measurement models
OP =~ O1 + O2 + O3
AG =~ A1 + A2 + A3
PR =~ EP + SP + HP + DP

# Covariance structure
OP ~~ OP + AG + PR
AG ~~ AG + PR
PR ~~ PR

'

# Step 2: Model estimation


model3.fit <- sem(model3,
data = Bergh,
meanstructure = FALSE,
estimator = "ML")

# Step 3: Evaluate the model


# Summary
summary(model3.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 54 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 23
##
## Number of observations 861
##
## Model Test User Model:
##
## Test statistic 186.620
## Degrees of freedom 32
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 4270.205
## Degrees of freedom 45
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.963
## Tucker-Lewis Index (TLI) 0.949
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -5672.807
## Loglikelihood unrestricted model (H1) -5579.497

12
##
## Akaike (AIC) 11391.614
## Bayesian (BIC) 11501.050
## Sample-size adjusted Bayesian (BIC) 11428.008
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.075
## 90 Percent confidence interval - lower 0.065
## 90 Percent confidence interval - upper 0.085
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.054
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.400 0.827
## O2 0.934 0.036 26.185 0.000 0.374 0.799
## O3 1.149 0.040 28.900 0.000 0.460 0.898
## AG =~
## A1 1.000 0.426 0.846
## A2 0.910 0.032 28.812 0.000 0.388 0.823
## A3 1.030 0.032 31.899 0.000 0.439 0.914
## PR =~
## EP 1.000 0.530 0.746
## SP 0.886 0.051 17.348 0.000 0.469 0.686
## HP 1.030 0.112 9.160 0.000 0.545 0.350
## DP 0.746 0.041 18.308 0.000 0.395 0.741
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP ~~
## AG 0.049 0.007 7.105 0.000 0.286 0.286
## PR -0.122 0.011 -11.371 0.000 -0.573 -0.573
## AG ~~
## PR -0.110 0.011 -10.241 0.000 -0.485 -0.485
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP 0.160 0.011 14.156 0.000 1.000 1.000
## AG 0.182 0.012 14.822 0.000 1.000 1.000
## PR 0.281 0.025 11.385 0.000 1.000 1.000
## .O1 0.074 0.005 14.555 0.000 0.074 0.317
## .O2 0.079 0.005 15.837 0.000 0.079 0.361
## .O3 0.051 0.005 9.630 0.000 0.051 0.194

13
## .A1 0.072 0.005 14.461 0.000 0.072 0.284
## .A2 0.072 0.005 15.697 0.000 0.072 0.322
## .A3 0.038 0.004 9.152 0.000 0.038 0.165
## .EP 0.224 0.016 14.198 0.000 0.224 0.444
## .SP 0.248 0.015 16.146 0.000 0.248 0.530
## .HP 2.137 0.107 20.052 0.000 2.137 0.878
## .DP 0.128 0.009 14.376 0.000 0.128 0.451
##
## R-Square:
## Estimate
## O1 0.683
## O2 0.639
## O3 0.806
## A1 0.716
## A2 0.678
## A3 0.835
## EP 0.556
## SP 0.470
## HP 0.122
## DP 0.549
# Visualize the path model
semPaths(model3.fit,
rotation = 2,
layout = "tree2",
what = "std",
posCol = "black",
edge.width = 0.5,
style = "Lisrel",
fade = T,
edge.label.position = 0.55)

DP 0.45

0.74

0.35 HP 0.88
PR
0.69
SP 0.53
0.75

−0.49
EP 0.44

−0.57 A3 0.17
0.91
AG 0.82
A2 0.32
0.85

0.29 A1 0.28

O3 0.19
0.90
OP 0.80
O2 0.36
0.83

O1 0.32

14
Model 3b: Refined CFA of personality

Some researcher had reason to believe that the indicators A1 and A3 may covary beyond having the same
underlying construct (Agreeableness). This may be due to similar wording in questions to the study
participants or a similar method with which A1 and A3 have been assessed. To represent this in the original
measurement model (Model 3), we add the residual covariance between these two indicators (i.e., A1 ~~ A3)
and evaluate the extent to which this improves/changes the model fit.
# Step 1: Model specification
model3b <- '
# Measurement models
OP =~ O1 + O2 + O3
AG =~ A1 + A2 + A3
PR =~ EP + SP + HP + DP

# Covariance structure
OP ~~ OP + AG + PR
AG ~~ AG + PR
PR ~~ PR

# Residual covariance
A1 ~~ A3

'

# Step 2: Model estimation


model3b.fit <- sem(model3b,
data = Bergh,
meanstructure = FALSE,
estimator = "ML")

# Step 3: Evaluate the model


# Summary
summary(model3b.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 62 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 24
##
## Number of observations 861
##
## Model Test User Model:
##
## Test statistic 118.256
## Degrees of freedom 31
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 4270.205

15
## Degrees of freedom 45
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.979
## Tucker-Lewis Index (TLI) 0.970
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -5638.625
## Loglikelihood unrestricted model (H1) -5579.497
##
## Akaike (AIC) 11325.249
## Bayesian (BIC) 11439.444
## Sample-size adjusted Bayesian (BIC) 11363.226
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.057
## 90 Percent confidence interval - lower 0.046
## 90 Percent confidence interval - upper 0.068
## P-value RMSEA <= 0.05 0.131
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.043
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.400 0.827
## O2 0.934 0.036 26.188 0.000 0.374 0.799
## O3 1.149 0.040 28.921 0.000 0.460 0.898
## AG =~
## A1 1.000 0.346 0.687
## A2 1.361 0.086 15.756 0.000 0.471 0.999
## A3 1.036 0.033 31.662 0.000 0.358 0.746
## PR =~
## EP 1.000 0.529 0.744
## SP 0.887 0.051 17.460 0.000 0.469 0.685
## HP 1.031 0.112 9.177 0.000 0.545 0.349
## DP 0.750 0.040 18.535 0.000 0.397 0.744
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP ~~
## AG 0.046 0.006 7.516 0.000 0.330 0.330

16
## PR -0.121 0.011 -11.372 0.000 -0.573 -0.573
## AG ~~
## PR -0.098 0.010 -9.409 0.000 -0.536 -0.536
## .A1 ~~
## .A3 0.066 0.008 8.266 0.000 0.066 0.560
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP 0.160 0.011 14.158 0.000 1.000 1.000
## AG 0.120 0.012 9.879 0.000 1.000 1.000
## PR 0.279 0.024 11.413 0.000 1.000 1.000
## .O1 0.074 0.005 14.570 0.000 0.074 0.317
## .O2 0.079 0.005 15.846 0.000 0.079 0.361
## .O3 0.051 0.005 9.643 0.000 0.051 0.194
## .A1 0.134 0.009 14.890 0.000 0.134 0.528
## .A2 0.000 0.012 0.027 0.979 0.000 0.001
## .A3 0.102 0.008 12.293 0.000 0.102 0.444
## .EP 0.225 0.016 14.456 0.000 0.225 0.447
## .SP 0.249 0.015 16.300 0.000 0.249 0.531
## .HP 2.138 0.106 20.073 0.000 2.138 0.878
## .DP 0.127 0.009 14.467 0.000 0.127 0.447
##
## R-Square:
## Estimate
## O1 0.683
## O2 0.639
## O3 0.806
## A1 0.472
## A2 0.999
## A3 0.556
## EP 0.553
## SP 0.469
## HP 0.122
## DP 0.553
# Visualize the path model
semPaths(model3b.fit,
rotation = 2,
layout = "tree2",
what = "std",
posCol = "black",
edge.width = 0.5,
style = "Lisrel",
fade = T,
edge.label.position = 0.55)

17
DP 0.45

0.74

0.35 HP 0.88
PR
0.68
SP 0.53
0.74

−0.54
EP 0.45

−0.57 A3 0.44
0.75
AG 1.00 0.56
A2 0.00
0.69

0.33 A1 0.53

O3 0.19
0.90
OP 0.80
O2 0.36
0.83

O1 0.32

## Model comparison: Model 3 vs. refined Model 3


anova(model3.fit, model3b.fit)

## Chi-Squared Difference Test


##
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## model3b.fit 31 11325 11439 118.26
## model3.fit 32 11392 11501 186.62 68.364 1 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Model 4: Structural equation model

# Step 1: Model specification


model4 <- '
# Measurement models
OP =~ O1 + O2 + O3
AG =~ A1 + A2 + A3
PR =~ EP + SP + HP + DP

# Residual covariance
A1 ~~ A3

# Structural model
PR ~ b1*OP + b2*AG

'

# Step 2: Model estimation


model4.fit <- sem(model4,
data = Bergh,
meanstructure = FALSE,

18
estimator = "ML")

# Step 3: Evaluate the model


# Summary
summary(model4.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 55 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 24
##
## Number of observations 861
##
## Model Test User Model:
##
## Test statistic 118.256
## Degrees of freedom 31
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 4270.205
## Degrees of freedom 45
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.979
## Tucker-Lewis Index (TLI) 0.970
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -5638.625
## Loglikelihood unrestricted model (H1) -5579.497
##
## Akaike (AIC) 11325.249
## Bayesian (BIC) 11439.444
## Sample-size adjusted Bayesian (BIC) 11363.226
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.057
## 90 Percent confidence interval - lower 0.046
## 90 Percent confidence interval - upper 0.068
## P-value RMSEA <= 0.05 0.131
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.043
##

19
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.400 0.827
## O2 0.934 0.036 26.188 0.000 0.374 0.799
## O3 1.149 0.040 28.921 0.000 0.460 0.898
## AG =~
## A1 1.000 0.346 0.687
## A2 1.361 0.086 15.756 0.000 0.471 0.999
## A3 1.036 0.033 31.662 0.000 0.358 0.746
## PR =~
## EP 1.000 0.529 0.744
## SP 0.887 0.051 17.460 0.000 0.469 0.685
## HP 1.031 0.112 9.177 0.000 0.545 0.349
## DP 0.750 0.040 18.535 0.000 0.397 0.744
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## PR ~
## OP (b1) -0.587 0.053 -11.106 0.000 -0.444 -0.444
## AG (b2) -0.595 0.058 -10.172 0.000 -0.390 -0.390
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .A1 ~~
## .A3 0.066 0.008 8.266 0.000 0.066 0.560
## OP ~~
## AG 0.046 0.006 7.516 0.000 0.330 0.330
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .O1 0.074 0.005 14.570 0.000 0.074 0.317
## .O2 0.079 0.005 15.846 0.000 0.079 0.361
## .O3 0.051 0.005 9.643 0.000 0.051 0.194
## .A1 0.134 0.009 14.890 0.000 0.134 0.528
## .A2 0.000 0.012 0.027 0.979 0.000 0.001
## .A3 0.102 0.008 12.293 0.000 0.102 0.444
## .EP 0.225 0.016 14.456 0.000 0.225 0.447
## .SP 0.249 0.015 16.300 0.000 0.249 0.531
## .HP 2.138 0.106 20.073 0.000 2.138 0.878
## .DP 0.127 0.009 14.467 0.000 0.127 0.447
## OP 0.160 0.011 14.158 0.000 1.000 1.000
## AG 0.120 0.012 9.879 0.000 1.000 1.000
## .PR 0.150 0.015 9.937 0.000 0.536 0.536
##
## R-Square:
## Estimate
## O1 0.683

20
## O2 0.639
## O3 0.806
## A1 0.472
## A2 0.999
## A3 0.556
## EP 0.553
## SP 0.469
## HP 0.122
## DP 0.553
## PR 0.464
# Visualize the path model
semPaths(model4.fit,
rotation = 2,
layout = "tree2",
what = "std",
posCol = "black",
edge.width = 0.5,
style = "Lisrel",
fade = T,
edge.label.position = 0.55)

0.44 A3

0.75

0.56
0.00 A2 1.00 AG DP 0.45

0.69
0.74
−0.39
0.53 A1 HP 0.88
0.35
0.33
0.54 PR
0.68
0.19 O3 SP 0.53
−0.44
0.74
0.90

0.36 O2 0.80 OP EP 0.45

0.83

0.32 O1

## Hypothesis testing
lavTestWald(model4.fit, constraints = "b1 == b2")

## $stat
## [1] 0.009016331
##
## $df
## [1] 1
##
## $p.value
## [1] 0.9243511
##
## $se

21
## [1] "standard"

22
ADD-ON–Model 5: Multi-group SEM (Gender differences in the
structural parameters)

# Step 1: Model specification


model5 <- '
# Measurement models
OP =~ O1 + O2 + O3
AG =~ A1 + A2 + A3
PR =~ EP + SP + HP + DP

# Covariance structure
OP ~~ OP + AG
AG ~~ AG

# Residual covariance
A1 ~~ A3

# Structural model
PR ~ c(a1,b1)*OP + c(a2,b2)*AG

'

# Step 2: Model estimation


# Only allow for differences in the structural parameters
# Keep all other parameters equal (measurement invariance)
model5.fit <- sem(model5,
data = Bergh,
meanstructure = FALSE,
estimator = "ML",
group = "gender",
group.equal = c("loadings", "residuals"))

# Step 3: Evaluate the model


# Summary
summary(model5.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 60 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 48
## Number of equality constraints 17
## Row rank of the constraints matrix 17
##
## Number of observations per group:
## male 249
## female 612
##
## Model Test User Model:
##

23
## Test statistic 208.998
## Degrees of freedom 79
## P-value (Chi-square) 0.000
## Test statistic for each group:
## male 83.323
## female 125.675
##
## Model Test Baseline Model:
##
## Test statistic 4207.254
## Degrees of freedom 90
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.968
## Tucker-Lewis Index (TLI) 0.964
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -5575.804
## Loglikelihood unrestricted model (H1) -5471.305
##
## Akaike (AIC) 11213.608
## Bayesian (BIC) 11361.109
## Sample-size adjusted Bayesian (BIC) 11262.661
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.062
## 90 Percent confidence interval - lower 0.052
## 90 Percent confidence interval - upper 0.072
## P-value RMSEA <= 0.05 0.028
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.067
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
##
## Group 1 [male]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.410 0.833
## O2 (.p2.) 0.932 0.036 26.006 0.000 0.382 0.806
## O3 (.p3.) 1.148 0.040 28.727 0.000 0.471 0.902
## AG =~

24
## A1 1.000 0.346 0.689
## A2 (.p5.) 1.327 0.089 14.919 0.000 0.459 0.993
## A3 (.p6.) 1.021 0.033 31.242 0.000 0.353 0.744
## PR =~
## EP 1.000 0.552 0.761
## SP (.p8.) 0.822 0.049 16.706 0.000 0.454 0.685
## HP (.p9.) 1.029 0.114 9.020 0.000 0.568 0.363
## DP (.10.) 0.733 0.041 17.857 0.000 0.405 0.748
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## PR ~
## OP (a1) -0.620 0.097 -6.403 0.000 -0.461 -0.461
## AG (a2) -0.510 0.108 -4.719 0.000 -0.320 -0.320
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP ~~
## AG 0.059 0.011 5.315 0.000 0.414 0.414
## .A1 ~~
## .A3 0.058 0.009 6.338 0.000 0.058 0.502
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP 0.168 0.019 9.083 0.000 1.000 1.000
## AG 0.120 0.015 7.753 0.000 1.000 1.000
## .O1 (.17.) 0.074 0.005 14.561 0.000 0.074 0.306
## .O2 (.18.) 0.079 0.005 15.870 0.000 0.079 0.351
## .O3 (.19.) 0.051 0.005 9.612 0.000 0.051 0.186
## .A1 (.20.) 0.132 0.009 14.304 0.000 0.132 0.525
## .A2 (.21.) 0.003 0.012 0.244 0.807 0.003 0.013
## .A3 (.22.) 0.101 0.008 11.859 0.000 0.101 0.447
## .EP (.23.) 0.221 0.016 14.053 0.000 0.221 0.421
## .SP (.24.) 0.233 0.014 16.504 0.000 0.233 0.531
## .HP (.25.) 2.133 0.106 20.044 0.000 2.133 0.869
## .DP (.26.) 0.129 0.009 14.552 0.000 0.129 0.440
## .PR 0.172 0.026 6.590 0.000 0.564 0.564
##
## R-Square:
## Estimate
## O1 0.694
## O2 0.649
## O3 0.814
## A1 0.475
## A2 0.987
## A3 0.553
## EP 0.579
## SP 0.469
## HP 0.131
## DP 0.560
## PR 0.436
##
##
## Group 2 [female]:

25
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.394 0.822
## O2 (.p2.) 0.932 0.036 26.006 0.000 0.367 0.794
## O3 (.p3.) 1.148 0.040 28.727 0.000 0.452 0.895
## AG =~
## A1 1.000 0.343 0.686
## A2 (.p5.) 1.327 0.089 14.919 0.000 0.455 0.993
## A3 (.p6.) 1.021 0.033 31.242 0.000 0.351 0.741
## PR =~
## EP 1.000 0.511 0.736
## SP (.p8.) 0.822 0.049 16.706 0.000 0.420 0.656
## HP (.p9.) 1.029 0.114 9.020 0.000 0.526 0.339
## DP (.10.) 0.733 0.041 17.857 0.000 0.375 0.722
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## PR ~
## OP (b1) -0.586 0.060 -9.722 0.000 -0.451 -0.451
## AG (b2) -0.568 0.066 -8.614 0.000 -0.381 -0.381
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP ~~
## AG 0.037 0.007 5.683 0.000 0.276 0.276
## .A1 ~~
## .A3 0.067 0.008 8.011 0.000 0.067 0.576
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP 0.155 0.012 12.660 0.000 1.000 1.000
## AG 0.118 0.013 9.258 0.000 1.000 1.000
## .O1 (.17.) 0.074 0.005 14.561 0.000 0.074 0.324
## .O2 (.18.) 0.079 0.005 15.870 0.000 0.079 0.370
## .O3 (.19.) 0.051 0.005 9.612 0.000 0.051 0.199
## .A1 (.20.) 0.132 0.009 14.304 0.000 0.132 0.529
## .A2 (.21.) 0.003 0.012 0.244 0.807 0.003 0.014
## .A3 (.22.) 0.101 0.008 11.859 0.000 0.101 0.450
## .EP (.23.) 0.221 0.016 14.053 0.000 0.221 0.459
## .SP (.24.) 0.233 0.014 16.504 0.000 0.233 0.569
## .HP (.25.) 2.133 0.106 20.044 0.000 2.133 0.885
## .DP (.26.) 0.129 0.009 14.552 0.000 0.129 0.478
## .PR 0.145 0.017 8.743 0.000 0.556 0.556
##
## R-Square:
## Estimate
## O1 0.676
## O2 0.630
## O3 0.801
## A1 0.471
## A2 0.986
## A3 0.550

26
## EP 0.541
## SP 0.431
## HP 0.115
## DP 0.522
## PR 0.444
# Hypothesis testing
lavTestWald(model5.fit, constraints = "a1==b1")

## $stat
## [1] 0.0955577
##
## $df
## [1] 1
##
## $p.value
## [1] 0.7572271
##
## $se
## [1] "standard"
lavTestWald(model5.fit, constraints = "a2==b2")

## $stat
## [1] 0.2275054
##
## $df
## [1] 1
##
## $p.value
## [1] 0.6333798
##
## $se
## [1] "standard"

ADD-ON–Model 6: Multi-group SEM with equal structural pa-


rameters

# Step 1: Model specification


model6 <- '
# Measurement models
OP =~ O1 + O2 + O3
AG =~ A1 + A2 + A3
PR =~ EP + SP + HP + DP

# Covariance structure
OP ~~ OP + AG
AG ~~ AG

# Residual covariance
A1 ~~ A3

# Structural model

27
PR ~ OP + AG

'

# Step 2: Model estimation


model6.fit <- sem(model6,
data = Bergh,
meanstructure = FALSE,
estimator = "ML",
group = "gender",
group.equal = c("loadings",
"residuals",
"regressions"))

# Summary
summary(model6.fit,
rsquare = TRUE,
fit.measures = TRUE,
standardized = TRUE)

## lavaan 0.6-5 ended normally after 59 iterations


##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 48
## Number of equality constraints 19
## Row rank of the constraints matrix 19
##
## Number of observations per group:
## male 249
## female 612
##
## Model Test User Model:
##
## Test statistic 209.237
## Degrees of freedom 81
## P-value (Chi-square) 0.000
## Test statistic for each group:
## male 83.388
## female 125.849
##
## Model Test Baseline Model:
##
## Test statistic 4207.254
## Degrees of freedom 90
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.969
## Tucker-Lewis Index (TLI) 0.965
##
## Loglikelihood and Information Criteria:
##

28
## Loglikelihood user model (H0) -5575.924
## Loglikelihood unrestricted model (H1) -5471.305
##
## Akaike (AIC) 11209.847
## Bayesian (BIC) 11347.832
## Sample-size adjusted Bayesian (BIC) 11255.736
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.061
## 90 Percent confidence interval - lower 0.051
## 90 Percent confidence interval - upper 0.071
## P-value RMSEA <= 0.05 0.041
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.067
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard errors Standard
##
##
## Group 1 [male]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.411 0.833
## O2 (.p2.) 0.932 0.036 26.007 0.000 0.383 0.806
## O3 (.p3.) 1.148 0.040 28.723 0.000 0.471 0.902
## AG =~
## A1 1.000 0.346 0.690
## A2 (.p5.) 1.322 0.088 14.987 0.000 0.458 0.991
## A3 (.p6.) 1.022 0.033 31.242 0.000 0.354 0.745
## PR =~
## EP 1.000 0.554 0.762
## SP (.p8.) 0.822 0.049 16.716 0.000 0.456 0.686
## HP (.p9.) 1.029 0.114 9.019 0.000 0.570 0.364
## DP (.10.) 0.733 0.041 17.855 0.000 0.406 0.749
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## PR ~
## OP (.15.) -0.593 0.053 -11.116 0.000 -0.439 -0.439
## AG (.16.) -0.554 0.058 -9.488 0.000 -0.346 -0.346
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP ~~
## AG 0.059 0.011 5.315 0.000 0.414 0.414
## .A1 ~~

29
## .A3 0.058 0.009 6.303 0.000 0.058 0.500
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP 0.169 0.019 9.099 0.000 1.000 1.000
## AG 0.120 0.015 7.760 0.000 1.000 1.000
## .O1 (.17.) 0.074 0.005 14.560 0.000 0.074 0.306
## .O2 (.18.) 0.079 0.005 15.867 0.000 0.079 0.351
## .O3 (.19.) 0.051 0.005 9.610 0.000 0.051 0.186
## .A1 (.20.) 0.132 0.009 14.287 0.000 0.132 0.524
## .A2 (.21.) 0.004 0.012 0.312 0.755 0.004 0.017
## .A3 (.22.) 0.100 0.008 11.834 0.000 0.100 0.445
## .EP (.23.) 0.221 0.016 14.050 0.000 0.221 0.419
## .SP (.24.) 0.233 0.014 16.496 0.000 0.233 0.529
## .HP (.25.) 2.133 0.106 20.044 0.000 2.133 0.868
## .DP (.26.) 0.129 0.009 14.562 0.000 0.129 0.439
## .PR 0.172 0.026 6.611 0.000 0.561 0.561
##
## R-Square:
## Estimate
## O1 0.694
## O2 0.649
## O3 0.814
## A1 0.476
## A2 0.983
## A3 0.555
## EP 0.581
## SP 0.471
## HP 0.132
## DP 0.561
## PR 0.439
##
##
## Group 2 [female]:
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP =~
## O1 1.000 0.393 0.822
## O2 (.p2.) 0.932 0.036 26.007 0.000 0.367 0.794
## O3 (.p3.) 1.148 0.040 28.723 0.000 0.452 0.895
## AG =~
## A1 1.000 0.344 0.688
## A2 (.p5.) 1.322 0.088 14.987 0.000 0.455 0.991
## A3 (.p6.) 1.022 0.033 31.242 0.000 0.351 0.743
## PR =~
## EP 1.000 0.511 0.735
## SP (.p8.) 0.822 0.049 16.716 0.000 0.420 0.656
## HP (.p9.) 1.029 0.114 9.019 0.000 0.525 0.338
## DP (.10.) 0.733 0.041 17.855 0.000 0.374 0.722
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## PR ~

30
## OP (.15.) -0.593 0.053 -11.116 0.000 -0.457 -0.457
## AG (.16.) -0.554 0.058 -9.488 0.000 -0.374 -0.374
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP ~~
## AG 0.038 0.007 5.698 0.000 0.277 0.277
## .A1 ~~
## .A3 0.066 0.008 7.978 0.000 0.066 0.575
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## OP 0.155 0.012 12.667 0.000 1.000 1.000
## AG 0.118 0.013 9.279 0.000 1.000 1.000
## .O1 (.17.) 0.074 0.005 14.560 0.000 0.074 0.324
## .O2 (.18.) 0.079 0.005 15.867 0.000 0.079 0.370
## .O3 (.19.) 0.051 0.005 9.610 0.000 0.051 0.199
## .A1 (.20.) 0.132 0.009 14.287 0.000 0.132 0.527
## .A2 (.21.) 0.004 0.012 0.312 0.755 0.004 0.017
## .A3 (.22.) 0.100 0.008 11.834 0.000 0.100 0.448
## .EP (.23.) 0.221 0.016 14.050 0.000 0.221 0.459
## .SP (.24.) 0.233 0.014 16.496 0.000 0.233 0.569
## .HP (.25.) 2.133 0.106 20.044 0.000 2.133 0.885
## .DP (.26.) 0.129 0.009 14.562 0.000 0.129 0.479
## .PR 0.145 0.017 8.747 0.000 0.557 0.557
##
## R-Square:
## Estimate
## O1 0.676
## O2 0.630
## O3 0.801
## A1 0.473
## A2 0.983
## A3 0.552
## EP 0.541
## SP 0.431
## HP 0.115
## DP 0.521
## PR 0.443
# Model comparison
anova(model5.fit, model6.fit)

## Chi-Squared Difference Test


##
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## model5.fit 79 11214 11361 209.00
## model6.fit 81 11210 11348 209.24 0.2392 2 0.8873

31
R session info

sessionInfo()

## R version 3.6.3 (2020-02-29)


## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Sierra 10.12.6
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] corrplot_0.84 MPsychoR_0.10-7 semPlot_1.1.2 lavaan_0.6-5
##
## loaded via a namespace (and not attached):
## [1] nlme_3.1-144 RColorBrewer_1.1-2 mi_1.0
## [4] tools_3.6.3 backports_1.1.6 R6_2.4.1
## [7] d3Network_0.5.2.1 rpart_4.1-15 Hmisc_4.3-1
## [10] colorspace_1.4-1 nnet_7.3-12 tidyselect_1.0.0
## [13] gridExtra_2.3 mnormt_1.5-7 compiler_3.6.3
## [16] qgraph_1.6.5 fdrtool_1.2.15 htmlTable_1.13.3
## [19] regsem_1.5.2 scales_1.1.0 checkmate_2.0.0
## [22] psych_1.9.12.31 pbapply_1.4-2 sem_3.1-9
## [25] stringr_1.4.0 digest_0.6.25 pbivnorm_0.6.0
## [28] foreign_0.8-75 minqa_1.2.4 rmarkdown_2.1
## [31] base64enc_0.1-3 jpeg_0.1-8.1 pkgconfig_2.0.3
## [34] htmltools_0.4.0 lme4_1.1-23 lisrelToR_0.1.4
## [37] htmlwidgets_1.5.1 rlang_0.4.6 huge_1.3.4
## [40] rstudioapi_0.11 gtools_3.8.1 acepack_1.4.1
## [43] dplyr_0.8.5 zip_2.0.4 magrittr_1.5
## [46] OpenMx_2.17.3 Formula_1.2-3 Matrix_1.2-18
## [49] Rcpp_1.0.4.6 munsell_0.5.0 abind_1.4-5
## [52] rockchalk_1.8.144 lifecycle_0.2.0 whisker_0.4
## [55] stringi_1.4.6 yaml_2.2.1 carData_3.0-3
## [58] MASS_7.3-51.5 plyr_1.8.6 matrixcalc_1.0-3
## [61] grid_3.6.3 parallel_3.6.3 crayon_1.3.4
## [64] lattice_0.20-40 kutils_1.69 splines_3.6.3
## [67] knitr_1.28 pillar_1.4.3 igraph_1.2.5
## [70] rjson_0.2.20 boot_1.3-24 corpcor_1.6.9
## [73] BDgraph_2.62 codetools_0.2-16 reshape2_1.4.4
## [76] stats4_3.6.3 XML_3.99-0.3 glue_1.4.0
## [79] evaluate_0.14 latticeExtra_0.6-29 data.table_1.12.8
## [82] png_0.1-7 vctrs_0.2.4 nloptr_1.2.2.1
## [85] gtable_0.3.0 purrr_0.3.4 assertthat_0.2.1
## [88] ggplot2_3.3.0 xfun_0.13 openxlsx_4.1.4
## [91] xtable_1.8-4 coda_0.19-3 Rsolnp_1.16

32
## [94] survival_3.1-8 glasso_1.11 truncnorm_1.0-8
## [97] tibble_3.0.1 arm_1.10-1 cluster_2.1.0
## [100] statmod_1.4.34 ellipsis_0.3.0

33

You might also like