Using Mplus

For Mplus (Muthén and Muthén 2017) to work properly, make sure that you save the input file with the model specification (example.inp) in the same folder as the data (example.dat). You can download the simulated example datasets here. Mplus includes defaults, like that:

These defaults are included to make the specification of many standard SEM models easier, but they are not always useful in the current modeling context. Therefore, we use the command ANALYSIS: MODEL = NOCOV; to overrule these defaults for the covariances and set all of them to zero.

Mplus residual language

From Mplus version 8.7 onward, the Residual Structural Equation Modeling (RSEM) capabilities have been expanded (Asparouhov and Muthén 2021). This allows for considerably simpler model syntax for the RI-CLPM using the ^ command. You can find Mplus syntax using this alternative hats-notation for the basic RI-CLPM (both with and without constraints over time) in the Residual syntax section.

The RI-CLPM

To specify the RI-CLPM we need four parts.

  • A between part, consisting of the random intercepts. It is specified using the BY command, RIx BY x1@1 x2@1 ...;, where @1 fixes the factor loading to one.
  • A within part, consisting of within-unit fluctuations. It is also specified using the BY command, wx1 BY x1; wx2 BY x2; .... We do not have to constrain the factor loading to 1, as this is already the default in Mplus for the factor loading of the first indicator of a latent variable. However, we do need to constrain the measurement error variances to zero, as Mplus will include them by default when we use the BY statement. We do this by including x1@0 x2@0 x3@0 x4@0 x5@0; where @0 fixes the measurement error variances to zero, which is the same as saying there is no measurement error.
  • The lagged regressions between the within-unit components, using wx2 ON wx1 wy1; wx3 ON wx2 wy2; ....
  • Relevant covariances in both the between and within part. In the within part the components at wave 1, and their residuals at waves 2 and further are correlated within each wave, using wx1 WITH wy1; wx2 WITH wy2;.... For the between part we have to specify that the random intercepts are correlated using RIx WITH RIy;.

The syntax for specifying the basic RI-CLPM is given below.

TITLE:      The basic RI-CLPM, 5 waves. 
       
DATA:       FILE = RICLPM.dat;
                    
VARIABLE:   NAMES = x1-x5 y1-y5;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
        
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1; 
            wx5 BY x5@1;
            
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1; 
            wy5 BY y5@1;
    
            ! Constrain measurement error variances to 0
            x1-y5@0;
    
            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1;
            wx3 wy3 ON wx2 wy2;
            wx4 wy4 ON wx3 wy3;
            wx5 wy5 ON wx4 wy4;
    
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Estimate covariance between within-person components at first wave
            wx1 WITH wy1;
                
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4;
            wx5 WITH wy5; 
                
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Imposing constraints to the model can be achieved by giving labels to parameters and using the same label for parameters that you want to constrain to be equal. A label is specified by adding (label) after a parameter. Below we specify a RI-CLPM with the following constraints:

  • fixed auto-regressive and cross-lagged relations over time, (a b c d),
  • time-invariant (residual) (co-)variances in the within-person part (cov), (vx), and (vy), and
  • constrained grand means over time, (mx) and (my).
TITLE:      The basic RI-CLPM, 5 waves. 
            Constrain the grand means, (residual) variances, and 
            lagged effects over time.   
    
DATA:       FILE = RICLPM.dat;  
                
VARIABLE:   NAMES = x1-x5 y1-y5;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
      
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1; 
            wx5 BY x5@1;
                
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1; 
            wy5 BY y5@1;
    
            ! Constrain measurement error variances to 0
            x1-y5@0;
    
            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1 (a b c d);
            wx3 wy3 ON wx2 wy2 (a b c d);
            wx4 wy4 ON wx3 wy3 (a b c d);
            wx5 wy5 ON wx4 wy4 (a b c d);
  
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Estimate covariance between within-person components at the first wave
            wx1 WITH wy1;
                
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations) and constrain these and residual variances to be 
            ! invariant over time
            wx2 WITH wy2 (cov); wx2 (vx); wy2 (vy);
            wx3 WITH wy3 (cov); wx3 (vx); wy3 (vy);
            wx4 WITH wy4 (cov); wx4 (vx); wy4 (vy); 
            wx5 WITH wy5 (cov); wx5 (vx); wy5 (vy);

            ! Constrain grand means to be invariant over time
            [x1 x2 x3 x4 x5] (mx);
            [y1 y2 y3 y4 y5] (my);
                
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Rather than imposing constraints on the unstandardized auto-regressive and cross-lagged relations over time, we can impose constraints on the standardized lagged effects, as explained in the FAQ. Compared to the basic model, there are multiple changes to the syntax. First, we freely estimate the factor loadings that link the observed variables to the within-components, rather than fixing them to 1:

! Create within-components with freely estimated factor loadings
wx1 BY x1*; 
wx2 BY x2*;
wx3 BY x3*; 
wx4 BY x4*; 
wx5 BY x5*;
                
wy1 BY y1*; 
wy2 BY y2*;
wy3 BY y3*; 
wy4 BY y4*; 
wy5 BY y5*;

Second, we set the variances of within-components at first wave to 1, and label the covariance (now also the correlation) between them:

! Set variances of within-components at first wave to 1
wx1@1 wy1@1;

! Estimate correlation between within-components at first wave
wx1 WITH wy1 (cor1);

Third, we give the residual variance and covariances between the within-component each a unique label:

wx2 WITH wy2 (rcov2); wx2 (rvx2); wy2 (rvy2);
wx3 WITH wy3 (rcov3); wx3 (rvx3); wy3 (rvy3);
wx4 WITH wy4 (rcov4); wx4 (rvx4); wy4 (rvy4); 
wx5 WITH wy5 (rcov5); wx5 (rvx5); wy5 (rvy5);

Finally, we compute the correlations between the within-components themselves at each wave, and then constrain the residual variances to ensure that the total variance of each within-component equals 1. This is done in the MODEL CONSTRAINT command:

MODEL CONSTRAINT:
  ! Compute correlations of within-components at each wave
  NEW(cor2);
  NEW(cor3);
  NEW(cor4);
  
  cor2 = a*c + b*d + a*d*cor1 + b*c*cor1 + rcov2;
  cor3 = a*c + b*d + a*d*cor2 + b*c*cor2 + rcov3;
  cor4 = a*c + b*d + a*d*cor3 + b*c*cor3 + rcov4;
 
  ! Contrain residual variances of within-components such that variance of each 
  ! within-component equals 1
  rvx2 = 1 - (a*a + b*b + 2*a*b*cor1);
  rvy2 = 1 - (c*c + d*d + 2*c*d*cor1);
  rvx3 = 1 - (a*a + b*b + 2*a*b*cor2);
  rvy3 = 1 - (c*c + d*d + 2*c*d*cor2);
  rvx4 = 1 - (a*a + b*b + 2*a*b*cor3);
  rvy4 = 1 - (c*c + d*d + 2*c*d*cor3);
  rvx5 = 1 - (a*a + b*b + 2*a*b*cor4);
  rvy5 = 1 - (c*c + d*d + 2*c*d*cor4);

Extension 1: Including time-invariant predictors and outcomes

Use the tabs below to navigate to the model specification of the RI-CLPM with

  • a time-invariant predictor \(z_{1}\) of the observed variables (\(z_{1}\) \(\rightarrow\) observed),
  • a time-invariant predictor \(z_{1}\) of the random intercepts (\(z_{1}\) \(\rightarrow\) RIs),
  • random intercepts predicting a time-invariant outcome \(z_{2}\) (RIs \(\rightarrow\) \(z_{2}\)), or
  • within components predicting a time-invariant outcome \(z_{2}\) (within \(\rightarrow\) \(z_{2}\)).

Below you can find the syntax for a RI-CLPM with 5 waves and a time-invariant predictor \(z_{1}\) for the observed variables. The effect of \(z_{1}\) on the observed variables is constrained to be the same across waves.

TITLE:      RI-CLPM, 5 waves, including a time-invariant predictor for
            the observed variables. 
       
DATA:       FILE = RICLPM-Z.dat;
                
VARIABLE:   NAMES = x1-x5 y1-y5 z2 z1;
            USEVARIABLES = x1-y5 z1;
        
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
    
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1;
            wx5 BY x5@1;
    
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1;
            wy5 BY y5@1;

            ! Constrain measurement error variances to 0
            x1-y5@0;

            ! Regression of observed variables on z1 (unconstrained)
            x1-x5 ON z1 (s1);
            y1-y5 ON z1 (s2);

            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1;
            wx3 wy3 ON wx2 wy2;
            wx4 wy4 ON wx3 wy3;
            wx5 wy5 ON wx4 wy4;

            ! Estimate covariance between within-person components at first wave 
            wx1 WITH wy1;
           
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4; 
            wx5 WITH wy5;
  
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Below you can find the syntax for a RI-CLPM with 5 waves and a time-invariant predictor \(z_{1}\) for the random intercepts.

TITLE:      RI-CLPM, 5 waves, including a time-invariant predictor for
            the random intercepts. 
       
DATA:       FILE = RICLPM-Z.dat;
                  
VARIABLE:   NAMES = x1-x5 y1-y5 z2 z1;
            USEVARIABLES = x1-y5 z1;
        
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
    
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1;
            wx5 BY x5@1;

            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1;
            wy5 BY y5@1;
    
            ! Constrain measurement error variances to 0
            x1-y5@0;
    
            ! Regression of random intercepts on z1
            RIx RIy ON z1;
    
            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1;
            wx3 wy3 ON wx2 wy2;
            wx4 wy4 ON wx3 wy3;
            wx5 wy5 ON wx4 wy4;
  
            ! Estimate covariance between within-person components at first wave 
            wx1 WITH wy1;
               
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4; 
            wx5 WITH wy5;
  
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Below you can find the syntax for a RI-CLPM with 5 waves and the random intercepts predicting the time-invariant outcome \(z_{2}\).

TITLE:      RI-CLPM, 5 waves.
              Time-invariant predictor z1 for observed variables (constrained).
              Between components predicting time-invariant outcome z2.
       
DATA:       FILE = RICLPM-Z.dat;
                  
VARIABLE:   NAMES = x1-x5 y1-y5 z2 z1;
        
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
    
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
    
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Regres distal outcome on random intercepts
            z2 ON RIx RIy;
                
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1;
            wx5 BY x5@1;
  
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1;
            wy5 BY y5@1;
    
            ! Constrain measurement error variances to 0
            x1-y5@0;
  
            ! Regression of observed variables on z1 (constrained)
            x1-x5 ON z1 (s1);
            y1-y5 ON z1 (s2);
    
            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1;
            wx3 wy3 ON wx2 wy2;
            wx4 wy4 ON wx3 wy3;
            wx5 wy5 ON wx4 wy4;
    
            ! Estimate covariance between within-person components at first wave 
            wx1 WITH wy1;
           
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4; 
            wx5 WITH wy5;
    
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Below you can find the syntax for a RI-CLPM with 5 waves and the within components predicting the time-invariant outcome \(z_{2}\).

TITLE:      RI-CLPM, 5 waves
              Time-invariant predictor z1 for observed variables (constrained).
              Within components predicting time-invariant outcome z2.
       
DATA:       FILE = RICLPM-Z.dat;
                  
VARIABLE:   NAMES = x1-x5 y1-y5 z2 z1;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
    
MODEL:      ! Create between-components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;

            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1;
            wx5 BY x5@1;
    
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1;
            wy5 BY y5@1;
    
            ! Constrain measurement error variances to 0
            x1-y5@0;

              ! Regres distal outcome on within components
            z2 ON wx1-wx5 wy1-wy5;
            
            ! Regression of observed variables on z1 (constrained)
            x1-x5 ON z1 (s1);
            y1-y5 ON z1 (s2);

            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1;
            wx3 wy3 ON wx2 wy2;
            wx4 wy4 ON wx3 wy3;
            wx5 wy5 ON wx4 wy4;
    
            ! Estimate covariance between within-person components at first wave 
            wx1 WITH wy1;
               
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4; 
            wx5 WITH wy5;
  
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Extension 2: Multiple group

Use the tabs below to navigate to the model specification of the basic multiple-group model, or the model with constrained lagged parameters (and intercepts across groups).

To specify a multiple group RI-CLPM, we need to overrule some of the defaults that Mplus will impose and that are associated with multiple group factor analysis. The reason for this is that when we use the BY statement in combination with multiple groups, Mplus will automatically impose the defaults that are associated with strong factorial invariance (Meredith 1993). These defaults are:

  • equal factor loadings across the groups,
  • equal intercepts for the observed variables across the groups, and
  • free latent means in the second (and subsequent) group(s).

In the context of a multiple-group RI-CLPM, the first constraint is not an issue as all the factor loadings are supposed to be constrained to one in both groups. However, the second constraint on the intercepts and the freeing of the latent means in the second group are not sensible here. There will be fewer observed variables than latent variables defined with a BY statement (i.e., a within-unit part for each observed variable, plus a random intercept for each variable); as a result, we would try to estimate more means than that there were observed. Such a model is unidentified. We should therefore overrule the defaults associated with the mean structure. We do this by adding for the second group [x1 x2 ...]; which frees the intercepts for the observed variables in the second group. Additionally, we include [wx1@0 wx2@0 ... ]; [RIx@0]; for the second group, which ensures all latent means are fixed to zero.

Below you can find the code for a multiple group RI-CLPM with 5 waves.

TITLE:      Multiple group RI-CLPM, 5 waves. 
            Overruling the Mplus multiple group factor analysis defaults.
                
DATA:       FILE = RICLPM-MG.dat;
                  
VARIABLE:   NAMES = x1-x5 y1-y5 GROUP;
            GROUPING = GROUP (1=G1 2=G2);
        
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
        
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1; 
            wx5 BY x5@1;
                
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1; 
            wy5 BY y5@1;
        
            ! Constrain measurement error variances to 0
            x1-y5@0;
        
            ! Estimate lagged effects between within-person centered variables
            wx2 wy2 ON wx1 wy1;
            wx3 wy3 ON wx2 wy2;
            wx4 wy4 ON wx3 wy3;
            wx5 wy5 ON wx4 wy4;
        
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
        
            ! Estimate covariance between within-person components at first wave
            wx1 WITH wy1;
                    
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4;
            wx5 WITH wy5; 
        
MODEL G2:   ! Overrule multiple group factor analysis default of equal intercepts 
            ! across groups
            [x1-y5];
              
            ! Overrule multiple group factor analysis default of free latent means 
            ! in second group
            [wx1-wy5@0];
            [RIx@0 RIy@0];
                       
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Below you can find the code for a multiple group RI-CLPM, 5 waves. The lagged-parameters are constrained to be equal over time.

TITLE:      Multiple group RI-CLPM, 5 waves, with equal lagged parameters 
            across groups. 
            Overruling the Mplus multiple group factor analysis defaults.
                
DATA:       FILE = RICLPM-MG.dat;
                
VARIABLE:   NAMES = x1-x5 y1-y5 GROUP;
            GROUPING = GROUP (1=G1 2=G2);
        
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
    
MODEL:      ! Create between components (random intercepts)
            RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
            RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
    
            ! Create within-person centered variables
            wx1 BY x1@1; 
            wx2 BY x2@1;
            wx3 BY x3@1; 
            wx4 BY x4@1; 
            wx5 BY x5@1;
                
            wy1 BY y1@1; 
            wy2 BY y2@1;
            wy3 BY y3@1; 
            wy4 BY y4@1; 
            wy5 BY y5@1;
        
            ! Constrain measurement error variances to 0
            x1-y5@0;
        
            ! Estimate lagged effects between within-person centered variables 
            ! (constrained across groups)
            wx2 wy2 ON wx1 wy1 (a1 b1 c1 d1);
            wx3 wy3 ON wx2 wy2 (a2 b2 c2 d2);
            wx4 wy4 ON wx3 wy3 (a3 b3 c3 d3);
            wx5 wy5 ON wx4 wy4 (a4 b4 c4 d4);
        
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
    
            ! Estimate covariance between within-person components at first wave
            wx1 WITH wy1;
                    
            ! Estimate covariances between residuals of within-person components 
            ! (i.e., innovations)
            wx2 WITH wy2;
            wx3 WITH wy3; 
            wx4 WITH wy4;
            wx5 WITH wy5; 
    
MODEL G2:   ! Overrule multiple group factor analysis default of equal intercepts 
            ! across groups
            [x1-y5];
              
            ! Overrule multiple group factor analysis default of free latent means 
            ! in second group
            [wx1-wy5@0];
            [RIx@0 RIy@0];

            ! Estimate lagged effects between within-person centered variables 
            ! (constrained across groups)
            wx2 wy2 ON wx1 wy1 (a1 b1 c1 d1);
            wx3 wy3 ON wx2 wy2 (a2 b2 c2 d2);
            wx4 wy4 ON wx3 wy3 (a3 b3 c3 d3);
            wx5 wy5 ON wx4 wy4 (a4 b4 c4 d4);
                   
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Extension 3: Multiple indicators

Use the tabs below to navigate to the model specification of a multiple indicator RI-CLPM, 5 waves and 3 indicators for each variable at each wave. The five steps correspond to:

  • the configural model (Step 1),
  • weak factorial invariance (Step 2),
  • strong factorial invariance (Step 3),
  • strong factorial invariance with factor loadings equal to the within-person factor loadings (Extra), and
  • the latent RI-CLPM (Step 4).

When we have three indicators \(X\), measured at five waves, we specify three random intercepts to capture the trait-like part of each indicator, that is, RIX1 BY x11@1 x21@1 ...;, RIX2 BY x12@1 x22@1 ...;, and RIX3 BY x13@1 x23@1 ...;. In addition, we specify five within-unit components that capture the state-like part at each wave, using WFX1 BY x11 x12 x13; WFX2 BY x21 x22 x23; ....

At the latent within-unit level, we specify the dynamic model in Mplus usingWFX2 ON WFY1 WFX1; WFX3 ON WFY2 WFX2; .... In addition, we allow the within-person factors at the first wave, and their residuals at subsequent waves to be correlated within each wave, WFX1 WITH WFY1; WFX2 WITH WFY2; .... The six random intercepts are allowed to be freely correlated with each other through RIX1-RIY3 WITH RIX1-RIY3;.

TITLE:      Multiple indicator RI-CLPM, 5 waves, with 3 indicators for 
            each variable at each wave (30 observed variables) and with 
            random intercepts for each indicator separately.
    
DATA:       FILE = RICLPM-MI.dat;
                
VARIABLE:   NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33 
                    x41 x42 x43 x51 x52 x53 y11 y12 y13 
                    y21 y22 y23 y31 y32 y33 y41 y42 y43 
                    y51 y52 y53;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
    
MODEL:      
            !!!!!!!!!!!!!!!!    
            ! BETWEEN PART !
            !!!!!!!!!!!!!!!!
    
            ! Create between factors (random intercepts) for each indicator separately
            RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
            RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
            RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
            
            RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
            RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
            RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;

            ! Add covariances between all RIs
            RIX1-RIY3 WITH RIX1-RIY3;
 
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: MEASUREMENT MODEL !
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
            ! Due to having a random intercept per indicator, the measurement model 
            ! is only on the within part of the measurements

            ! Factor models for X at 5 waves
            WFX1 BY x11-x13;
            WFX2 BY x21-x23;
            WFX3 BY x31-x33;
            WFX4 BY x41-x43; 
            WFX5 BY x51-x53;   
            
            ! Factor models for Y at 5 waves
            WFY1 BY y11-y13;
            WFY2 BY y21-y23;
            WFY3 BY y31-y33;
            WFY4 BY y41-y43;
            WFY5 BY y51-y53;

            !!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: DYNAMICS !
            !!!!!!!!!!!!!!!!!!!!!!!!!

            ! Specify lagged effects between within-person centered latent variables
            WFX2 WFY2 ON WFX1 WFY1;
            WFX3 WFY3 ON WFX2 WFY2;
            WFX4 WFY4 ON WFX3 WFY3;
            WFX5 WFY5 ON WFX4 WFY4;

            ! Estimate correlations within same wave
            WFX1 WITH WFY1;
            WFX2 WITH WFY2;
            WFX3 WITH WFY3; 
            WFX4 WITH WFY4;
            WFX5 WITH WFY5; 

OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

In the second step, we constrain the factor loadings to be invariant over time using the labels (a b) and (c d). We only need to constrain the second and third loading of the factor models at each wave (i.e., WFX1 BY x12 x13, WFX2 BY x22 x23, etc.), because the first loading (i.e., WFX1 BY x11 and WFX2 BY x21, etc.) is constrained to 1 by default, and is therefore already invariant over time.

TITLE:      Multiple indicator RI-CLPM, 5 waves, with 3 indicators for 
            each variable at each wave (30 observed variables) and with 
            random intercepts for each indicator separately. Fitting a model 
            with constraints to ensure weak factorial invariance. 
  
DATA:       FILE = RICLPM-MI.dat;
            
VARIABLE:   NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33 
                    x41 x42 x43 x51 x52 x53 y11 y12 y13 
                    y21 y22 y23 y31 y32 y33 y41 y42 y43 
                    y51 y52 y53;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero

MODEL:      !!!!!!!!!!!!!!!!    
            ! BETWEEN PART !
            !!!!!!!!!!!!!!!!

            ! Create between factors (random intercepts) for each indicator separately
            RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
            RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
            RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
        
            RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
            RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
            RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;

            ! Add covariances between all RIs
            RIX1-RIY3 WITH RIX1-RIY3;

            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: MEASUREMENT MODEL !
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            ! Due to having a random intercept per indicator, the measurement model 
            ! is only on the within part of the measurements

            ! Factor models for X at 5 waves (constrained)
            WFX1 BY x11-x13 (a b c);
            WFX2 BY x21-x23 (a b c);
            WFX3 BY x31-x33 (a b c);
            WFX4 BY x41-x43 (a b c); 
            WFX5 BY x51-x53 (a b c);   
            
            ! Factor models for Y at 5 waves (constrained)
            WFY1 BY y11-y13 (d e f);
            WFY2 BY y21-y23 (d e f);
            WFY3 BY y31-y33 (d e f);
            WFY4 BY y41-y43 (d e f);
            WFY5 BY y51-y53 (d e f);

            !!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: DYNAMICS !
            !!!!!!!!!!!!!!!!!!!!!!!!!

            ! Specify lagged effects between within-person centered latent variables
            WFX2 WFY2 ON WFX1 WFY1;
            WFX3 WFY3 ON WFX2 WFY2;
            WFX4 WFY4 ON WFX3 WFY3;
            WFX5 WFY5 ON WFX4 WFY4;
  
            ! Estimate correlations within same wave
            WFX1 WITH WFY1;
            WFX2 WITH WFY2;
            WFX3 WITH WFY3; 
            WFX4 WITH WFY4;
            WFX5 WITH WFY5; 
    
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

In Mplus, the model for strong factorial invariance can be specified as the previous model with the following addition [x11 x12 x13] (g h i);[x21 x22 x23] (g h i); ... which ensures that the intercepts of the observed variables are constrained over time, and [WFX2* WFX3* ... ]; which implies that the latent means at each wave can differ from zero.

TITLE:      Multiple indicator RI-CLPM, 5 waves, with 3 indicators for 
            each variable at each wave (30 observed variables) and with 
            random intercepts for each indicator separately. Fitting a model 
              with constraints to ensure strong factorial invariance. 
    
DATA:       FILE = RICLPM-MI.dat;
            
VARIABLE:   NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33 
                    x41 x42 x43 x51 x52 x53 y11 y12 y13 
                    y21 y22 y23 y31 y32 y33 y41 y42 y43 
                    y51 y52 y53;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
    
MODEL:      !!!!!!!!!!!!!!!!    
            ! BETWEEN PART !
            !!!!!!!!!!!!!!!!
    
            ! Create between factors (random intercepts) for each indicator separately
            RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
            RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
            RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
            
            RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
            RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
            RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;
    
            ! Add covariances between all RIs
            RIX1-RIY3 WITH RIX1-RIY3;
 
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: MEASUREMENT MODEL !
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            ! Due to having a random intercept per indicator, the measurement model 
            ! is only on the within part of the measurements

            ! Factor models for X at 5 waves (constrained)
            WFX1 BY x11-x13 (a b c);
            WFX2 BY x21-x23 (a b c);
            WFX3 BY x31-x33 (a b c);
            WFX4 BY x41-x43 (a b c); 
            WFX5 BY x51-x53 (a b c);   
        
            ! Factor models for Y at 5 waves (constrained)
            WFY1 BY y11-y13 (d e f);
            WFY2 BY y21-y23 (d e f);
            WFY3 BY y31-y33 (d e f);
            WFY4 BY y41-y43 (d e f);
            WFY5 BY y51-y53 (d e f);
    
            ! Constrained intercepts over time (necessary for strong factorial 
            ! invariance; without these constraints we have weak factorial invariance)
            [x11 x12 x13] (g h i);
            [x21 x22 x23] (g h i);
            [x31 x32 x33] (g h i);
            [x41 x42 x43] (g h i);
            [x51 x52 x53] (g h i);
                
            [y11 y12 y13] (j k l);
            [y21 y22 y23] (j k l);
            [y31 y32 y33] (j k l);
            [y41 y42 y43] (j k l);
            [y51 y52 y53] (j k l);
        
            ! Free latent means from second wave onward (only do this in combination 
            ! with constraints on intercepts; without these, this is not identified)
            [WFX2* WFX3* WFX4* WFX5*];
            [WFY2* WFY3* WFY4* WFY5*];
    
            !!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: DYNAMICS !
            !!!!!!!!!!!!!!!!!!!!!!!!!
  
            ! Specify lagged effects between within-person centered latent variables
            WFX2 WFY2 ON WFX1 WFY1;
            WFX3 WFY3 ON WFX2 WFY2;
            WFX4 WFY4 ON WFX3 WFY3;
            WFX5 WFY5 ON WFX4 WFY4;

            ! Estimate correlations within same wave
            WFX1 WITH WFY1;
            WFX2 WITH WFY2;
            WFX3 WITH WFY3; 
            WFX4 WITH WFY4;
            WFX5 WITH WFY5; 

OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;
TITLE:      Multiple indicator RI-CLPM, 5 waves with 3 indicators for each 
            variable at each wave (30 observed variables). Fitting a model 
            with constraints to ensure strong factorial invariance, with a
            random intercept for each indicator separately, for which a 
            factor model is specified, with factor loadings equal to the 
            within- person factor loadings. 
    
DATA:       FILE = RICLPM-MI.dat;
                
VARIABLE:   NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33 
                    x41 x42 x43 x51 x52 x53 y11 y12 y13 
                    y21 y22 y23 y31 y32 y33 y41 y42 y43 
                    y51 y52 y53;
  
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
  
MODEL:      !!!!!!!!!!!!!!!!    
            ! BETWEEN PART !
            !!!!!!!!!!!!!!!!

            ! Create between factors (random intercepts) for each indicator separately
            RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
            RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
            RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
            
            RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
            RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
            RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;
    
            ! Create single random intercept for all X-variables, and another for all 
            ! Y-variables. Constrain factor loading to be identical to within-person 
            ! factor loadings
            RIX BY RIX1 RIX2 RIX3 (a b c);
            RIY BY RIY1 RIY2 RIY3 (d e f);
        
            ! Add covariance between 2nd-order random intercepts
            RIX WITH RIY;
        
            ! Constrain measurement error variances of 2nd-order factor model to 0
            RIX1-RIY3@0; 
 
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: MEASUREMENT MODEL !
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  
            ! Due to having a random intercept per indicator, the measurement model 
            ! is only on the within part of the measurements

            ! Factor models for X at 5 waves
            WFX1 BY x11-x13 (a b c);
            WFX2 BY x21-x23 (a b c);
            WFX3 BY x31-x33 (a b c);
            WFX4 BY x41-x43 (a b c); 
            WFX5 BY x51-x53 (a b c);   
        
            ! Factor models for Y at 5 waves
            WFY1 BY y11-y13 (d e f);
            WFY2 BY y21-y23 (d e f);
            WFY3 BY y31-y33 (d e f);
            WFY4 BY y41-y43 (d e f);
            WFY5 BY y51-y53 (d e f);

            ! Constrained intercepts over time (necessary for strong factorial invariance; 
            ! without these we have weak factorial invariance)
            [x11 x12 x13] (g h i);
            [x21 x22 x23] (g h i);
            [x31 x32 x33] (g h i);
            [x41 x42 x43] (g h i);
            [x51 x52 x53] (g h i);
                  
            [y11 y12 y13] (j k l);
            [y21 y22 y23] (j k l);
            [y31 y32 y33] (j k l);
            [y41 y42 y43] (j k l);
            [y51 y52 y53] (j k l);
    
            ! Free latent means from second wave onward (only do this in combination with 
            ! constraints on intercepts; without these, this is not identified)
            [WFX2* WFX3* WFX4* WFX5*];
            [WFY2* WFY3* WFY4* WFY5*];
    
            !!!!!!!!!!!!!!!!!!!!!!!!!
            ! WITHIN PART: DYNAMICS !
            !!!!!!!!!!!!!!!!!!!!!!!!!

            ! Specify lagged effects between within-person centered latent variables
            WFX2 WFY2 ON WFX1 WFY1;
            WFX3 WFY3 ON WFX2 WFY2;
            WFX4 WFY4 ON WFX3 WFY3;
            WFX5 WFY5 ON WFX4 WFY4;

            ! Estimate correlations within same wave
            WFX1 WITH WFY1;
            WFX2 WITH WFY2;
            WFX3 WITH WFY3; 
            WFX4 WITH WFY4;
            WFX5 WITH WFY5; 

OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

We have to overrule the default of Mplus to include a term for measurement error when the BY statement is used, through FX1@0 FX2@0 ...;. The two random intercepts are allowed to be freely correlated with each other, through RIX WITH RIY;.

TITLE:      Multiple indicator RI-CLPM, 5 waves with 3 indicators for each 
            variable at each wave (30 observed variables). Fitting a model 
            with constraints to ensure strong factorial invariance, with 
            the RI-CLPM at the latent level.
    
DATA:       FILE = RICLPM-MI.dat;
            
VARIABLE:   NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33 
                    x41 x42 x43 x51 x52 x53 y11 y12 y13 
                    y21 y22 y23 y31 y32 y33 y41 y42 y43 
                    y51 y52 y53;
    
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
  
MODEL:      !!!!!!!!!!!!!!!!!!!!!
            ! MEASUREMENT MODEL !
            !!!!!!!!!!!!!!!!!!!!!
    
            ! Factor models for X at 5 waves 
            FX1 BY x11-x13 (a b c);
            FX2 BY x21-x23 (a b c);
            FX3 BY x31-x33 (a b c);
            FX4 BY x41-x43 (a b c); 
            FX5 BY x51-x53 (a b c);   
            
            ! Factor models for Y at 5 waves
            FY1 BY y11-y13 (d e f);
            FY2 BY y21-y23 (d e f);
            FY3 BY y31-y33 (d e f);
            FY4 BY y41-y43 (d e f);
            FY5 BY y51-y53 (d e f);
        
            ! Constrained intercepts over time (necessary for strong factorial 
            ! invariance; without these we have weak factorial invariance)
            [x11 x12 x13] (g h i);
            [x21 x22 x23] (g h i);
            [x31 x32 x33] (g h i);
            [x41 x42 x43] (g h i);
            [x51 x52 x53] (g h i);
                    
            [y11 y12 y13] (j k l);
            [y21 y22 y23] (j k l);
            [y31 y32 y33] (j k l);
            [y41 y42 y43] (j k l);
            [y51 y52 y53] (j k l);        
    
            ! Free latent means from 2nd wave onward (only do this in combination with 
            ! constraints on intercepts; without these, this is not identified)
            [FX2* FX3* FX4* FX5*];
            [FY2* FY3* FY4* FY5*];
      
            !!!!!!!!!!!!!!!!    
            ! BETWEEN PART !
            !!!!!!!!!!!!!!!!
    
            ! Create between factors (random intercepts)
            RIX BY FX1@1 FX2@1 FX3@1 FX4@1 FX5@1;
            RIY BY FY1@1 FY2@1 FY3@1 FY4@1 FY5@1;
    
            ! Include covariance between random intercepts
            RIX WITH RIY;
  
            ! Set residual variances of all FX and FY variables to 0 
            FX1-FY5@0;
    
            !!!!!!!!!!!!!!!
            ! WITHIN PART !
            !!!!!!!!!!!!!!!
    
            ! Create within-part
            WFX1 BY FX1@1;
            WFX2 BY FX2@1;
            WFX3 BY FX3@1;
            WFX4 BY FX4@1;
            WFX5 BY FX5@1;
                 
            WFY1 BY FY1@1;
            WFY2 BY FY2@1;
            WFY3 BY FY3@1;
            WFY4 BY FY4@1;
            WFY5 BY FY5@1;
        
            ! Specify lagged effects between within-person centered latent variables
            WFX2 WFY2 ON WFX1 WFY1;
            WFX3 WFY3 ON WFX2 WFY2;
            WFX4 WFY4 ON WFX3 WFY3;
            WFX5 WFY5 ON WFX4 WFY4;
      
            ! Estimate correlations within same wave
            WFX1 WITH WFY1;
            WFX2 WITH WFY2;
            WFX3 WITH WFY3; 
            WFX4 WITH WFY4;
            WFX5 WITH WFY5;

OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

Residual syntax

The basic RI-CLPM model syntax (with and without constraints) can be made considerably simpler by using the ^-notation and PON and PWITH statements (pairwise ON and WITH, respectively):

  • ^-notation: By including a ^ after a variable (e.g., x1^ or y3^) a residual latent variable is automatically created for that variable with the loading parameter fixed to 1. Moreover, this notation fixes the measurement error variance of the observed variable to 0, such that, in an RI-CLPM context, x1^ and y3^ can be interpreted as deviations from a person-specific mean. This notation is available from Mplus version 8.7 onward.
  • PON and PWITH: These statements define pairwise regression and correlational relationships, respectively. For example, the x1^-x5^ PWITH y1^-y5^; statement in the RI-CLPM model syntax below, defines a covariance between the within-components at the first wave, a residual covariance between the within-components at the second wave, a residual covariance between the within-components at the third wave, etc.
TITLE:      The basic RI-CLPM (5 waves), using residual-language of Mplus.
     
DATA:       FILE = RICLPM.dat;
                
VARIABLE:   NAMES = x1-x5 y1-y5;
            
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between-components (random intercepts)
            RIx BY x1-x5@1;
            RIy BY y1-y5@1;
    
            ! Estimate covariance between random intercepts
            RIx WITH RIy;
        
            ! Using residual-language ("^"-notation) Mplus automatically creates 
            ! within-person centered variables with measurement error variances 
            ! constrained at 0

            ! Estimate lagged effects between within-person centered variables using 
            ! "Pairwise ON"-notation.
            x2^-x5^ y2^-y5^ PON x1^-x4^ y1^-y4^; ! Autoregressive effects
            x2^-x5^ y2^-y5^ PON y1^-y4^ x1^-x4^; ! Cross-lagged effects
    
            ! Estimate covariance between within-person components using 
            ! "Pairwise WITH"-notation
            x1^-x5^ PWITH y1^-y5^;
                
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;
TITLE:      The basic RI-CLPM (5 waves), using residual-language of Mplus.
            Constrain the grand means, (residual) variances, and lagged effects 
            over time.   
       
DATA:       FILE = RICLPM.dat;
                    
VARIABLE:   NAMES = x1-x5 y1-y5;
            
ANALYSIS:   MODEL = NOCOV; ! Sets all default covariances to zero
        
MODEL:      ! Create between-components (random intercepts)
            RIx BY x1-x5@1;
            RIy BY y1-y5@1;
    
            ! Estimate covariance between the random intercepts
            RIx WITH RIy;
        
            ! Estimate lagged effects between within-person centered variables using
            ! "pairwise ON"-notation.
            x2^-x5^ PON x1^-x4^ (a); ! Autoregressive effects (contrained)
            y2^-y5^ PON y1^-y4^ (b); 
            x2^-x5^ PON y1^-y4^ (c); ! Cross-lagged effects (constrained)
            y2^-y5^ PON x1^-x4^ (d);
      
            ! Estimate (residual) (co)variance between within-person components using 
            ! "pairwise WITH"-notation
            x1^ WITH y1^; ! Covariance
            x2^-x5^ PWITH y2^-y5^ (cov); ! Residual covariances
            x2^-x5^ (vx); ! Residual variance x^
            y2^-y5^ (vy); ! Residual variance y^

            ! Constrain grand means to be invariant over time
            [x1 x2 x3 x4 x5] (mx);
            [y1 y2 y3 y4 y5] (my);
                
OUTPUT:     TECH1 STDYX SAMPSTAT CINTERVAL;

References

Asparouhov, Tihomir, and Bengt O. Muthén. 2021. Residual structural equation models.”
Meredith, William. 1993. Measurement invariance, factor analysis and factorial invariance.” Psychometrika. https://doi.org/10.1007/BF02294825.
Muthén, L. K., and B. O. Muthén. 2017. Mplus User’s Guide. Eighth Edition. Los Angeles, CA: Muthén & Muthén.