Stata's generalized structural equations model (SEM) command now makes it easy to fit models on data comprising groups.
gsem's new features, you can perform a confirmatory factor analysis (CFA) and allow for differences between men and women by typing:
If you are new to Stata and
gsem, let us tell you that this is just one new feature in a command that already has many features
gsem fits confirmatory factor models, seemingly unrelated models, SEMs, multilevel models, and all combinations thereof. It fits these models with outcomes that are continuous, binary, ordinal, count, and even survival. With the new
group() option, we can estimate distinct parameters across groups for any of these models. We can even combine group analysis with
gsem's other new featurelatent class analyses.
The new syntax features are the
ginvariant() options. They work together. Say you want to fit a path model such as:
If you wanted to fit the same model but obtain separate parameter estimates for each of three groups in the data identified by variable subset equal to 1, 2, and 3, you could fit the model three times:
But then you could not compare the fitted parameters or constrain some parameters to be equal across groups.
In Stata 15, you can type:
And you can specify a separate model for each group:
ginvariant() option specifies which fitted parameters are to be constrained to be equal across groups. The types of parameters
gsem fits are
Thus, if you type:
only the intercepts are constrained to be equal across groups.