| Code for the SEM-Based DTSM |
| TITLE: (a) |
| SEM-based DTSM Example; |
| DATA: (b) |
| FILE IS example2.txt; |
| VARIABLE: (c) |
| NAMES ARE x m y5 y6 y7 y8 y9; |
| USEVARIABLES ARE x m y5 y6 y7 y8 y9; |
| CATEGORICAL = y5 y6 y7 y8 y9; |
| MISSING ARE ALL (−999); |
| ANALYSIS: (d) |
| TYPE = GENERAL; |
| ESTIMATOR = MLR; |
| LINK = LOGIT; |
| ALGORITHM = INTEGRATION EM; |
| INTEGRATION = MONTECARLO (500); |
| MODEL: (e) |
| [x]; |
| x; |
| m ON x (p1); |
| [m]; |
| m; |
| factor BY y5@1 y6@1 y7@1 y8@1 y9@1; |
| [y5$1 y6$1 y7$1 y8$1 y9$1]; |
| factor@0; |
| factor ON x m (p2-p3); |
| MODEL CONSTRAINT: (f) |
| NEW (ab); |
| ab = p1 * p3; |
| OUTPUT: (g) |
| SAMPSTAT; |
| CINTERVAL; |
Programming Notes:
In the TITLE command make a title for the analysis.
In the DATA command specify the data file.
In the VARIABLE command name the variables as they appear in the dataset, specify the categorical outcomes to create binary event indicators for each time period, and identify the missing value code. Specify a subset of variables to use for analysis if applicable.
In the ANALYSIS command specify a general model with MLR estimation; use a logit link function and the EM integration algorithm. Specify the number of integration points to estimate in parentheses.
In the MODEL command estimate the mean and variance of X so that the program can handle any missing data. Estimate the a path of the mediation model by regressing M on X. Name the parameter. Estimate the mean and variance of M. Specify a proportional odds model for Y by creating a latent factor defined by the binary event indicators and constraining all the factor loadings to be equal. Freely estimate the thresholds for each time point. Fix the variance of the latent factor to zero. Estimate the b and c’ paths of the mediation model by regressing the latent factor on X and M. Name the parameters.
In the MODEL CONSTRAINT command define the indirect effect by naming the variable and calculating it using previously estimated parameters.
In the OUTPUT command request information you deem useful.