Stata sem

The sem command fits a SEM.


Usage

Adapted from https://www.stata.com/features/overview/structural-equation-modeling/explanation/:

. webuse sem_1fmm
(Single-factor measurement model)

. rename x4 y

. sem (x1<-X) (x2<-X) (x3<-X) (y<-X)

Endogenous variables
  Measurement: x1 x2 x3 y

Exogenous variables
  Latent: X

Fitting target model:
Iteration 0:   log likelihood = -8487.5905  
Iteration 1:   log likelihood = -8487.2358  
Iteration 2:   log likelihood = -8487.2337  
Iteration 3:   log likelihood = -8487.2337  

Structural equation model                                  Number of obs = 500
Estimation method: ml

Log likelihood = -8487.2337

 ( 1)  [x1]X = 1
------------------------------------------------------------------------------
             |                 OIM
             | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
Measurement  |
  x1         |
           X |          1  (constrained)
       _cons |     99.518   .6412888   155.18   0.000      98.2611    100.7749
  -----------+----------------------------------------------------------------
  x2         |
           X |   1.033249   .0723898    14.27   0.000     .8913676     1.17513
       _cons |     99.954   .6341354   157.62   0.000     98.71112    101.1969
  -----------+----------------------------------------------------------------
  x3         |
           X |   1.063876   .0729725    14.58   0.000     .9208526      1.2069
       _cons |     99.052   .6372649   155.43   0.000     97.80298     100.301
  -----------+----------------------------------------------------------------
  y          |
           X |   7.276754   .4277638    17.01   0.000     6.438353    8.115156
       _cons |     94.474   3.132547    30.16   0.000     88.33432    100.6137
-------------+----------------------------------------------------------------
    var(e.x1)|   115.6865   7.790423                      101.3823    132.0089
    var(e.x2)|   105.0445    7.38755                      91.51873    120.5692
    var(e.x3)|   101.2572    7.17635                      88.12499    116.3463
     var(e.y)|   144.0406   145.2887                      19.94838    1040.069
       var(X)|   89.93921   11.07933                      70.64676    114.5001
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(2) = 1.46            Prob > chi2 = 0.4827

A more complex example:

. sem (X -> x1 x2 x3) (Z -> z1 z2 z3) (Y -> y1 y2 y3) (Y <- X Z), noanchor variance(X@1 Z@1 e.Y@1) noconstant

Note that assumptions about variances must be specified on the variance option. In this case, the variances of latent variables (i.e., var(X) and var(Z)) and the variance of the outcome variable's errors (i.e. var(e.Y)) are all assumed to be uniform.


See also

gsem

Stata manual for sem


CategoryRicottone

Stata/Sem (last edited 2025-04-04 03:29:06 by DominicRicottone)