The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The syntax is, for the most part, identical to that of lavaan (Rosseel, 2012). That being said, there are some OpenMx (Boker et al., 2011) specific elements.
The following specifies loadings of a latent variable
eta
on manifest variables
y1
-y4
:
eta =~ y1 + y2 + y3
Regressions are specified with ~
:
xi =~ x1 + x2 + x3
eta =~ y1 + y2 + y3
# predict eta with xi:
eta ~ xi
Add covariances with ~~
xi =~ x1 + x2 + x3
eta =~ y1 + y2 + y3
# predict eta with xi:
eta ~ xi
x1 ~~ x2
Intercepts are specified with ~1
xi =~ x1 + x2 + x3
eta =~ y1 + y2 + y3
# predict eta with xi:
eta ~ xi
x1 ~~ x2
eta ~ 1
Note: In lavaan’s
sem
-function, the loading on the first item of each latent variable is constrained to one by default. Estimating this loading freely requires replacingxi =~ x1 + x2 + x3
withxi =~ NA*x1 + x2 + x3
. In mxsem, a different approach is used. When calling themxsem
-function set the argumentscale_loadings
toFALSE
to freely estimate all loadings.
Add labels to parameters as follows:
xi =~ l1*x1 + l2*x2 + l3*x3
eta =~ l4*y1 + l5*y2 + l6*y3
# predict eta with xi:
eta ~ b*xi
Fix parameters by using numeric values instead of labels:
xi =~ 1*x1 + l2*x2 + l3*x3
eta =~ 1*y1 + l5*y2 + l6*y3
# predict eta with xi:
eta ~ b*xi
Lower and upper bounds allow for constraints on parameters. For instance, a lower bound can prevent negative variances.
xi =~ 1*x1 + l2*x2 + l3*x3
eta =~ 1*y1 + l5*y2 + l6*y3
# predict eta with xi:
eta ~ b*xi
# residual variance for x1
x1 ~~ v*x1
# bound:
v > 0
Upper bounds are specified with v < 10. Note that the parameter
label must always come first. The following is not allowed:
0 < v
or 10 > v
.
Assume that latent construct eta
was observed twice,
where eta1
is the first observation and eta2
the second. We want to define the loadings of eta2
on its
observations as l_1 + delta_l1
. If delta_l1
is
zero, we have measurement invariance.
eta1 =~ l1*y1 + l2*y2 + l3*y3
eta2 =~ l4*y4 + l5*y5 + l6*y6
# define new delta-parameter
!delta_1; !delta_2; !delta_3
# redefine l4-l6
l4 := l1 + delta_1
l5 := l2 + delta_2
l6 := l3 + delta_3
Alternatively, implicit transformations can be used as follows:
eta1 =~ l1*y1 + l2*y2 + l3*y3
eta2 =~ {l1 + delta_1} * y4 + {l2 + delta_2} * y5 + {l3 + delta_3} * y6
This is inspired by the approach in metaSEM (Cheung, 2015).
Definition variables allow for person-specific parameter constraints.
Use the data.
-prefix to specify definition variables.
I =~ 1*y1 + 1*y2 + 1*y3 + 1*y4 + 1*y5
S =~ data.t_1 * y1 + data.t_2 * y2 + data.t_3 * y3 + data.t_4 * y4 + data.t_5 * y5
I ~ int*1
S ~ slp*1
You can specify a model name using the following syntax:
# start with at least three equal signs:
=== model_name ===
I =~ 1*y1 + 1*y2 + 1*y3 + 1*y4 + 1*y5
S =~ data.t_1 * y1 + data.t_2 * y2 + data.t_3 * y3 + data.t_4 * y4 + data.t_5 * y5
I ~ int*1
S ~ slp*1
Note that mxsem will ignore everything above the three (or more) equal signs! That is, the following will result in problems:
# the following two lines will be ignored:
I =~ 1*y1 + 1*y2 + 1*y3 + 1*y4 + 1*y5
S =~ data.t_1 * y1 + data.t_2 * y2 + data.t_3 * y3 + data.t_4 * y4 + data.t_5 * y5
# start with at least three equal signs:
=== model_name ===
I ~ int*1
S ~ slp*1
mxsem differs from lavaan in the specification of
starting values. Instead of providing starting values in the model
syntax, the set_starting_values
function is used.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.