9 Longitudinal Multirater Data
MPlus data file (chapter_9_str)
MPlus data file (chapter_9_com)
R data file (chapter_9_com_na)
Models of Section 9.2.3
Multistate model for loneliness measured by parent report wih configural measurement invariance, no indicator-specific factors
R Code
MSlopar <- '
# latent state-rater factors
SR1 =~ Plon12 + Plon22 + Plon32
SR2 =~ Plon14 + Plon24 + Plon34
'
fit <- sem(model=MSlopar, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model for loneliness measured by self-report wih configural measurement invariance, no indicator-specific factors
R Code
MSlosel <- '
# latent state-rater factors
SR1 =~ Slon12 + Slon22 + Slon32
SR2 =~ Slon14 + Slon24 + Slon34
'
fit <- sem(model=MSlosel, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness parent report wih configural measurement invariance
R Code
MSloparis <- '
# latent state-rater factors
SR1 =~ Plon12 + Plon22 + Plon32
SR2 =~ Plon14 + Plon24 + Plon34
# indicator-specific factors
I2 =~ 1*Plon22 + 1*Plon24
I3 =~ 1*Plon32 + 1*Plon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
'
fit <- sem(model=MSloparis, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness self-report wih configural measurement invariance
R Code
MSloselis <- '
# latent state-rater factors
SR1 =~ Slon12 + Slon22 + Slon32
SR2 =~ Slon14 + Slon24 + Slon34
# indicator-specific factors
I2 =~ 1*Slon22 + 1*Slon24
I3 =~ 1*Slon32 + 1*Slon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
'
fit <- sem(model=MSloselis, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness parent report wih weak measurement invariance (equal loadings)
R Code
MSloparisw <- '
# latent state-rater factors
SR1 =~ Plon12 + l2*Plon22 + l3*Plon32
SR2 =~ Plon14 + l2*Plon24 + l3*Plon34
# Indicator-specific factors
I2 =~ 1*Plon22 + 1*Plon24
I3 =~ 1*Plon32 + 1*Plon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
'
fit <- sem(model=MSloparisw, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness self-report wih weak measurement invariance (equal loadings)
R Code
MSloselisw <- '
# latent state-rater factors
SR1 =~ Slon12 + l2*Slon22 + l3*Slon32
SR2 =~ Slon14 + l2*Slon24 + l3*Slon34
# Indicator-specific factors
I2 =~ 1*Slon22 + 1*Slon24
I3 =~ 1*Slon32 + 1*Slon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
'
fit <- sem(model=MSloselisw, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness parent report with strong measurement invariance (equal loadings and equal intercepts)
R Code
MSlopariss <- '
# latent state-rater factors
SR1 =~ Plon12 + l2*Plon22 + l3*Plon32
SR2 =~ Plon14 + l2*Plon24 + l3*Plon34
# Intercepts set equal across time
Plon12 ~ a1*1
Plon14 ~ a1*1
Plon22 ~ a2*1
Plon24 ~ a2*1
Plon32 ~ a3*1
Plon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR1 ~ 0*1
SR2 ~ 1
# Indicator-specific factors
I2 =~ 1*Plon22 + 1*Plon24
I3 =~ 1*Plon32 + 1*Plon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
'
fit <- sem(model=MSlopariss, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness self-report with strong measurement invariance (equal loadings and equal intercepts)
R Code
MSloseliss <- '
# latent state-rater factors
SR1 =~ Slon12 + l2*Slon22 + l3*Slon32
SR2 =~ Slon14 + l2*Slon24 + l3*Slon34
# Intercepts set equal across time
Slon12 ~ a1*1
Slon14 ~ a1*1
Slon22 ~ a2*1
Slon24 ~ a2*1
Slon32 ~ a3*1
Slon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR1 ~ 0*1
SR2 ~ 1
# Indicator-specific factors
I2 =~ 1*Slon22 + 1*Slon24
I3 =~ 1*Slon32 + 1*Slon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
'
fit <- sem(model=MSloseliss, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness parent report with strict measurement invariance (equal loadings, intercepts, and error variances)
R Code
MSloparisstric <- '
# latent state-rater factors
SR1 =~ Plon12 + l2*Plon22 + l3*Plon32
SR2 =~ Plon14 + l2*Plon24 + l3*Plon34
# Intercepts set equal across time
Plon12 ~ a1*1
Plon14 ~ a1*1
Plon22 ~ a2*1
Plon24 ~ a2*1
Plon32 ~ a3*1
Plon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR1 ~ 0*1
SR2 ~ 1
# Indicator-specific factors
I2 =~ 1*Plon22 + 1*Plon24
I3 =~ 1*Plon32 + 1*Plon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
# Error variances set equal across time
Plon12 ~~ e1*Plon12
Plon14 ~~ e1*Plon14
Plon22 ~~ e2*Plon22
Plon24 ~~ e2*Plon24
Plon32 ~~ e3*Plon32
Plon34 ~~ e3*Plon34
'
fit <- sem(model=MSloparisstric, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness self-report with strict measurement invariance (equal loadings, intercepts, and error variances)
R Code
MSloselisstric <- '
# latent state-rater factors
# latent state-rater factors
SR1 =~ Slon12 + l2*Slon22 + l3*Slon32
SR2 =~ Slon14 + l2*Slon24 + l3*Slon34
# Intercepts set equal across time
Slon12 ~ a1*1
Slon14 ~ a1*1
Slon22 ~ a2*1
Slon24 ~ a2*1
Slon32 ~ a3*1
Slon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR1 ~ 0*1
SR2 ~ 1
# Indicator-specific factors
I2 =~ 1*Slon22 + 1*Slon24
I3 =~ 1*Slon32 + 1*Slon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
# Error variances set equal across time
Slon12 ~~ e1*Slon12
Slon14 ~~ e1*Slon14
Slon22 ~~ e2*Slon22
Slon24 ~~ e2*Slon24
Slon32 ~~ e3*Slon32
Slon34 ~~ e3*Slon34
'
fit <- sem(model=MSloselisstric, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness parent report with strict measurement invariance (equal loadings, intercepts, and error variances) and equal latent state factor variances
R Code
MSloparisstricv <- '
# latent state-rater factors
SR1 =~ Plon12 + l2*Plon22 + l3*Plon32
SR2 =~ Plon14 + l2*Plon24 + l3*Plon34
# Intercepts set equal across time
Plon12 ~ a1*1
Plon14 ~ a1*1
Plon22 ~ a2*1
Plon24 ~ a2*1
Plon32 ~ a3*1
Plon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR1 ~ 0*1
SR2 ~ 1
# Indicator-specific factors
I2 =~ 1*Plon22 + 1*Plon24
I3 =~ 1*Plon32 + 1*Plon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
# Error variances set equal across time
Plon12 ~~ e1*Plon12
Plon14 ~~ e1*Plon14
Plon22 ~~ e2*Plon22
Plon24 ~~ e2*Plon24
Plon32 ~~ e3*Plon32
Plon34 ~~ e3*Plon34
# Set state-rater factor variances equal across time
SR1 ~~ SRVAR*SR1
SR2 ~~ SRVAR*SR2
'
fit <- sem(model=MSloparisstricv, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Multistate model with indicator-specific factors for loneliness self-report with strict measurement invariance (equal loadings, intercepts, and error variances) and equal latent state factor variances
R Code
MSloselisstricv <- '
# latent state-rater factors
# latent state-rater factors
SR1 =~ Slon12 + l2*Slon22 + l3*Slon32
SR2 =~ Slon14 + l2*Slon24 + l3*Slon34
# Intercepts set equal across time
Slon12 ~ a1*1
Slon14 ~ a1*1
Slon22 ~ a2*1
Slon24 ~ a2*1
Slon32 ~ a3*1
Slon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR1 ~ 0*1
SR2 ~ 1
# Indicator-specific factors
I2 =~ 1*Slon22 + 1*Slon24
I3 =~ 1*Slon32 + 1*Slon34
SR1 ~~ 0*I2 + 0*I3
SR2 ~~ 0*I2 + 0*I3
# Error variances set equal across time
Slon12 ~~ e1*Slon12
Slon14 ~~ e1*Slon14
Slon22 ~~ e2*Slon22
Slon24 ~~ e2*Slon24
Slon32 ~~ e3*Slon32
Slon34 ~~ e3*Slon34
# Set state-rater factor variances equal across time
SR1 ~~ SRVAR*SR1
SR2 ~~ SRVAR*SR2
'
fit <- sem(model=MSloselisstricv, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Combined multistate-multirater model parent & self report loneliness with strict measurement invariance (equal loadings, intercepts, and error variances) and equal state-rater factor variances across time
R Code
MSMRlosev <- '
# SELF REPORT (Method 1)
# latent state-rater factors
SR11 =~ Slon12 + l21*Slon22 + l31*Slon32
SR21 =~ Slon14 + l21*Slon24 + l31*Slon34
# Intercepts set equal across time
Slon12 ~ a11*1
Slon14 ~ a11*1
Slon22 ~ a21*1
Slon24 ~ a21*1
Slon32 ~ a31*1
Slon34 ~ a31*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR11 ~ 0*1
SR21 ~ 1
# Indicator-specific factors
I21 =~ 1*Slon22 + 1*Slon24
I31 =~ 1*Slon32 + 1*Slon34
SR11 ~~ 0*I21 + 0*I31
SR21 ~~ 0*I21 + 0*I31
# set error variances equal across time
Slon12 ~~ e11*Slon12
Slon14 ~~ e11*Slon14
Slon22 ~~ e21*Slon22
Slon24 ~~ e21*Slon24
Slon32 ~~ e31*Slon32
Slon34 ~~ e31*Slon34
# Set state factor variances equal across time
SR11 ~~ SRVAR1*SR11
SR21 ~~ SRVAR1*SR21
# PARENT REPORT (Method 2)
# latent state-rater factors
SR12 =~ Plon12 + l22*Plon22 + l32*Plon32
SR22 =~ Plon14 + l22*Plon24 + l32*Plon34
# Intercepts set equal across time
Plon12 ~ a12*1
Plon14 ~ a12*1
Plon22 ~ a22*1
Plon24 ~ a22*1
Plon32 ~ a32*1
Plon34 ~ a32*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR12 ~ 0*1
SR22 ~ 1
# Indicator-specific factors
I22 =~ 1*Plon22 + 1*Plon24
I32 =~ 1*Plon32 + 1*Plon34
SR12 ~~ 0*I22 + 0*I32
SR22 ~~ 0*I22 + 0*I32
# Error variances set equal across time
Plon12 ~~ e12*Plon12
Plon14 ~~ e12*Plon14
Plon22 ~~ e22*Plon22
Plon24 ~~ e22*Plon24
Plon32 ~~ e32*Plon32
Plon34 ~~ e32*Plon34
# Set state-rater factor variances equal across time
SR12 ~~ SRVAR2*SR12
SR22 ~~ SRVAR2*SR22
'
fit <- sem(model=MSMRlosev, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Combined multistate-multirater model parent & self report loneliness with strict measurement invariance (equal loadings, intercepts, and error variances) and equal state-rater factor variances across time and weak MI across rater groups
R Code
MSMRlosevs <- '
# SELF REPORT (Method 1)
# latent state-rater factors
SR11 =~ Slon12 + l2*Slon22 + l3*Slon32
SR21 =~ Slon14 + l2*Slon24 + l3*Slon34
# Intercepts set equal across time
Slon12 ~ a1*1
Slon14 ~ a1*1
Slon22 ~ a2*1
Slon24 ~ a2*1
Slon32 ~ a3*1
Slon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR11 ~ 0*1
SR21 ~ 1
# Indicator-specific factors
I21 =~ 1*Slon22 + 1*Slon24
I31 =~ 1*Slon32 + 1*Slon34
SR11 ~~ 0*I21 + 0*I31
SR21 ~~ 0*I21 + 0*I31
# set error variances equal across time
Slon12 ~~ e11*Slon12
Slon14 ~~ e11*Slon14
Slon22 ~~ e21*Slon22
Slon24 ~~ e21*Slon24
Slon32 ~~ e31*Slon32
Slon34 ~~ e31*Slon34
# Set state factor variances equal across time
SR11 ~~ SRVAR1*SR11
SR21 ~~ SRVAR1*SR21
# PARENT REPORT (Method 2)
# latent state-rater factors
SR12 =~ Plon12 + l2*Plon22 + l3*Plon32
SR22 =~ Plon14 + l2*Plon24 + l3*Plon34
# Intercepts set equal across time
Plon12 ~ a1*1
Plon14 ~ a1*1
Plon22 ~ a2*1
Plon24 ~ a2*1
Plon32 ~ a3*1
Plon34 ~ a3*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR12 ~ 0*1
SR22 ~ 1
# Indicator-specific factors
I22 =~ 1*Plon22 + 1*Plon24
I32 =~ 1*Plon32 + 1*Plon34
SR12 ~~ 0*I22 + 0*I32
SR22 ~~ 0*I22 + 0*I32
# Error variances set equal across time
Plon12 ~~ e12*Plon12
Plon14 ~~ e12*Plon14
Plon22 ~~ e22*Plon22
Plon24 ~~ e22*Plon24
Plon32 ~~ e32*Plon32
Plon34 ~~ e32*Plon34
# Set state-rater factor variances equal across time
SR12 ~~ SRVAR2*SR12
SR22 ~~ SRVAR2*SR22
'
fit <- sem(model=MSMRlosevs, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Combined MSMR models for loneliness and flourishing (2 traits) and measured by self- and parent report (2 methods/rater groups). The MSMR model assumes strict MI (equal loadings, intercepts, and error variances) across time and weak MI across rater groups and equal state-rater factor variances across time
R Code
MSMR1 <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1)
# latent state-rater factors
SR111 =~ Slon12 + l21*Slon22 + l31*Slon32
SR112 =~ Slon14 + l21*Slon24 + l31*Slon34
# Intercepts set equal across time
Slon12 ~ a111*1
Slon14 ~ a111*1
Slon22 ~ a211*1
Slon24 ~ a211*1
Slon32 ~ a311*1
Slon34 ~ a311*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR111 ~ 0*1
SR112 ~ 1
# Indicator-specific factors
I211 =~ 1*Slon22 + 1*Slon24
I311 =~ 1*Slon32 + 1*Slon34
SR111 ~~ 0*I211 + 0*I311
SR112 ~~ 0*I211 + 0*I311
# set error variances equal across time
Slon12 ~~ e111*Slon12
Slon14 ~~ e111*Slon14
Slon22 ~~ e211*Slon22
Slon24 ~~ e211*Slon24
Slon32 ~~ e311*Slon32
Slon34 ~~ e311*Slon34
# Set state factor variances equal across time
SR111 ~~ SRVAR11*SR111
SR112 ~~ SRVAR11*SR112
# PARENT REPORT (Method 2)
# latent state-rater factors
SR121 =~ Plon12 + l21*Plon22 + l31*Plon32
SR122 =~ Plon14 + l21*Plon24 + l31*Plon34
# Intercepts set equal across time
Plon12 ~ a112*1
Plon14 ~ a112*1
Plon22 ~ a212*1
Plon24 ~ a212*1
Plon32 ~ a312*1
Plon34 ~ a312*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR121 ~ 0*1
SR122 ~ 1
# Indicator-specific factors
I212 =~ 1*Plon22 + 1*Plon24
I312 =~ 1*Plon32 + 1*Plon34
SR121 ~~ 0*I212 + 0*I312
SR122 ~~ 0*I212 + 0*I312
# Error variances set equal across time
Plon12 ~~ e122*Plon12
Plon14 ~~ e122*Plon14
Plon22 ~~ e222*Plon22
Plon24 ~~ e222*Plon24
Plon32 ~~ e322*Plon32
Plon34 ~~ e322*Plon34
# Set state-rater factor variances equal across time
SR121 ~~ SRVAR12*SR121
SR122 ~~ SRVAR12*SR122
# FLOURISHING (Construct 2)
# SELF-REPORT (Method 1)
# latent state-rater factors
SR211 =~ SFlou12 + l22*SFlou22
SR212 =~ SFlou14 + l22*SFlou24
# Intercepts set equal across time
SFlou12 ~ a121*1
SFlou14 ~ a121*1
SFlou22 ~ a221*1
SFlou24 ~ a221*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR211 ~ 0*1
SR212 ~ 1
# Indicator-specific factor
I221 =~ 1*SFlou22 + 1*SFlou24
SR211 ~~ 0*I221
SR212 ~~ 0*I221
# set error variances equal across time
SFlou12 ~~ e112*SFlou12
SFlou14 ~~ e112*SFlou14
SFlou22 ~~ e212*SFlou22
SFlou24 ~~ e212*SFlou24
# Set state factor variances equal across time
SR211 ~~ SRVAR21*SR211
SR212 ~~ SRVAR21*SR212
# PARENT REPORT (Method 2)
# latent state-rater factors
SR221 =~ PFlou12 + l22*PFlou22
SR222 =~ PFlou14 + l22*PFlou24
# Intercepts set equal across time
PFlou12 ~ a122*1
PFlou14 ~ a122*1
PFlou22 ~ a222*1
PFlou24 ~ a222*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR221 ~ 0*1
SR222 ~ 1
# Indicator-specific factor
I222 =~ 1*PFlou22 + 1*PFlou24
SR221 ~~ 0*I222
SR222 ~~ 0*I222
# Error variances set equal across time
PFlou12 ~~ e122*PFlou12
PFlou14 ~~ e122*PFlou14
PFlou22 ~~ e222*PFlou22
PFlou24 ~~ e222*PFlou24
# Set state-rater factor variances equal across time
SR221 ~~ SRVAR22*SR221
SR222 ~~ SRVAR22*SR222
'
fit <- sem(model=MSMR1, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Combined MSMR models for loneliness and flourishing (2 traits) and measured by self- and parent report (2 methods/rater groups). The MSMR model assumes strict MI (equal loadings, intercepts, and error variances) across time and weak MI across rater groups and equal state-rater factor variances across time and equal convergent validity covariances/correlations across time
R Code
MSMR2 <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1)
# latent state-rater factors
SR111 =~ Slon12 + l21*Slon22 + l31*Slon32
SR112 =~ Slon14 + l21*Slon24 + l31*Slon34
# Intercepts set equal across time
Slon12 ~ a111*1
Slon14 ~ a111*1
Slon22 ~ a211*1
Slon24 ~ a211*1
Slon32 ~ a311*1
Slon34 ~ a311*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR111 ~ 0*1
SR112 ~ 1
# Indicator-specific factors
I211 =~ 1*Slon22 + 1*Slon24
I311 =~ 1*Slon32 + 1*Slon34
SR111 ~~ 0*I211 + 0*I311
SR112 ~~ 0*I211 + 0*I311
# set error variances equal across time
Slon12 ~~ e111*Slon12
Slon14 ~~ e111*Slon14
Slon22 ~~ e211*Slon22
Slon24 ~~ e211*Slon24
Slon32 ~~ e311*Slon32
Slon34 ~~ e311*Slon34
# Set state factor variances equal across time
SR111 ~~ SRVAR11*SR111
SR112 ~~ SRVAR11*SR112
# PARENT REPORT (Method 2)
# latent state-rater factors
SR121 =~ Plon12 + l21*Plon22 + l31*Plon32
SR122 =~ Plon14 + l21*Plon24 + l31*Plon34
# Intercepts set equal across time
Plon12 ~ a112*1
Plon14 ~ a112*1
Plon22 ~ a212*1
Plon24 ~ a212*1
Plon32 ~ a312*1
Plon34 ~ a312*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR121 ~ 0*1
SR122 ~ 1
# Indicator-specific factors
I212 =~ 1*Plon22 + 1*Plon24
I312 =~ 1*Plon32 + 1*Plon34
SR121 ~~ 0*I212 + 0*I312
SR122 ~~ 0*I212 + 0*I312
# Error variances set equal across time
Plon12 ~~ e122*Plon12
Plon14 ~~ e122*Plon14
Plon22 ~~ e222*Plon22
Plon24 ~~ e222*Plon24
Plon32 ~~ e322*Plon32
Plon34 ~~ e322*Plon34
# Set state-rater factor variances equal across time
SR121 ~~ SRVAR12*SR121
SR122 ~~ SRVAR12*SR122
# FLOURISHING (Construct 2)
# SELF-REPORT (Method 1)
# latent state-rater factors
SR211 =~ SFlou12 + l22*SFlou22
SR212 =~ SFlou14 + l22*SFlou24
# Intercepts set equal across time
SFlou12 ~ a121*1
SFlou14 ~ a121*1
SFlou22 ~ a221*1
SFlou24 ~ a221*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR211 ~ 0*1
SR212 ~ 1
# Indicator-specific factor
I221 =~ 1*SFlou22 + 1*SFlou24
SR211 ~~ 0*I221
SR212 ~~ 0*I221
# set error variances equal across time
SFlou12 ~~ e112*SFlou12
SFlou14 ~~ e112*SFlou14
SFlou22 ~~ e212*SFlou22
SFlou24 ~~ e212*SFlou24
# Set state factor variances equal across time
SR211 ~~ SRVAR21*SR211
SR212 ~~ SRVAR21*SR212
# PARENT REPORT (Method 2)
# latent state-rater factors
SR221 =~ PFlou12 + l22*PFlou22
SR222 =~ PFlou14 + l22*PFlou24
# Intercepts set equal across time
PFlou12 ~ a122*1
PFlou14 ~ a122*1
PFlou22 ~ a222*1
PFlou24 ~ a222*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR221 ~ 0*1
SR222 ~ 1
# Indicator-specific factor
I222 =~ 1*PFlou22 + 1*PFlou24
SR221 ~~ 0*I222
SR222 ~~ 0*I222
# Error variances set equal across time
PFlou12 ~~ e122*PFlou12
PFlou14 ~~ e122*PFlou14
PFlou22 ~~ e222*PFlou22
PFlou24 ~~ e222*PFlou24
# Set state-rater factor variances equal across time
SR221 ~~ SRVAR22*SR221
SR222 ~~ SRVAR22*SR222
# Set convergent validity covariances equal across time
SR111 ~~ cov1*SR121
SR112 ~~ cov1*SR122
SR211 ~~ cov2*SR221
SR212 ~~ cov2*SR222
'
fit <- sem(model=MSMR2, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Combined MSMR models for loneliness and flourishing (2 traits) and measured by self- and parent report (2 methods/rater groups) The MSMR model assumes strict MI (equal loadings, intercepts, and error variances) across time and weak MI across rater groups and equal state-rater factor variances across time and equal convergent and discriminant validity covariances/correlations across time
R Code
MSMR3 <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1)
# latent state-rater factors
SR111 =~ Slon12 + l21*Slon22 + l31*Slon32
SR112 =~ Slon14 + l21*Slon24 + l31*Slon34
# Intercepts set equal across time
Slon12 ~ a111*1
Slon14 ~ a111*1
Slon22 ~ a211*1
Slon24 ~ a211*1
Slon32 ~ a311*1
Slon34 ~ a311*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR111 ~ 0*1
SR112 ~ 1
# Indicator-specific factors
I211 =~ 1*Slon22 + 1*Slon24
I311 =~ 1*Slon32 + 1*Slon34
SR111 ~~ 0*I211 + 0*I311
SR112 ~~ 0*I211 + 0*I311
# set error variances equal across time
Slon12 ~~ e111*Slon12
Slon14 ~~ e111*Slon14
Slon22 ~~ e211*Slon22
Slon24 ~~ e211*Slon24
Slon32 ~~ e311*Slon32
Slon34 ~~ e311*Slon34
# Set state factor variances equal across time
SR111 ~~ SRVAR11*SR111
SR112 ~~ SRVAR11*SR112
# PARENT REPORT (Method 2)
# latent state-rater factors
SR121 =~ Plon12 + l21*Plon22 + l31*Plon32
SR122 =~ Plon14 + l21*Plon24 + l31*Plon34
# Intercepts set equal across time
Plon12 ~ a112*1
Plon14 ~ a112*1
Plon22 ~ a212*1
Plon24 ~ a212*1
Plon32 ~ a312*1
Plon34 ~ a312*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR121 ~ 0*1
SR122 ~ 1
# Indicator-specific factors
I212 =~ 1*Plon22 + 1*Plon24
I312 =~ 1*Plon32 + 1*Plon34
SR121 ~~ 0*I212 + 0*I312
SR122 ~~ 0*I212 + 0*I312
# Error variances set equal across time
Plon12 ~~ e122*Plon12
Plon14 ~~ e122*Plon14
Plon22 ~~ e222*Plon22
Plon24 ~~ e222*Plon24
Plon32 ~~ e322*Plon32
Plon34 ~~ e322*Plon34
# Set state-rater factor variances equal across time
SR121 ~~ SRVAR12*SR121
SR122 ~~ SRVAR12*SR122
# FLOURISHING (Construct 2)
# SELF-REPORT (Method 1)
# latent state-rater factors
SR211 =~ SFlou12 + l22*SFlou22
SR212 =~ SFlou14 + l22*SFlou24
# Intercepts set equal across time
SFlou12 ~ a121*1
SFlou14 ~ a121*1
SFlou22 ~ a221*1
SFlou24 ~ a221*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR211 ~ 0*1
SR212 ~ 1
# Indicator-specific factor
I221 =~ 1*SFlou22 + 1*SFlou24
SR211 ~~ 0*I221
SR212 ~~ 0*I221
# set error variances equal across time
SFlou12 ~~ e112*SFlou12
SFlou14 ~~ e112*SFlou14
SFlou22 ~~ e212*SFlou22
SFlou24 ~~ e212*SFlou24
# Set state factor variances equal across time
SR211 ~~ SRVAR21*SR211
SR212 ~~ SRVAR21*SR212
# PARENT REPORT (Method 2)
# latent state-rater factors
SR221 =~ PFlou12 + l22*PFlou22
SR222 =~ PFlou14 + l22*PFlou24
# Intercepts set equal across time
PFlou12 ~ a122*1
PFlou14 ~ a122*1
PFlou22 ~ a222*1
PFlou24 ~ a222*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR221 ~ 0*1
SR222 ~ 1
# Indicator-specific factor
I222 =~ 1*PFlou22 + 1*PFlou24
SR221 ~~ 0*I222
SR222 ~~ 0*I222
# Error variances set equal across time
PFlou12 ~~ e122*PFlou12
PFlou14 ~~ e122*PFlou14
PFlou22 ~~ e222*PFlou22
PFlou24 ~~ e222*PFlou24
# Set state-rater factor variances equal across time
SR221 ~~ SRVAR22*SR221
SR222 ~~ SRVAR22*SR222
# Set convergent validity covariances equal across time
SR111 ~~ cov1*SR121
SR112 ~~ cov1*SR122
SR211 ~~ cov2*SR221
SR212 ~~ cov2*SR222
# Set discriminant validity coefficients equal across time
SR111 ~~ cov3*SR211
SR112 ~~ cov3*SR212
SR121 ~~ cov4*SR221
SR122 ~~ cov4*SR222
'
fit <- sem(model=MSMR3, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Models of Section 9.3.1
CSC(M - 1) state model for loneliness and flourishing measured by self- and parent report
R Code
CSCM1S <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1, Reference Method)
# latent state-rater factors, equal loadings across time
SR111 =~ Slon12 + ls21*Slon22 + ls31*Slon32 + lp11*Plon12 + lp21*Plon22 + lp31*Plon32
SR112 =~ Slon14 + ls21*Slon24 + ls31*Slon34 + lp11*Plon14 + lp21*Plon24 + lp31*Plon34
# Intercepts set equal across time for reference method
Slon12 ~ a111*1
Slon14 ~ a111*1
Slon22 ~ a211*1
Slon24 ~ a211*1
Slon32 ~ a311*1
Slon34 ~ a311*1
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR111 ~ 0*1
SR112 ~ 1
# Indicator-specific factors for reference method
I211 =~ 1*Slon22 + 1*Slon24
I311 =~ 1*Slon32 + 1*Slon34
# set error variances equal across time
Slon12 ~~ e111*Slon12
Slon14 ~~ e111*Slon14
Slon22 ~~ e211*Slon22
Slon24 ~~ e211*Slon24
Slon32 ~~ e311*Slon32
Slon34 ~~ e311*Slon34
# Set state factor variances equal across time
SR111 ~~ SRVAR11*SR111
SR112 ~~ SRVAR11*SR112
# PARENT REPORT (Method 2, Non-Reference Method)
# latent rater (method) factors, equal loadings across time
R121 =~ Plon12 + lr21*Plon22 + lr31*Plon32
R122 =~ Plon14 + lr21*Plon24 + lr31*Plon34
# Intercepts set equal across time
# [Plon12 Plon14] (a112)
# [Plon22 Plon24] (a212)
# [Plon32 Plon34] (a312)
# Indicator-specific factors for parent indicators
I212 =~ 1*Plon22 + 1*Plon24
I312 =~ 1*Plon32 + 1*Plon34
# Unwanted correlations set to zero
SR111 ~~ 0*R121 + 0*R122 + 0*I211 + 0*I311 + 0*I212 + 0*I312
SR112 ~~ 0*R121 + 0*R122 + 0*I211 + 0*I311 + 0*I212 + 0*I312
R121 ~~ 0*I211 + 0*I311 + 0*I212 + 0*I312
R122 ~~ 0*I211 + 0*I311 + 0*I212 + 0*I312
# Error variances set equal across time
Plon12 ~~ e122*Plon12
Plon14 ~~ e122*Plon14
Plon22 ~~ e222*Plon22
Plon24 ~~ e222*Plon24
Plon32 ~~ e322*Plon32
Plon34 ~~ e322*Plon34
# Set method factor variances equal across time
R121 ~~ RVAR12*R121
R122 ~~ RVAR12*R122
# FLOURISHING (Construct 2)
# SELF-REPORT (Method 1, Reference Method)
# latent state-rater factors, equal loadings across time
SR211 =~ SFlou12 + ls22*SFlou22 + lp12*PFlou12 + lp22*PFlou22
SR212 =~ SFlou14 + ls22*SFlou24 + lp12*PFlou14 + lp22*PFlou24
# Intercepts set equal across time
# [SFlou12 SFlou14] (a121)
# [SFlou22 SFlou24] (a221)
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR211 ~ 0*1
SR212 ~ 1
# Indicator-specific factor
I221 =~ 1*SFlou22 + 1*SFlou24
# set error variances equal across time
SFlou12 ~~ e112*SFlou12
SFlou14 ~~ e112*SFlou14
SFlou22 ~~ e212*SFlou22
SFlou24 ~~ e212*SFlou24
# Set state factor variances equal across time
SR211 ~~ SRVAR21*SR211
SR212 ~~ SRVAR21*SR212
# PARENT REPORT (Method 2, Non-Reference Method)
# latent rater (method) factors, equal loadings across time
R221 =~ PFlou12 + lr22*PFlou22
R222 =~ PFlou14 + lr22*PFlou24
# Intercepts set equal across time
PFlou12 ~ a122*1
PFlou14 ~ a122*1
PFlou22 ~ a222*1
PFlou24 ~ a222*1
# Indicator-specific factor
I222 =~ 1*PFlou22 + 1*PFlou24
# Unwanted correlations
SR211 ~~ 0*R221 + 0*R222 + 0*I221 + 0*I222
SR212 ~~ 0*R221 + 0*R222 + 0*I221 + 0*I222
R221 ~~ 0*I221 + 0*I222
R222 ~~ 0*I221 + 0*I222
# Error variances set equal across time
PFlou12 ~~ e122*PFlou12
PFlou14 ~~ e122*PFlou14
PFlou22 ~~ e222*PFlou22
PFlou24 ~~ e222*PFlou24
# Set rater factor variances equal across time
R221 ~~ RVAR22*R221
R222 ~~ RVAR22*R222
'
fit <- sem(model=CSCM1S, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Models of Section 9.4.1
CSC(M - 1) change model for loneliness and flourishing measured by self- and parent report
R Code
CSCM1C <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1, Reference Method)
# latent state-rater factors, equal loadings across time
SR111 =~ Slon12 + ls21*Slon22 + ls31*Slon32 + lp11*Plon12 + lp21*Plon22 + lp31*Plon32
SR112 =~ Slon14 + ls21*Slon24 + ls31*Slon34 + lp11*Plon14 + lp21*Plon24 + lp31*Plon34
# Latent state change factor Time 2 - Time 1
ChLon =~ 0*Slon12
# Time 2 state factor equals 1*State 1 + 1*Change
SR112 ~ 1*SR111 + 1*ChLon
# Set State-2 residual variance to zero
SR112 ~~ 0*SR112
# Intercepts set equal across time for reference method
Slon12 ~ a111*1
Slon14 ~ a111*1
Slon22 ~ a211*1
Slon24 ~ a211*1
Slon32 ~ a311*1
Slon34 ~ a311*1
# Time-1 and Time-2 state-rater factor means fixed to zero
# Change factor mean freely estimated to assess mean change
SR111 ~ 0*1
SR112 ~ 0*1
ChLon ~ 1
# Indicator-specific factors for reference method
I211 =~ 1*Slon22 + 1*Slon24
I311 =~ 1*Slon32 + 1*Slon34
# set error variances equal across time
Slon12 ~~ e111*Slon12
Slon14 ~~ e111*Slon14
Slon22 ~~ e211*Slon22
Slon24 ~~ e211*Slon24
Slon32 ~~ e311*Slon32
Slon34 ~~ e311*Slon34
# PARENT REPORT (Method 2, Non-Reference Method)
# latent rater (method) factors, equal loadings across time
R121 =~ Plon12 + lr21*Plon22 + lr31*Plon32
R122 =~ Plon14 + lr21*Plon24 + lr31*Plon34
# Latent method change factor Time 2 - Time 1
ChR1 =~ 0*Slon12
# Time 2 method factor equals 1*Method 1 + 1*Change
R122 ~ 1*R121 + 1*ChR1
# Set Method-2 residual variance to zero
R122 ~~ 0*R122
# Intercepts set equal across time
# [Plon12 Plon14] (a112)
# [Plon22 Plon24] (a212)
# [Plon32 Plon34] (a312)
# Indicator-specific factors for parent indicators
I212 =~ 1*Plon22 + 1*Plon24
I312 =~ 1*Plon32 + 1*Plon34
# Unwanted correlations set to zero
SR111 ~~ 0*SR112 + 0*R121 + 0*R122 + 0*ChR1 + 0*I211 + 0*I311 + 0*I212 + 0*I312
ChLon ~~ 0*SR112 + 0*R121 + 0*R122 + 0*ChR1 + 0*I211 + 0*I311 + 0*I212 + 0*I312
R121 ~~ 0*R122 + 0*SR112 + 0*I211 + 0*I311 + 0*I212 + 0*I312
ChR1 ~~ 0*R122 + 0*SR112 + 0*I211 + 0*I311 + 0*I212 + 0*I312
SR212 ~~ 0*SR111 + 0*ChLon + 0*SR112 + 0*R121 + 0*R122 + 0*ChR1 + 0*I211 + 0*I311 +
0*I212 + 0*I312
# Error variances set equal across time
Plon12 ~~ e122*Plon12
Plon14 ~~ e122*Plon14
Plon22 ~~ e222*Plon22
Plon24 ~~ e222*Plon24
Plon32 ~~ e322*Plon32
Plon34 ~~ e322*Plon34
# FLOURISHING (Construct 2)
# SELF-REPORT (Method 1, Reference Method)
# latent state-rater factors, equal loadings across time
SR211 =~ SFlou12 + ls22*SFlou22 + lp12*PFlou12 + lp22*PFlou22
SR212 =~ SFlou14 + ls22*SFlou24 + lp12*PFlou14 + lp22*PFlou24
# Latent state change factor Time 2 - Time 1
ChFlo =~ 0*Slon12
# Time 2 state factor equals 1*State 1 + 1*Change
SR212 ~ 1*SR211 + 1*ChFlo
# Set State-2 residual variance to zero
SR212 ~~ 0*SR212
# Intercepts set equal across time
# [SFlou12 SFlou14] (a121)
# [SFlou22 SFlou24] (a221)
# Time-1 state-rater factor mean fixed to zero
# Time-2 state-rater factor mean freely estimated to assess mean change
SR211 ~ 0*1
SR212 ~ 1
# Indicator-specific factor
I221 =~ 1*SFlou22 + 1*SFlou24
# set error variances equal across time
SFlou12 ~~ e112*SFlou12
SFlou14 ~~ e112*SFlou14
SFlou22 ~~ e212*SFlou22
SFlou24 ~~ e212*SFlou24
# PARENT REPORT (Method 2, Non-Reference Method)
# latent rater (method) factors, equal loadings across time
R221 =~ PFlou12 + lr22*PFlou22
R222 =~ PFlou14 + lr22*PFlou24
# Latent method change factor Time 2 - Time 1
ChR2 =~ 0*Slon12
# Time 2 method factor equals 1*Method 1 + 1*Change
R222 ~ 1*R221 + 1*ChR2
# Set Method-2 residual variance to zero
R222 ~~ 0*R222
# Intercepts set equal across time
PFlou12 ~ a122*1
PFlou14 ~ a122*1
PFlou22 ~ a222*1
PFlou24 ~ a222*1
# Indicator-specific factor
I222 =~ 1*PFlou22 + 1*PFlou24
# Unwanted correlations
SR211 ~~ 0*SR212 + 0*R221 + 0*R222 + 0*ChR2 + 0*I221 + 0*I222
ChFlo ~~ 0*SR212 + 0*R221 + 0*R222 + 0*ChR2 + 0*I221 + 0*I222
R221 ~~ 0*R222 + 0*SR212 + 0*I221 + 0*I222
ChR2 ~~ 0*R222 + 0*SR212 + 0*I221 + 0*I222
SR112 ~~ 0*SR211 + 0*ChFlo + 0*R221 + 0*R222 + 0*ChR2 + 0*I221 + 0*I222
R122 ~~ 0*SR112
R222 ~~ 0*R122 + 0*SR212
# Error variances set equal across time
PFlou12 ~~ e122*PFlou12
PFlou14 ~~ e122*PFlou14
PFlou22 ~~ e222*PFlou22
PFlou24 ~~ e222*PFlou24
'
fit <- sem(model=CSCM1C, data=chapter_9_str, estimator="mlr", missing="fiml")
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Models of Section 9.5.1
MR-LST model for loneliness and flourishing measured by self- and parent report
R Code
MMLST <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1) as reference
# Reference latent trait factors T_ij1l
# Parent loadings set equal across time
T111 =~ Slon12 + 1*Slon14 + lT11*Plon12 + lT11*Plon14
T211 =~ Slon22 + 1*Slon24 + lT21*Plon22 + lT21*Plon24
T311 =~ Slon32 + 1*Slon34 + lT31*Plon32 + lT31*Plon34
# Trait-rater residual factors TRR_ijk for parents
# loadings fixed to 1 to set them equal across time
TRR111 =~ 1*Plon12 + 1*Plon14
TRR211 =~ 1*Plon22 + 1*Plon24
TRR311 =~ 1*Plon32 + 1*Plon34
# Reference latent occasion residual factors O_ij1l
# First measurement occasion
# Parent loadings set equal across time
O1111 =~ Slon12 + lO11*Plon12
O2111 =~ Slon22 + lO21*Plon22
O3111 =~ Slon32 + lO31*Plon32
# Second measurement occasion
O1112 =~ Slon14 + lO11*Plon14
O2112 =~ Slon24 + lO21*Plon24
O3112 =~ Slon34 + lO31*Plon34
# Occasion-rater residual factors OR_jkl for parents
# First measurement occasion
OR121 =~ Plon12 + lOR21*Plon22 + lOR31*Plon32
# Second measurement occasion
OR122 =~ Plon14 + lOR21*Plon24 + lOR31*Plon34
# Latent correlations to be estimated (within Construct 1)
T111 ~~ T111 + T211 + T311
T211 ~~ T211 + T311
T311 ~~ T311
TRR111 ~~ TRR111 + TRR211 + TRR311
TRR211 ~~ TRR211 + TRR311
TRR311 ~~ TRR311
O1111 ~~ O1111 + O2111 + O3111
O2111 ~~ O2111 + O3111
O3111 ~~ O3111
O1112 ~~ O1112 + O2112 + O3112
O2112 ~~ O2112 + O3112
O3112 ~~ O3112
# FLOURISHING (Construct 2)
# SELF REPORT (Method 1) as reference
# Reference latent trait factors T_ij1l
# Parent loadings set equal across time
T121 =~ SFlou12 + 1*SFlou14 + lT12*PFlou12 + lT12*PFlou14
T221 =~ SFlou22 + 1*SFlou24 + lT22*PFlou22 + lT22*PFlou24
# Trait-rater residual factors TRR_ijk for parents
# loadings fixed to 1 to set them equal across time
TRR121 =~ 1*PFlou12 + 1*PFlou14
TRR221 =~ 1*PFlou22 + 1*PFlou24
# Reference latent occasion residual factors O_ij1l
# First measurement occasion
# Parent loadings set equal across time
O1211 =~ SFlou12 + lO12*PFlou12
O2211 =~ SFlou22 + lO22*PFlou22
# Second measurement occasion
O1212 =~ SFlou14 + lO12*PFlou14
O2212 =~ SFlou24 + lO22*PFlou24
# Occasion-rater residual factors OR_jkl for parents
# First measurement occasion
OR221 =~ PFlou12 + lOR22*PFlou22
# Second measurement occasion
OR222 =~ PFlou14 + lOR22*PFlou24
# Latent correlations to be estimated (within Construct 2)
T121 ~~ T121 + T221
T221 ~~ T221
TRR121 ~~ TRR121 + TRR221
TRR221 ~~ TRR221
O1211 ~~ O1211 + O2211
O2211 ~~ O2211
O1212 ~~ O1212 + O2212
O2212 ~~ O2212
# Latent covariances to be estimated between constructs
T111 ~~ T121 + T221
T211 ~~ T121 + T221
T311 ~~ T121 + T221
TRR111 ~~ TRR121 + TRR221
TRR211 ~~ TRR121 + TRR221
TRR311 ~~ TRR121 + TRR221
O1111 ~~ O1211 + O2211
O2111 ~~ O1211 + O2211
O3111 ~~ O1211 + O2211
O1112 ~~ O1212 + O2212
O2112 ~~ O1212 + O2212
O3112 ~~ O1212 + O2212
OR121 ~~ OR221
OR122 ~~ OR222
'
fit <- sem(model=MMLST, data=chapter_9_str, estimator="mlr", missing="fiml", orthogonal=TRUE)
summary(fit, fit.measures=T, standardized=T)
MPlus Code
MR-LST model for loneliness and flourishing measured by self- and parent report with general instead of indicator-specific occasion residual factors O_j1l
R Code
MMLSTg <- '
# LONELINESS (Construct 1)
# SELF REPORT (Method 1) as reference
# Reference latent trait factors T_ij1l
# Parent loadings set equal across time
T111 =~ Slon12 + 1*Slon14 + lT11*Plon12 + lT11*Plon14
T211 =~ Slon22 + 1*Slon24 + lT21*Plon22 + lT21*Plon24
T311 =~ Slon32 + 1*Slon34 + lT31*Plon32 + lT31*Plon34
# Trait-rater residual factors TRR_ijk for parents
# loadings fixed to 1 to set them equal across time
TRR111 =~ 1*Plon12 + 1*Plon14
TRR211 =~ 1*Plon22 + 1*Plon24
TRR311 =~ 1*Plon32 + 1*Plon34
# Reference latent occasion residual factors O_j1l
# First measurement occasion
# Loadings set equal across time
O111 =~ Slon12 + lO211*Slon22 + lO311*Slon32 + lO112*Plon12 + lO212*Plon22 + lO312*Plon32
# Second measurement occasion
O112 =~ Slon14 + lO211*Slon24 + lO311*Slon34 + lO112*Plon14 + lO212*Plon24 + lO312*Plon34
# Occasion-rater residual factors OR_jkl for parents
# First measurement occasion
OR121 =~ Plon12 + lOR21*Plon22 + lOR31*Plon32
# Second measurement occasion
OR122 =~ Plon14 + lOR21*Plon24 + lOR31*Plon34
# Latent correlations to be estimated (within Construct 1)
T111 ~~ T111 + T211 + T311
T211 ~~ T211 + T311
T311 ~~ T311
TRR111 ~~ TRR111 + TRR211 + TRR311
TRR211 ~~ TRR211 + TRR311
TRR311 ~~ TRR311
# FLOURISHING (Construct 2)
# SELF REPORT (Method 1) as reference
# Reference latent trait factors T_ij1l
# Parent loadings set equal across time
T121 =~ SFlou12 + 1*SFlou14 + lT12*PFlou12 + lT12*PFlou14
T221 =~ SFlou22 + 1*SFlou24 + lT22*PFlou22 + lT22*PFlou24
# Trait-rater residual factors TRR_ijk for parents
# loadings fixed to 1 to set them equal across time
TRR121 =~ 1*PFlou12 + 1*PFlou14
TRR221 =~ 1*PFlou22 + 1*PFlou24
# Reference latent occasion residual factors O_j1l
# First measurement occasion
# Loadings set equal across time
O211 =~ SFlou12 + lO221*SFlou22 + lO122*PFlou12 + lO222*PFlou22
# Second measurement occasion
O212 =~ SFlou14 + lO221*SFlou24 + lO122*PFlou14 + lO222*PFlou24
# Occasion-rater residual factors OR_jkl for parents
# First measurement occasion
OR221 =~ PFlou12 + lOR22*PFlou22
# Second measurement occasion
OR222 =~ PFlou14 + lOR22*PFlou24
# Latent correlations to be estimated (within Construct 2)
T121 ~~ T121 + T221
T221 ~~ T221
TRR121 ~~ TRR121 + TRR221
TRR221 ~~ TRR221
# Latent covariances to be estimated between constructs
T111 ~~ T121 + T221
T211 ~~ T121 + T221
T311 ~~ T121 + T221
TRR111 ~~ TRR121 + TRR221
TRR211 ~~ TRR121 + TRR221
TRR311 ~~ TRR121 + TRR221
O111 ~~ O211
O112 ~~ O212
OR121 ~~ OR221
OR122 ~~ OR222
'
fit <- sem(model=MMLSTg, data=chapter_9_str, estimator="mlr", missing="fiml", orthogonal=TRUE)
summary(fit, fit.measures=T, standardized=T)
MPlus Code
Models of Section 9.6.2
R Code
LS-COM mode for loneliness and flourishing measured by self- and parent and peer report with configural MI and IS Factors and NO CR-Factors at Between Level
R Code
ls_com_conf <- '
Level: 1
# Trait-specific rater (method) factors UR_j
# Flourishing (UR_l)
UR_flou1 =~ 1*FFlou12 + FFlou22
UR_flou2 =~ 1*FFlou14 + FFlou24
UR_lon1 =~ 1*Flon12 + Flon22 + Flon32
UR_lon2 =~ 1*Flon14 + Flon24 + Flon34
# Indicator-Specific Effects
IS_UR1 =~ 1*FFlou22 + 1*FFlou24
IS_UR2 =~ 1*Flon22 + 1*Flon24
IS_UR3 =~ 1*Flon32 + 1*Flon34
# Impermissible Correlations
UR_flou1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_flou2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
Level: 2
# Flourishing
S_flou1 =~ 1*SFlou12 + SFlou22 + FFlou12 + FFlou22 + PFlou12 + PFlou22
S_flou2 =~ 1*SFlou14 + SFlou24 + FFlou14 + FFlou24 + PFlou14 + PFlou24
# Loneliness
S_lone1 =~ 1*Slon12 + Slon22 + Slon32 + Flon12 + Flon22 + Flon32 + Plon12 + Plon22 +
Plon32
S_lone2 =~ 1*Slon14 + Slon24 + Slon34 + Flon14 + Flon24 + Flon34 + Plon14 + Plon24 +
Plon34
# Rater-Specific Factors
R_flou1 =~ 1*PFlou12 + PFlou22
R_flou2 =~ 1*PFlou14 + PFlou24
R_lone1 =~ Plon12 + Plon22 + Plon32
R_lone2 =~ Plon14 + Plon24 + Plon34
######################################
# Note: Difference to Mplus Code
# Common Rater-Specific Factors
# were fixed to zero due to low variance
# and to ensure convergence of the models
S_flou1 ~~ 0*R_flou1
S_flou2 ~~ 0*R_flou2
S_lone1 ~~ 0*R_lone1
S_lone2 ~~ 0*R_lone2
######################################
# Level-2 residual variances fixed to zero
FFlou12 ~~ 0*FFlou12
FFlou14 ~~ 0*FFlou14
FFlou22 ~~ 0*FFlou22
FFlou24 ~~ 0*FFlou24
Flon12 ~~ 0*Flon12
Flon14 ~~ 0*Flon14
Flon22 ~~ 0*Flon22
Flon24 ~~ 0*Flon24
Flon32 ~~ 0*Flon32
Flon34 ~~ 0*Flon34
# Indicator-Specific Factors
IS_S1 =~ 1*SFlou22 + 1*SFlou24
IS_S2 =~ 1*Slon22 + 1*Slon24
IS_S3 =~ 1*Slon32 + 1*Slon34
IS_P1 =~ 1*PFlou22 + 1*PFlou24
IS_P2 =~ 1*Plon22 + 1*Plon24
IS_P3 =~ 1*Plon32 + 1*Plon34
# Impermissible Correlations
S_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
'
fit_ls_com_conf <- sem(ls_com_conf, data = chapter_9_com,
estimator="mlr", cluster = "Target",
baseline = FALSE, start = "simple",
#verbose=T
)
summary(fit_ls_com_conf, fit.measures=T)
MPlus Code
LS-COM mode for loneliness and flourishing measured by self- and parent and peer report with weak MI + IS Factors + NO CR-Factors at Between Level
R Code
ls_com_weak <- '
Level: 1
# Trait-specific rater (method) factors UR_j
# Flourishing (UR_l)
UR_flou1 =~ 1*FFlou12 + lamUR1*FFlou22
UR_flou2 =~ 1*FFlou14 + lamUR1*FFlou24
UR_lon1 =~ 1*Flon12 + lamUR2*Flon22 + lamUR3*Flon32
UR_lon2 =~ 1*Flon14 + lamUR2*Flon24 + lamUR3*Flon34
# Indicator-Specific Effects
IS_UR1 =~ 1*FFlou22 + 1*FFlou24
IS_UR2 =~ 1*Flon22 + 1*Flon24
IS_UR3 =~ 1*Flon32 + 1*Flon34
UR_flou1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_flou2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
Level: 2
# Flourishing
S_flou1 =~ 1*SFlou12 + lamS21*SFlou22 + lamS31*FFlou12 + lamS41*FFlou22 +
lamS51*PFlou12 + lamS61*PFlou22
S_flou2 =~ 1*SFlou14 + lamS21*SFlou24 + lamS31*FFlou14 + lamS41*FFlou24 +
lamS51*PFlou14 + lamS61*PFlou24
# Loneliness
S_lone1 =~ 1*Slon12 + lamS22*Slon22 + lamS32*Slon32 + lamS42*Flon12 + lamS52*Flon22 +
lamS62*Flon32 + lamS72*Plon12 + lamS82*Plon22 + lamS92*Plon32
S_lone2 =~ 1*Slon14 + lamS22*Slon24 + lamS32*Slon34 + lamS42*Flon14 + lamS52*Flon24 +
lamS62*Flon34 + lamS72*Plon14 + lamS82*Plon24 + lamS92*Plon34
# Rater-Specific Factors
R_flou1 =~ 1*PFlou12 + lamR1*PFlou22
R_flou2 =~ 1*PFlou14 + lamR1*PFlou24
R_lone1 =~ Plon12 + lamR2*Plon22 + lamR3*Plon32
R_lone2 =~ Plon14 + lamR2*Plon24 + lamR3*Plon34
######################################
# Note: Difference to Mplus Code
# Common Rater-Specific Factors
# were fixed to zero due to low variance
# and to ensure convergence of the models
# CR_flou1 =~ 1*FFlou12 + lamCR1*FFlou22
# CR_flou2 =~ 1*FFlou14 + lamCR1*FFlou24
# CR_lone1 =~ 1*Flon12 + lamCR2*Flon22 + lamCR3*Flon32
# CR_lone2 =~ 1*Flon14 + lamCR2*Flon24 + lamCR3*Flon35
S_flou1 ~~ 0*R_flou1 #+ 0*CR_flou1
S_flou2 ~~ 0*R_flou2 #+ 0*CR_flou2
S_lone1 ~~ 0*R_lone1 #+ 0*CR_lone1
S_lone2 ~~ 0*R_lone2 #+ 0*CR_lone2
#######################################
IS_S1 =~ 1*SFlou22 + 1*SFlou24
IS_S2 =~ 1*Slon22 + 1*Slon24
IS_S3 =~ 1*Slon32 + 1*Slon34
IS_P1 =~ 1*PFlou22 + 1*PFlou24
IS_P2 =~ 1*Plon22 + 1*Plon24
IS_P3 =~ 1*Plon32 + 1*Plon34
S_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# Level-2 residual variances fixed to zero
FFlou12 ~~ 0*FFlou12
FFlou14 ~~ 0*FFlou14
FFlou22 ~~ 0*FFlou22
FFlou24 ~~ 0*FFlou24
Flon12 ~~ 0*Flon12
Flon14 ~~ 0*Flon14
Flon22 ~~ 0*Flon22
Flon24 ~~ 0*Flon24
Flon32 ~~ 0*Flon32
Flon34 ~~ 0*Flon34
'
fit_ls_com_weak <- sem(ls_com_weak, data = chapter_9_com,
estimator="mlr", cluster = "Target",
baseline = FALSE, start = "simple",
#verbose=T
)
summary(fit_ls_com_weak, fit.measures=T)
MPlus Code
LS-COM mode for loneliness and flourishing measured by self- and parent and peer report with strong MI + IS Factors + NO CR-Factors at Between Level
R Code
ls_com_strong <- '
Level: 1
# Trait-specific rater (method) factors UR_j
# Flourishing (UR_l)
UR_flou1 =~ 1*FFlou12 + lamUR1*FFlou22
UR_flou2 =~ 1*FFlou14 + lamUR1*FFlou24
UR_lon1 =~ 1*Flon12 + lamUR2*Flon22 + lamUR3*Flon32
UR_lon2 =~ 1*Flon14 + lamUR2*Flon24 + lamUR3*Flon34
# Indicator-Specific Effects
IS_UR1 =~ 1*FFlou22 + 1*FFlou24
IS_UR2 =~ 1*Flon22 + 1*Flon24
IS_UR3 =~ 1*Flon32 + 1*Flon34
UR_flou1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_flou2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
Level: 2
# Flourishing
S_flou1 =~ 1*SFlou12 + lamS21*SFlou22 + lamS31*FFlou12 + lamS41*FFlou22 +
lamS51*PFlou12 + lamS61*PFlou22
S_flou2 =~ 1*SFlou14 + lamS21*SFlou24 + lamS31*FFlou14 + lamS41*FFlou24 +
lamS51*PFlou14 + lamS61*PFlou24
# Loneliness
S_lone1 =~ 1*Slon12 + lamS22*Slon22 + lamS32*Slon32 + lamS42*Flon12 + lamS52*Flon22 +
lamS62*Flon32 + lamS72*Plon12 + lamS82*Plon22 + lamS92*Plon32
S_lone2 =~ 1*Slon14 + lamS22*Slon24 + lamS32*Slon34 + lamS42*Flon14 + lamS52*Flon24 +
lamS62*Flon34 + lamS72*Plon14 + lamS82*Plon24 + lamS92*Plon34
# Rater-Specific Factors
R_flou1 =~ 1*PFlou12 + lamR1*PFlou22
R_flou2 =~ 1*PFlou14 + lamR1*PFlou24
R_lone1 =~ Plon12 + lamR2*Plon22 + lamR3*Plon32
R_lone2 =~ Plon14 + lamR2*Plon24 + lamR3*Plon34
######################################
# Note: Difference to Mplus Code
# Common Rater-Specific Factors
# were fixed to zero due to low variance
# and to ensure convergence of the models
# Common Rater-Specific Factors
# CR_flou1 =~ 1*FFlou12 + lamCR1*FFlou22
# CR_flou2 =~ 1*FFlou14 + lamCR1*FFlou24
# CR_lone1 =~ 1*Flon12 + lamCR2*Flon22 + lamCR3*Flon32
# CR_lone2 =~ 1*Flon14 + lamCR2*Flon24 + lamCR3*Flon34
S_flou1 ~~ 0*R_flou1 #+ 0*CR_flou1
S_flou2 ~~ 0*R_flou2 #+ 0*CR_flou2
S_lone1 ~~ 0*R_lone1 #+ 0*CR_lone1
S_lone2 ~~ 0*R_lone2 #+ 0*CR_lone2
######################################
IS_S1 =~ 1*SFlou22 + 1*SFlou24
IS_S2 =~ 1*Slon22 + 1*Slon24
IS_S3 =~ 1*Slon32 + 1*Slon34
IS_P1 =~ 1*PFlou22 + 1*PFlou24
IS_P2 =~ 1*Plon22 + 1*Plon24
IS_P3 =~ 1*Plon32 + 1*Plon34
S_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# Level-2 residual variances fixed to zero
FFlou12 ~~ 0*FFlou12
FFlou14 ~~ 0*FFlou14
FFlou22 ~~ 0*FFlou22
FFlou24 ~~ 0*FFlou24
Flon12 ~~ 0*Flon12
Flon14 ~~ 0*Flon14
Flon22 ~~ 0*Flon22
Flon24 ~~ 0*Flon24
Flon32 ~~ 0*Flon32
Flon34 ~~ 0*Flon34
# Intercept Structure
SFlou12 ~ 0*1
SFlou14 ~ 0*1
SFlou22 ~ alpS1*1
SFlou24 ~ alpS1*1
Slon12 ~ 0*1
Slon14 ~ 0*1
Slon22 ~ alpS2*1
Slon24 ~ alpS2*1
Slon32 ~ alpS3*1
Slon34 ~ alpS3*1
S_flou1 ~ 1
S_flou2 ~ 1
S_lone1 ~ 1
S_lone2 ~ 1
'
fit_ls_com_strong <- sem(ls_com_strong, data = chapter_9_com,
estimator="mlr", cluster = "Target",
baseline = FALSE, start = "simple",
#verbose=T
)
summary(fit_ls_com_strong, fit.measures=T)
MPlus Code
LS-COM mode for loneliness and flourishing measured by self- and parent and peer report with strict MI + IS Factors + NO CR-Factors at Between Level
R Code
ls_com_strict <- '
Level: 1
# Trait-specific rater (method) factors UR_j
# Flourishing (UR_l)
UR_flou1 =~ 1*FFlou12 + lamUR1*FFlou22
UR_flou2 =~ 1*FFlou14 + lamUR1*FFlou24
UR_lon1 =~ 1*Flon12 + lamUR2*Flon22 + lamUR3*Flon32
UR_lon2 =~ 1*Flon14 + lamUR2*Flon24 + lamUR3*Flon34
# Indicator-Specific Effects
IS_UR1 =~ 1*FFlou22 + 1*FFlou24
IS_UR2 =~ 1*Flon22 + 1*Flon24
IS_UR3 =~ 1*Flon32 + 1*Flon34
UR_flou1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_flou2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
Level: 2
# Flourishing
S_flou1 =~ 1*SFlou12 + lamS21*SFlou22 + lamS31*FFlou12 + lamS41*FFlou22 +
lamS51*PFlou12 + lamS61*PFlou22
S_flou2 =~ 1*SFlou14 + lamS21*SFlou24 + lamS31*FFlou14 + lamS41*FFlou24 +
lamS51*PFlou14 + lamS61*PFlou24
# Loneliness
S_lone1 =~ 1*Slon12 + lamS22*Slon22 + lamS32*Slon32 + lamS42*Flon12 + lamS52*Flon22 +
lamS62*Flon32 + lamS72*Plon12 + lamS82*Plon22 + lamS92*Plon32
S_lone2 =~ 1*Slon14 + lamS22*Slon24 + lamS32*Slon34 + lamS42*Flon14 + lamS52*Flon24 +
lamS62*Flon34 + lamS72*Plon14 + lamS82*Plon24 + lamS92*Plon34
# Rater-Specific Factors
R_flou1 =~ 1*PFlou12 + lamR1*PFlou22
R_flou2 =~ 1*PFlou14 + lamR1*PFlou24
R_lone1 =~ Plon12 + lamR2*Plon22 + lamR3*Plon32
R_lone2 =~ Plon14 + lamR2*Plon24 + lamR3*Plon34
######################################
# Note: Difference to Mplus Code
# Common Rater-Specific Factors
# were fixed to zero due to low variance
# and to ensure convergence of the models
# Common Rater-Specific Factors
# CR_flou1 =~ 1*FFlou12 + lamCR1*FFlou22
# CR_flou2 =~ 1*FFlou14 + lamCR1*FFlou24
# CR_lone1 =~ 1*Flon12 + lamCR2*Flon22 + lamCR3*Flon32
# CR_lone2 =~ 1*Flon14 + lamCR2*Flon24 + lamCR3*Flon34
S_flou1 ~~ 0*R_flou1 #+ 0*CR_flou1
S_flou2 ~~ 0*R_flou2 #+ 0*CR_flou2
S_lone1 ~~ 0*R_lone1 #+ 0*CR_lone1
S_lone2 ~~ 0*R_lone2 #+ 0*CR_lone2
######################################
IS_S1 =~ 1*SFlou22 + 1*SFlou24
IS_S2 =~ 1*Slon22 + 1*Slon24
IS_S3 =~ 1*Slon32 + 1*Slon34
IS_P1 =~ 1*PFlou22 + 1*PFlou24
IS_P2 =~ 1*Plon22 + 1*Plon24
IS_P3 =~ 1*Plon32 + 1*Plon34
S_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# Level-2 residual variances fixed to zero
FFlou12 ~~ 0*FFlou12
FFlou14 ~~ 0*FFlou14
FFlou22 ~~ 0*FFlou22
FFlou24 ~~ 0*FFlou24
Flon12 ~~ 0*Flon12
Flon14 ~~ 0*Flon14
Flon22 ~~ 0*Flon22
Flon24 ~~ 0*Flon24
Flon32 ~~ 0*Flon32
Flon34 ~~ 0*Flon34
# Intercept Structure
SFlou12 ~ 0*1
SFlou14 ~ 0*1
SFlou22 ~ alpS1*1
SFlou24 ~ alpS1*1
Slon12 ~ 0*1
Slon14 ~ 0*1
Slon22 ~ alpS2*1
Slon24 ~ alpS2*1
Slon32 ~ alpS3*1
Slon34 ~ alpS3*1
S_flou1 ~ 1
S_flou2 ~ 1
S_lone1 ~ 1
S_lone2 ~ 1
# Equal Error Variances
SFlou12 ~~ epsS1*SFlou12
SFlou14 ~~ epsS1*SFlou14
SFlou22 ~~ epsS2*SFlou22
SFlou24 ~~ epsS2*SFlou24
PFlou12 ~~ epsP1*PFlou12
PFlou14 ~~ epsP1*PFlou14
PFlou22 ~~ epsP2*PFlou22
PFlou24 ~~ epsP2*PFlou24
Slon12 ~~ epsS3*Slon12
Slon14 ~~ epsS3*Slon14
Slon22 ~~ epsS4*Slon22
Slon24 ~~ epsS4*Slon24
Slon32 ~~ epsS5*Slon32
Slon34 ~~ epsS5*Slon34
Plon12 ~~ epsP3*Plon12
Plon14 ~~ epsP3*Plon14
Plon22 ~~ epsP4*Plon22
Plon24 ~~ epsP4*Plon24
Plon32 ~~ epsP5*Plon32
Plon34 ~~ epsP5*Plon34
'
fit_ls_com_strict <- sem(ls_com_strict, data = chapter_9_com,
estimator="mlr", cluster = "Target",
baseline = FALSE, start = "simple",
#verbose=T
)
summary(fit_ls_com_strict, fit.measures=T)
MPlus Code
LS-COM mode for loneliness and flourishing measured by self- and parent and peer report with strict MI + IS Factors + Equal Variances + NO CR-Factors at Between Level
R Code
ls_com_strict_eq_var <- '
Level: 1
# Trait-specific rater (method) factors UR_j
# Flourishing (UR_l)
UR_flou1 =~ 1*FFlou12 + lamUR1*FFlou22
UR_flou2 =~ 1*FFlou14 + lamUR1*FFlou24
UR_lon1 =~ 1*Flon12 + lamUR2*Flon22 + lamUR3*Flon32
UR_lon2 =~ 1*Flon14 + lamUR2*Flon24 + lamUR3*Flon34
# Indicator-Specific Effects
IS_UR1 =~ 1*FFlou22 + 1*FFlou24
IS_UR2 =~ 1*Flon22 + 1*Flon24
IS_UR3 =~ 1*Flon32 + 1*Flon34
# Impermissible Correlations
UR_flou1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_flou2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon1 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
UR_lon2 ~~ 0*IS_UR1 + 0*IS_UR2 + 0*IS_UR3
# Equal UR Factor Variances
UR_flou1 ~~ UR1*UR_flou1
UR_flou2 ~~ UR1*UR_flou2
UR_lon1 ~~ UR2*UR_lon1
UR_lon2 ~~ UR2*UR_lon2
Level: 2
# Flourishing
S_flou1 =~ 1*SFlou12 + lamS21*SFlou22 + lamS31*FFlou12 + lamS41*FFlou22 +
lamS51*PFlou12 + lamS61*PFlou22
S_flou2 =~ 1*SFlou14 + lamS21*SFlou24 + lamS31*FFlou14 + lamS41*FFlou24 +
lamS51*PFlou14 + lamS61*PFlou24
# Loneliness
S_lone1 =~ 1*Slon12 + lamS22*Slon22 + lamS32*Slon32 + lamS42*Flon12 + lamS52*Flon22 +
lamS62*Flon32 + lamS72*Plon12 + lamS82*Plon22 + lamS92*Plon32
S_lone2 =~ 1*Slon14 + lamS22*Slon24 + lamS32*Slon34 + lamS42*Flon14 + lamS52*Flon24 +
lamS62*Flon34 + lamS72*Plon14 + lamS82*Plon24 + lamS92*Plon34
# Rater-Specific Factors
R_flou1 =~ 1*PFlou12 + lamR1*PFlou22
R_flou2 =~ 1*PFlou14 + lamR1*PFlou24
R_lone1 =~ Plon12 + lamR2*Plon22 + lamR3*Plon32
R_lone2 =~ Plon14 + lamR2*Plon24 + lamR3*Plon34
######################################
# Note: Difference to Mplus Code
# Common Rater-Specific Factors
# were fixed to zero due to low variance
# and to ensure convergence of the models
# Common Rater-Specific Factors
# CR_flou1 =~ 1*FFlou12 + lamCR1*FFlou22
# CR_flou2 =~ 1*FFlou14 + lamCR1*FFlou24
# CR_lone1 =~ 1*Flon12 + lamCR2*Flon22 + lamCR3*Flon32
# CR_lone2 =~ 1*Flon14 + lamCR2*Flon24 + lamCR3*Flon34
S_flou1 ~~ 0*R_flou1 #+ 0*CR_flou1
S_flou2 ~~ 0*R_flou2 #+ 0*CR_flou2
S_lone1 ~~ 0*R_lone1 #+ 0*CR_lone1
S_lone2 ~~ 0*R_lone2 #+ 0*CR_lone2
######################################
IS_S1 =~ 1*SFlou22 + 1*SFlou24
IS_S2 =~ 1*Slon22 + 1*Slon24
IS_S3 =~ 1*Slon32 + 1*Slon34
IS_P1 =~ 1*PFlou22 + 1*PFlou24
IS_P2 =~ 1*Plon22 + 1*Plon24
IS_P3 =~ 1*Plon32 + 1*Plon34
# Impermissible Correlations
S_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
S_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
R_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_flou2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone1 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# CR_lone2 ~~ 0*IS_S1 + 0*IS_S2 + 0*IS_S3 + 0*IS_P1 + 0*IS_P2 + 0*IS_P3
# Level-2 residual variances fixed to zero
FFlou12 ~~ 0*FFlou12
FFlou14 ~~ 0*FFlou14
FFlou22 ~~ 0*FFlou22
FFlou24 ~~ 0*FFlou24
Flon12 ~~ 0*Flon12
Flon14 ~~ 0*Flon14
Flon22 ~~ 0*Flon22
Flon24 ~~ 0*Flon24
Flon32 ~~ 0*Flon32
Flon34 ~~ 0*Flon34
# Intercept Structure
SFlou12 ~ 0*1
SFlou14 ~ 0*1
SFlou22 ~ alpS1*1
SFlou24 ~ alpS1*1
Slon12 ~ 0*1
Slon14 ~ 0*1
Slon22 ~ alpS2*1
Slon24 ~ alpS2*1
Slon32 ~ alpS3*1
Slon34 ~ alpS3*1
S_flou1 ~ 1
S_flou2 ~ 1
S_lone1 ~ 1
S_lone2 ~ 1
# Equal Error Variances
SFlou12 ~~ epsS1*SFlou12
SFlou14 ~~ epsS1*SFlou14
SFlou22 ~~ epsS2*SFlou22
SFlou24 ~~ epsS2*SFlou24
PFlou12 ~~ epsP1*PFlou12
PFlou14 ~~ epsP1*PFlou14
PFlou22 ~~ epsP2*PFlou22
PFlou24 ~~ epsP2*PFlou24
Slon12 ~~ epsS3*Slon12
Slon14 ~~ epsS3*Slon14
Slon22 ~~ epsS4*Slon22
Slon24 ~~ epsS4*Slon24
Slon32 ~~ epsS5*Slon32
Slon34 ~~ epsS5*Slon34
Plon12 ~~ epsP3*Plon12
Plon14 ~~ epsP3*Plon14
Plon22 ~~ epsP4*Plon22
Plon24 ~~ epsP4*Plon24
Plon32 ~~ epsP5*Plon32
Plon34 ~~ epsP5*Plon34
# Equal Factor Variances
S_lone1 ~~ state2*S_lone1
S_lone2 ~~ state2*S_lone2
R_flou1 ~~ R1*R_flou1
R_flou2 ~~ R1*R_flou2
R_lone1 ~~ R2*R_lone1
R_lone2 ~~ R2*R_lone2
# CR_flou1 ~~ CR_flou*CR_flou1
# CR_flou2 ~~ CR_flou*CR_flou2
# CR_lone1 ~~ CR_lone*CR_lone1
# CR_lone2 ~~ CR_lone*CR_lone2
'
fit_ls_com_strict_eq_var <- sem(ls_com_strict_eq_var, data = chapter_9_com,
estimator="mlr", cluster = "Target",
baseline = FALSE, start = "simple",
#verbose=T
)
# model comparison
anova(fit_ls_com_conf, fit_ls_com_weak, fit_ls_com_strong, fit_ls_com_strict)
MPlus Code
Models of Section 9.6.4
LST-COM mode for loneliness and flourishing measured by self- and parent and peer report with equal loadings and error variances over time and freely estimated intercepts and equal factor variances over time
R Code
lst_com_eq_load_var_free_mu <- '
Level: 1
# UR-Trait-Factors
# Loneliness
T_URl1 =~ 1*Flon12 + 1*Flon14
T_URl2 =~ 1*Flon22 + 1*Flon24
T_URl3 =~ 1*Flon32 + 1*Flon34
# Flourishing
T_URf1 =~ 1*FFlou12 + 1*FFlou14
T_URf2 =~ 1*FFlou22 + 1*FFlou24
# Occasion-Specific Factors
O_URl1 =~ 1*Flon12 + 1*Flon22 + 1*Flon32
O_URl2 =~ 1*Flon14 + 1*Flon24 + 1*Flon34
O_URf1 =~ 1*FFlou12 + 1*FFlou22
O_URf2 =~ 1*FFlou14 + 1*FFlou24
# Free Permissible Correlations
T_URl1 ~~ T_URl2 + T_URl3 + T_URf1 + T_URf2
T_URl2 ~~ T_URl3 + T_URf1 + T_URf2
T_URl3 ~~ T_URf1 + T_URf2
T_URf1 ~~ T_URf2
O_URl1 ~~ UR1*O_URl1
O_URl2 ~~ UR1*O_URl2
O_URf1 ~~ UR2*O_URf1
O_URf2 ~~ UR2*O_URf2
O_URl1 ~~ O_URf1
O_URl2 ~~ O_URf2
# Equal Error Variances
Flon12 ~~ epsF1*Flon12
Flon14 ~~ epsF1*Flon14
Flon22 ~~ epsF2*Flon22
Flon24 ~~ epsF2*Flon24
Flon32 ~~ epsF3*Flon32
Flon34 ~~ epsF3*Flon34
FFlou12 ~~ epsF4*FFlou12
FFlou14 ~~ epsF4*FFlou14
FFlou22 ~~ epsF5*FFlou22
FFlou24 ~~ epsF5*FFlou24
Level: 2
T_l1 =~ 1*Slon12 + 1*Slon14 +
lamTF11*Flon12 + lamTF11*Flon14 +
lamFP11*Plon12 + lamFP11*Plon14
T_l2 =~ 1*Slon22 + 1*Slon24 +
lamTF21*Flon22 + lamTF21*Flon24 +
lamFP21*Plon22 + lamFP21*Plon24
T_l3 =~ 1*Slon32 + 1*Slon34 +
lamTF31*Flon32 + lamTF31*Flon34 +
lamFP31*Plon32 + lamFP31*Plon34
T_f1 =~ 1*SFlou12 + 1*SFlou14 +
lamTF12*FFlou12 + lamTF12*FFlou14 +
lamFP12*PFlou12 + lamFP12*PFlou14
T_f2 =~ 1*SFlou22 + 1*SFlou24 +
lamTF22*FFlou22 + lamTF22*FFlou24 +
lamFP22*PFlou22 + lamFP22*PFlou24
# Free Permissible Trait Correlations
T_l1 ~~ T_l1 + T_l2 + T_l3 + T_f1 + T_f2
T_l1 ~~ T_l2 + T_l3 + T_f1 + T_f2
T_l2 ~~ T_l3 + T_f1 + T_f2
T_l3 ~~ T_f1 + T_f2
T_f1 ~~ T_f2
TCR_l1 =~ 1*Flon12 + 1*Flon14 + 1*Flon22 +
1*Flon24 + 1*Flon32 + 1*Flon34
TPR_l1 =~ 1*Plon12 + 1*Plon14
TPR_l2 =~ 1*Plon22 + 1*Plon24
TPR_l3 =~ 1*Plon32 + 1*Plon34
TCR_f1 =~ 1*FFlou12 + 1*FFlou14
TCR_f2 =~ 1*FFlou22 + 1*FFlou24
TPR_f1 =~ 1*PFlou12 + 1*PFlou14
TPR_f2 =~ 1*PFlou22 + 1*PFlou24
# Free Permissible Rater-Factor Correlations
TCR_l1 ~~ TCR_l1 + TPR_l1 + TPR_l2 + TPR_l3 + TCR_f1 + TCR_f2 + TPR_f1 + TPR_f2
TCR_l1 ~~ TPR_l1 + TPR_l2 + TPR_l3 + TCR_f1 + TCR_f2 + TPR_f1 + TPR_f2
TPR_l1 ~~ TPR_l2 + TPR_l3 + TCR_f1 + TCR_f2 + TPR_f1 + TPR_f2
TPR_l2 ~~ TPR_l3 + TCR_f1 + TCR_f2 + TPR_f1 + TPR_f2
TPR_l3 ~~ TCR_f1 + TCR_f2 + TPR_f1 + TPR_f2
TCR_f1 ~~ TCR_f2 + TPR_f1 + TPR_f2
TCR_f2 ~~ TPR_f1 + TPR_f2
TPR_f1 ~~ TPR_f2
# Flourishing
O_l1 =~ 1*Slon12 + lamO1*Slon22 + lamO2*Slon32 + lamO3*Flon12 + lamO4*Flon22 +
lamO5*Flon32 + lamO6*Plon12 + lamO7*Plon22 + lamO8*Plon32
O_l2 =~ 1*Slon14 + lamO1*Slon24 + lamO2*Slon34 + lamO3*Flon14 + lamO4*Flon24 +
lamO5*Flon34 + lamO6*Plon14 + lamO7*Plon24 + lamO8*Plon34
O_f1 =~ 1*SFlou12 + lamO1*SFlou22 + lamO2*FFlou12 + lamO3*FFlou22 + lamO4*PFlou12 +
lamO5*PFlou22
O_f2 =~ 1*SFlou14 + lamO1*SFlou24 + lamO2*FFlou14 + lamO3*FFlou24 + lamO4*PFlou14 +
lamO5*PFlou24
# Free Permissible Occasion-Specific Correlations
O_l1 ~~ O_f1
O_l2 ~~ O_f2
O_l1 ~~ O1*O_l1
O_l2 ~~ O1*O_l2
O_f1 ~~ O2*O_f1
O_f2 ~~ O2*O_f2
# OCR_l1 =~ 1*Flon12 + 1*Flon22 + 1*Flon32 ### fixed to zero due to low variance
# OCR_l2 =~ 1*Flon14 + 1*Flon24 + 1*Flon34 ### fixed to zero due to low variance
OPR_l1 =~ 1*Plon12 + 1*Plon22 + 1*Plon32
OPR_l2 =~ 1*Plon14 + 1*Plon24 + 1*Plon34
# OCR_l1 ~~ CR1*OCR_l1 ### fixed to zero due to low variance
# OCR_l2 ~~ CR1*OCR_l2 ### fixed to zero due to low variance
OPR_l1 ~~ PR1*OPR_l1
OPR_l2 ~~ PR1*OPR_l2
OCR_f1 =~ 1*FFlou12 + 1*FFlou22
OCR_f2 =~ 1*FFlou14 + 1*FFlou24
OPR_f1 =~ 1*PFlou12 + 1*PFlou22
OPR_f2 =~ 1*PFlou14 + 1*PFlou24
OCR_f1 ~~ CR2*OCR_f1
OCR_f2 ~~ CR2*OCR_f2
OPR_f1 ~~ PR2*OPR_f1
OPR_f2 ~~ PR2*OPR_f2
# Free Permissible Occasion-Specific-Rater Correlations
OPR_l1 ~~ OPR_f1
OPR_l2 ~~ OPR_f2
# Level-2 residual variances fixed to zero
Flon12 ~~ 0*Flon12
Flon22 ~~ 0*Flon22
Flon32 ~~ 0*Flon32
Flon14 ~~ 0*Flon14
Flon24 ~~ 0*Flon24
Flon34 ~~ 0*Flon34
Slon12 ~~ epsS11*Slon12
Slon14 ~~ epsS11*Slon14
Slon22 ~~ epsS21*Slon22
Slon24 ~~ epsS21*Slon24
Slon32 ~~ epsS31*Slon32
Slon34 ~~ epsS31*Slon34
Plon12 ~~ epsP11*Plon12
Plon14 ~~ epsP11*Plon14
Plon22 ~~ epsP21*Plon22
Plon24 ~~ epsP21*Plon24
Plon32 ~~ epsP31*Plon32
Plon34 ~~ epsP31*Plon34
FFlou12 ~~ 0*FFlou12
FFlou14 ~~ 0*FFlou14
FFlou22 ~~ 0*FFlou22
FFlou24 ~~ 0*FFlou24
SFlou12 ~~ epsS12*SFlou12
SFlou14 ~~ epsS12*SFlou14
SFlou22 ~~ epsS22*SFlou22
SFlou24 ~~ epsS22*SFlou24
PFlou12 ~~ epsP12*PFlou12
PFlou14 ~~ epsP12*PFlou14
PFlou22 ~~ epsP22*PFlou22
PFlou24 ~~ epsP22*PFlou24'
fit_lst_com_eq_load_var_free_mu <- sem(lst_com_eq_load_var_free_mu, data = chapter_9_com,
estimator="mlr", cluster = "Target",
baseline = FALSE, start = "simple",
#verbose=T,
orthogonal=TRUE)
summary(fit_lst_com_eq_load_var_free_mu, fit.measure=T)
MPlus Code