clear infile x1-x9 grp using "Z:\PUBLIC_WEB\MPlus\Basics\Grouped\ex5.15.dat" // a simple measurement model, estimated using all the data sem (L1 -> x1-x3), var(L1@1) // saturated model // using just a subset of the data sem (L1 -> x1-x3) if grp==1, var(L1@1) sem (L1 -> x1-x3), var(L1@1) group(grp) // default constraints across groups: scale-equivalent (parallel) measures estat mindices // There are several things to keep in mind when loosening cross-group // constraints: (1) constraints are cumulative, (2) including the // default constraints, and (3) we have syntax for specifying group- // specific equations. // You do NOT loosen constraints just by specifying explicit parameters sem (L1 -> x1@a x2@b x3), var(L1@1) group(grp) // This is the same as the previous model because constraints are // cumulative. The default group constraints here are sem (L1 -> x1-x3), var(L1@1) group(grp) ginvariant(mcons mcoef) // Change the defaults by specifying anything else, such as sem (L1 -> x1@a x2@b x3), var(L1@1) group(grp) ginvariant(mcons) // This is the least modified model. Now recheck the modification // indices. estat mindices // Suppose we wanted to specify a model with no coefficient for // one group. We have a couple of methods to do this. sem (1: L1 -> x1@a x2@b x3)(2: L1 -> x1@a x2@b), var(L1@1) group(grp) sem (L1 -> x1 x2)(1: L1 -> x3), var(L1@1) group(grp) //ginvariant(mcons mcoef) sem (L1 -> x1 x2 x3)(2: L1 _cons -> x3@0), var(L1@1) var(2: e.x3@0) group(grp) // Note the group number comes from the data value. If our values // are {1,5} then it would be replace grp=5 if grp==2 sem (1: L1 -> x1@a x2@b x3)(5: L1 -> x1@a x2@b), var(L1@1) group(grp) // Finally, we use grp as a binary exogenous variable replace grp=0 if grp==5 sem (grp -> L1)(L1 -> x1-x3) estimates store binex // This is equivalent to sem (L1 -> x1-x3), group(grp) ginvariant(mcons mcoef merrvar covex) // This is NOT the same as ginvariant(all), because the means of the // exogenous latent variables are not constrained to be equal. estimates table . binex // Notice how a couple of parameters show up with different names in // the different specifications.