[SEM] sem -- Structural equation model estimation command
sem paths [if] [in] [weight] [, options]
where paths are the paths of the model in command-language path notation;
see [SEM] sem and gsem path notation.
model_description_options fully define, along with paths, the model
to be fit
group_options fit model for different groups
ssd_options for use with summary statistics data
estimation_options method used to obtain estimation results
reporting_options reporting of estimation results
syntax_options controlling interpretation of syntax
Time-series operators are allowed.
bootstrap, by, jackknife, permute, statsby, and svy are allowed; see
Weights are not allowed with the bootstrap prefix.
vce() and weights are not allowed with the svy prefix.
fweights, iweights, and pweights are allowed; see weight.
Also see [SEM] sem postestimation for features available after
Statistics > SEM (structural equation modeling) > Model building and
sem fits structural equation models. Even when you use the SEM Builder,
you are using the sem command.
model_description_options describe the model to be fit. The model to be
fit is fully specified by paths -- which appear immediately after sem
-- and the options covariance(), variance(), and means(). See [SEM]
sem model description options and [SEM] sem and gsem path notation.
group_options allow the specified model to be fit for different subgroups
of the data, with some parameters free to vary across groups and
other parameters constrained to be equal across groups. See [SEM]
sem group options.
ssd_options allow models to be fit using summary statistics data (SSD),
meaning data on means, variances (standard deviations), and
covariances (correlations). See [SEM] sem ssd options.
estimation_options control how the estimation results are obtained.
These options control how the standard errors (VCE) are obtained and
control technical issues such as choice of estimation method. See
[SEM] sem estimation options.
reporting_options control how the results of estimation are displayed.
See [SEM] sem reporting options.
syntax_options control how the syntax that you type is interpreted. See
[SEM] sem and gsem syntax options.
For a readable explanation of what sem can do and how to use it, see any
of the intro sections. You might start with [SEM] intro 1.
For examples of sem in action, see any of the example sections. You
might start with [SEM] example 1.
For detailed syntax and descriptions, see the references below.
See the following advanced topics in [SEM] sem:
Default normalization constraints
Default covariance assumptions
How to solve convergence problems
These examples are intended for quick reference. For detailed examples,
see [SEM] examples.
. webuse census13
Use correlate command
. correlate mrgrate dvcrate medage
Replicate with sem
. sem ( <- mrgrate dvcrate medage), standardized
Examples: Linear regression
. sysuse auto
. generate weight2 = weight^2
Use regress command
. regress mpg weight weight2 foreign
Replicate model with sem
. sem (mpg <- weight weight2 foreign)
Examples: Single-factor measurement model
. webuse sem_1fmm, clear
CFA model with a single latent variable X
. sem (x1 x2 x3 x4 <- X)
Display standardized results
. sem, standardized
Examples: Two-factor measurement model
. webuse sem_2fmm
CFA model with two latent variables: Affective and Cognitive
. sem (Affective -> a1 a2 a3 a4 a5)
(Cognitive -> c1 c2 c3 c4 c5)
Examples: Nonrecursive structural model
. webuse sem_sm1
Model with a feedback loop
. sem (r_occasp <- f_occasp r_intel r_ses f_ses)
(f_occasp <- r_occasp f_intel f_ses r_ses),
Examples: MIMIC model
. webuse sem_mimic1
. sem (SubjSES -> s_income s_occpres s_socstat)
(SubjSES <- income occpres)
Examples: Latent growth model
. webuse sem_lcm
Fit latent growth model
. sem (lncrime0 <- Intercept@1 Slope@0)
(lncrime1 <- Intercept@1 Slope@1)
(lncrime2 <- Intercept@1 Slope@2)
(lncrime3 <- Intercept@1 Slope@3),
means(Intercept Slope) noconstant
sem stores the following in e():
e(N) number of observations
e(N_clust) number of clusters
e(N_groups) number of groups
e(N_missing) number of missing values in the sample for
e(ll) log likelihood of model
e(df_m) model degrees of freedom
e(df_b) baseline model degrees of freedom
e(df_s) saturated model degrees of freedom
e(chi2_ms) test of target model against saturated model
e(df_ms) degrees of freedom for e(chi2_ms)
e(p_ms) p-value for e(chi2_ms)
e(chi2sb_ms) Satorra-Bentler scaled test of target model against
e(psb_ms) p-value for e(chi2sb_ms)
e(sbc_ms) Satorra-Bentler correction factor for e(chi2sb_ms)
e(chi2_bs) test of baseline model against saturated model
e(df_bs) degrees of freedom for e(chi2_bs)
e(p_bs) p-value for e(chi2_bs)
e(chi2sb_bs) Satorra-Bentler scaled test of baseline model
against saturated model
e(psb_bs) p-value for e(chi2sb_bs)
e(sbc_bs) Satorra-Bentler correction factor for e(chi2sb_bs)
e(rank) rank of e(V)
e(ic) number of iterations
e(rc) return code
e(converged) 1 if target model converged, 0 otherwise
e(critvalue) log likelihood or discrepancy of fitted model
e(critvalue_b) log likelihood or discrepancy of baseline model
e(critvalue_s) log likelihood or discrepancy of saturated model
e(modelmeans) 1 if fitting means and intercepts, 0 otherwise
e(cmdline) command as typed
e(data) raw or ssd if SSD data were used
e(wtype) weight type
e(wexp) weight expression
e(title) title in estimation output
e(clustvar) name of cluster variable
e(vce) vcetype specified in vce()
e(vcetype) title used to label Std. Err.
e(method) estimation method: ml, mlmv, or adf
e(technique) maximization technique
e(properties) b V
e(estat_cmd) program used to implement estat
e(predict) program used to implement predict
e(lyvars) names of latent y variables
e(oyvars) names of observed y variables
e(lxvars) names of latent x variables
e(oxvars) names of observed x variables
e(groupvar) name of group variable
e(xconditional) empty if noxconditional specified, xconditional
e(marginsnotok) predictions not allowed by margins
e(marginsdefault) default predict() specification for margins
e(b) parameter vector
e(b_std) standardized parameter vector
e(b_pclass) parameter class
e(Cns) constraints matrix
e(admissible) admissibility of Sigma, Psi, Phi
e(ilog) iteration log (up to 20 iterations)
e(gradient) gradient vector
e(V) covariance matrix of the estimators
e(V_std) standardized covariance matrix of the estimators
e(V_modelbased) model-based variance
e(nobs) vector with number of observations per group
e(groupvalue) vector of group values of e(groupvar)
e(sample) marks estimation sample (not with SSD)