Example 5: Equality Constraint (lavaan input) - simsem/simsem GitHub Wiki
Model Description
This example will show how to specify a full SEM model with equality constraints. As the target model, two exogenous factors predict one endogenous factor. The effect from the first factor is 0.6. The effect from the second factor is 0.3. The endogenous factor has two indicators. The factor loadings of the endogenous factor are constrained to equality in the analysis model (labelled as con1). The endogenous factor loadings are 0.6. The endogenous factor's error variance is 0.64.

Syntax
The lavaan syntax for data generation can be specified:
popModel <- "
f1 =~ 0.7*y1 + 0.7*y2 + 0.7*y3
f2 =~ 0.7*y4 + 0.7*y5 + 0.7*y6
f3 =~ con1*y7 + con1*y8 + 0.6*y7 + 0.6*y8
f3 ~ 0.6*f1 + 0.3*f2
f1 ~~ 1*f1
f2 ~~ 1*f2
f3 ~~ 1*f3
f1 ~~ 0.5*f2
y1 ~~ 0.51*y1
y2 ~~ 0.51*y2
y3 ~~ 0.51*y3
y4 ~~ 0.51*y4
y5 ~~ 0.51*y5
y6 ~~ 0.51*y6
y7 ~~ 0.64*y7
y8 ~~ 0.64*y8
"
Note that the con1 label is actually not needed in data generation. However, the label will be used to compare the parameter estimates labeled as con1 in the analysis model below. If the label is not specified, the results from the data-generation model and analysis model cannot be compared. The lavaan script for data analysis can be specified:
analyzeModel <- "
f1 =~ y1 + y2 + y3
f2 =~ y4 + y5 + y6
f3 =~ con1*y7 + con1*y8
f3 ~ f1 + f2
"
Note that the con1 label is used twice to set an equality constraint. A Monte Carlo simulation can be implemented:
Output <- sim(1000, analyzeModel, n=200, generate=popModel, std.lv=TRUE, lavaanfun = "sem")
getCutoff(Output, 0.05)
plotCutoff(Output, 0.05)
summary(Output)
The figure below shows the graph provided by the plotCutoff function:

Here is the summary of the whole script in this example.