Lavaan MPLUS Reference Sheet

A growth curve model written in lavaan and MPLUS as a syntax reference guide. Imagine a latent growth curve on affect across 4 time points. First, lavaan code:

lavaan_string <- '

# Latent intercept and slope factors

intercept_affect =~ 1*affect.1 + 1*affect.2 + 1*affect.3 + 1*affect.4
slope_affect =~ 0*affect.1 + 1*affect.2 + 2*affect.3 + 3*affect.4

# Mean and variance of latent factors

intercept_affect ~~ intercept_affect
slope_affect ~~ slope_affect

# Covariance between latent factors

intercept_affect ~~ slope_affect

# Fix observed variable means to 0

affect.1 ~ 0
affect.2 ~ 0
affect.3 ~ 0
affect.4 ~ 0

# Constrain residual (error) variance of observed variables to equality across time

affect.1 ~~ res_var*affect.1
affect.2 ~~ res_var*affect.2
affect.3 ~~ res_var*affect.3
affect.4 ~~ res_var*affect.4


'

Now the same thing in MPLUS syntax:

mplus_string <- '

        ! Latent intercept and slope factors
        intercept_affect BY affect.1@1 affect.2@1 affect.3@1 affect.4@1;
        slope_affect BY affect.1@0 affect.2@1 affect.3@3 affect.4@5;

        ! estimate mean of latent intercept
        [intercept_affect];

        ! estimate mean of latent slope
        [slope_affect]

        ! estimate variance of intercept
        intercept_affect;

        ! estimate variance of slope
        slope_affect;

        ! covariance between intercept and slope
        intercept_affect WITH slope_affect;

        ! Fix observed variable means to 0 so we can estimate a mean for the latent variable
        [affect.1@0 affect.2@0 affect.3@0 affect.4@0];

        ! constrain estimates of residual variances to be equivalent at each time point
        affect.1(res_var); affect.2(res_var); affect.3(res_var); affect.4(res_var);



'

Bo\(^2\)m =)