1 SET

setwd("C:/Users/user/Desktop/NTNU/longd")

dta.l <- read.csv("./dta_collapse_parent.csv")

names(dta.l)
 [1] "baby_id"         "baby_sex"        "fa_T1"           "fa_T2"          
 [5] "fa_T3"           "ma_T1"           "ma_T2"           "ma_T3"          
 [9] "fatherinvo01_T1" "fatherinvo01_T2" "fatherinvo01_T3" "fatherinvo02_T1"
[13] "fatherinvo02_T2" "fatherinvo02_T3" "fatherinvo03_T1" "fatherinvo03_T2"
[17] "fatherinvo03_T3" "fatherinvo04_T1" "fatherinvo04_T2" "fatherinvo04_T3"
[21] "fatherinvo05_T1" "fatherinvo05_T2" "fatherinvo05_T3" "motherinvo01_T1"
[25] "motherinvo01_T2" "motherinvo01_T3" "motherinvo02_T1" "motherinvo02_T2"
[29] "motherinvo02_T3" "motherinvo03_T1" "motherinvo03_T2" "motherinvo03_T3"
[33] "motherinvo04_T1" "motherinvo04_T2" "motherinvo04_T3" "motherinvo05_T1"
[37] "motherinvo05_T2" "motherinvo05_T3" "famedu01_T1"     "famedu01_T2"    
[41] "famedu01_T3"     "famedu02_T1"     "famedu02_T2"     "famedu02_T3"    
[45] "famedu03_T1"     "famedu03_T2"     "famedu03_T3"     "famedu04_T1"    
[49] "famedu04_T2"     "famedu04_T3"     "famedu05_T1"     "famedu05_T2"    
[53] "famedu05_T3"     "famedu06_T1"     "famedu06_T2"     "famedu06_T3"    
[57] "famedu07_T1"     "famedu07_T2"     "famedu07_T3"     "famedu08_T1"    
[61] "famedu08_T2"     "famedu08_T3"     "famedu09_T1"     "famedu09_T2"    
[65] "famedu09_T3"     "socc02_T1"       "socc02_T2"       "socc02_T3"      
[69] "socc03_T1"       "socc03_T2"       "socc03_T3"       "socc09_T1"      
[73] "socc09_T2"       "socc09_T3"       "socc10_T1"      
 [ reached getOption("max.print") -- omitted 17 entries ]
library(lavaan)

2 FATHER

個體內(WFX, WFY)指的是同一波次的不同items的變異

個體間(RIX, RIY)則是指不同waves的同一個item的變異

RICLPM1 <- '
  
  ################
  # BETWEEN PART #
  ################
  
  # Create between factors (random intercepts) for each indicator separately
  RIX1 =~ 1*fatherinvo01_T1 + 1*fatherinvo01_T2 + 1*fatherinvo01_T3
  RIX2 =~ 1*fatherinvo02_T1 + 1*fatherinvo02_T2 + 1*fatherinvo02_T3
  RIX3 =~ 1*fatherinvo03_T1 + 1*fatherinvo03_T2 + 1*fatherinvo03_T3
  RIX4 =~ 1*fatherinvo04_T1 + 1*fatherinvo04_T2 + 1*fatherinvo04_T3
  RIX5 =~ 1*fatherinvo05_T1 + 1*fatherinvo05_T2 + 1*fatherinvo05_T3

  RIY1 =~ 1*socc02_T1 + 1*socc02_T2 + 1*socc02_T3
  RIY2 =~ 1*socc03_T1 + 1*socc03_T2 + 1*socc03_T3
  RIY3 =~ 1*socc09_T1 + 1*socc09_T2 + 1*socc09_T3
  RIY4 =~ 1*socc10_T1 + 1*socc10_T2 + 1*socc10_T3
  
  ##################################
  # WITHIN PART: MEASUREMENT MODEL #
  ##################################
  
  # Factor models for X at 3 waves
  WFX1 =~ fatherinvo01_T1 + fatherinvo02_T1 + fatherinvo03_T1 + fatherinvo04_T1 + fatherinvo05_T1
  WFX2 =~ fatherinvo01_T2 + fatherinvo02_T2 + fatherinvo03_T2 + fatherinvo04_T2 + fatherinvo05_T2
  WFX3 =~ fatherinvo01_T3 + fatherinvo02_T3 + fatherinvo03_T3 + fatherinvo04_T3 + fatherinvo05_T3

  # Factor models for Y at 3 waves
  WFY1 =~ socc02_T1 + socc03_T1 + socc09_T1 + socc10_T1
  WFY2 =~ socc02_T2 + socc03_T2 + socc09_T2 + socc10_T2
  WFY3 =~ socc02_T3 + socc03_T3 + socc09_T3 + socc10_T3

  #########################
  # WITHIN PART: DYNAMICS #
  #########################
  
  # Specify lagged effects between within-person centered latent variables
  WFX2 + WFY2 ~ WFX1 + WFY1
  WFX3 + WFY3 ~ WFX2 + WFY2

  # Estimate correlations within same wave
  WFX1 ~~ WFY1
  WFX2 ~~ WFY2
  WFX3 ~~ WFY3 
  
  ##########################
  # ADDITIONAL CONSTRAINTS #
  ##########################
  
  # Constrain covariance of between factors and exogenous within factors to 0
  #確保  爸爸投入的五個題目  安全依附的四個題目  在三波次之間  共變=0
  RIX1 + RIX2 + RIX3 + RIX4 + RIX5 + RIY1 + RIY2 + RIY3 + RIY4 ~~ 0*WFY1 + 0*WFX1
'

rst.1 <- cfa(RICLPM1, data = dta.l, ordered = names(dta.l)[9:77], estimator = 'wlsmv')

summary(rst.1, fit.measures = T)
lavaan 0.6-12 ended normally after 137 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                       173

  Number of observations                          1575

Model Test User Model:
                                              Standard      Robust
  Test Statistic                               165.689     304.804
  Degrees of freedom                               268         268
  P-value (Chi-square)                           1.000       0.060
  Scaling correction factor                                  0.913
  Shift parameter                                          123.367
    simple second-order correction                                

Model Test Baseline Model:

  Test statistic                            255314.800   84895.576
  Degrees of freedom                               351         351
  P-value                                        0.000       0.000
  Scaling correction factor                                  3.016

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000       1.000
  Tucker-Lewis Index (TLI)                       1.001       0.999
                                                                  
  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.000       0.009
  90 Percent confidence interval - lower         0.000       0.000
  90 Percent confidence interval - upper         0.000       0.014
  P-value RMSEA <= 0.05                          1.000       1.000
                                                                  
  Robust RMSEA                                                  NA
  90 Percent confidence interval - lower                     0.000
  90 Percent confidence interval - upper                        NA

Standardized Root Mean Square Residual:

  SRMR                                           0.017       0.017

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  RIX1 =~                                             
    fatherinv01_T1    1.000                           
    fatherinv01_T2    1.000                           
    fatherinv01_T3    1.000                           
  RIX2 =~                                             
    fatherinv02_T1    1.000                           
    fatherinv02_T2    1.000                           
    fatherinv02_T3    1.000                           
  RIX3 =~                                             
    fatherinv03_T1    1.000                           
    fatherinv03_T2    1.000                           
    fatherinv03_T3    1.000                           
  RIX4 =~                                             
    fatherinv04_T1    1.000                           
    fatherinv04_T2    1.000                           
 [ 達到了 getOption("max.print") -- 省略最後 54 列 ]]

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  WFX2 ~                                              
    WFX1              0.246    0.067    3.680    0.000
    WFY1             -0.007    0.110   -0.066    0.948
  WFY2 ~                                              
    WFX1              0.070    0.074    0.952    0.341
    WFY1              0.385    0.144    2.670    0.008
  WFX3 ~                                              
    WFX2              0.315    0.052    6.062    0.000
    WFY2              0.034    0.063    0.541    0.589
  WFY3 ~                                              
    WFX2             -0.024    0.049   -0.492    0.623
    WFY2              0.519    0.074    6.984    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
  WFX1 ~~                                             
    WFY1              0.037    0.024    1.573    0.116
 .WFX2 ~~                                             
   .WFY2              0.023    0.018    1.249    0.212
 .WFX3 ~~                                             
   .WFY3              0.032    0.013    2.503    0.012
  RIX1 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
  RIX2 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
  RIX3 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
 [ 達到了 getOption("max.print") -- 省略最後 62 列 ]]

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .fatherinv01_T1    0.000                           
   .fatherinv01_T2    0.000                           
   .fatherinv01_T3    0.000                           
   .fatherinv02_T1    0.000                           
   .fatherinv02_T2    0.000                           
   .fatherinv02_T3    0.000                           
   .fatherinv03_T1    0.000                           
   .fatherinv03_T2    0.000                           
   .fatherinv03_T3    0.000                           
   .fatherinv04_T1    0.000                           
   .fatherinv04_T2    0.000                           
   .fatherinv04_T3    0.000                           
   .fatherinv05_T1    0.000                           
   .fatherinv05_T2    0.000                           
   .fatherinv05_T3    0.000                           
 [ 達到了 getOption("max.print") -- 省略最後 27 列 ]]

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)
    fthrnv01_T1|t1   -1.313    0.044  -29.989    0.000
    fthrnv01_T1|t2   -0.579    0.034  -17.238    0.000
    fthrnv01_T1|t3    0.196    0.032    6.168    0.000
    fthrnv01_T2|t1   -1.269    0.043  -29.637    0.000
    fthrnv01_T2|t2   -0.566    0.033  -16.894    0.000
    fthrnv01_T2|t3    0.128    0.032    4.055    0.000
    fthrnv01_T3|t1   -1.265    0.043  -29.606    0.000
    fthrnv01_T3|t2   -0.581    0.034  -17.287    0.000
    fthrnv01_T3|t3    0.103    0.032    3.249    0.001
    fthrnv02_T1|t1   -1.458    0.047  -30.759    0.000
    fthrnv02_T1|t2   -0.531    0.033  -15.958    0.000
    fthrnv02_T1|t3    0.343    0.032   10.634    0.000
    fthrnv02_T2|t1   -1.468    0.048  -30.788    0.000
    fthrnv02_T2|t2   -0.522    0.033  -15.711    0.000
    fthrnv02_T2|t3    0.295    0.032    9.181    0.000
 [ 達到了 getOption("max.print") -- 省略最後 75 列 ]]

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .fatherinv01_T1    0.187                           
   .fatherinv01_T2    0.145                           
   .fatherinv01_T3    0.183                           
   .fatherinv02_T1    0.095                           
   .fatherinv02_T2    0.081                           
   .fatherinv02_T3    0.085                           
   .fatherinv03_T1    0.120                           
   .fatherinv03_T2    0.137                           
   .fatherinv03_T3    0.106                           
   .fatherinv04_T1    0.147                           
   .fatherinv04_T2    0.134                           
   .fatherinv04_T3    0.131                           
   .fatherinv05_T1    0.147                           
   .fatherinv05_T2    0.113                           
   .fatherinv05_T3    0.133                           
 [ 達到了 getOption("max.print") -- 省略最後 27 列 ]]

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)
    fatherinv01_T1    1.000                           
    fatherinv01_T2    1.000                           
    fatherinv01_T3    1.000                           
    fatherinv02_T1    1.000                           
    fatherinv02_T2    1.000                           
    fatherinv02_T3    1.000                           
    fatherinv03_T1    1.000                           
    fatherinv03_T2    1.000                           
    fatherinv03_T3    1.000                           
    fatherinv04_T1    1.000                           
    fatherinv04_T2    1.000                           
    fatherinv04_T3    1.000                           
    fatherinv05_T1    1.000                           
    fatherinv05_T2    1.000                           
    fatherinv05_T3    1.000                           
 [ 達到了 getOption("max.print") -- 省略最後 12 列 ]]

3 MOM

RICLPM2 <- '
  
  ################
  # BETWEEN PART #
  ################
  
  # Create between factors (random intercepts) for each indicator separately
  RIX1 =~ 1*motherinvo01_T1 + 1*motherinvo01_T2 + 1*motherinvo01_T3
  RIX2 =~ 1*motherinvo02_T1 + 1*motherinvo02_T2 + 1*motherinvo02_T3
  RIX3 =~ 1*motherinvo03_T1 + 1*motherinvo03_T2 + 1*motherinvo03_T3
  RIX4 =~ 1*motherinvo04_T1 + 1*motherinvo04_T2 + 1*motherinvo04_T3
  RIX5 =~ 1*motherinvo05_T1 + 1*motherinvo05_T2 + 1*motherinvo05_T3

  RIY1 =~ 1*socc02_T1 + 1*socc02_T2 + 1*socc02_T3
  RIY2 =~ 1*socc03_T1 + 1*socc03_T2 + 1*socc03_T3
  RIY3 =~ 1*socc09_T1 + 1*socc09_T2 + 1*socc09_T3
  RIY4 =~ 1*socc10_T1 + 1*socc10_T2 + 1*socc10_T3
  
  ##################################
  # WITHIN PART: MEASUREMENT MODEL #
  ##################################
  
  # Factor models for X at 3 waves
  WFX1 =~ motherinvo01_T1 + motherinvo02_T1 + motherinvo03_T1 + motherinvo04_T1 + motherinvo05_T1
  WFX2 =~ motherinvo01_T2 + motherinvo02_T2 + motherinvo03_T2 + motherinvo04_T2 + motherinvo05_T2
  WFX3 =~ motherinvo01_T3 + motherinvo02_T3 + motherinvo03_T3 + motherinvo04_T3 + motherinvo05_T3

  # Factor models for Y at 3 waves
  WFY1 =~ socc02_T1 + socc03_T1 + socc09_T1 + socc10_T1
  WFY2 =~ socc02_T2 + socc03_T2 + socc09_T2 + socc10_T2
  WFY3 =~ socc02_T3 + socc03_T3 + socc09_T3 + socc10_T3

  #########################
  # WITHIN PART: DYNAMICS #
  #########################
  
  # Specify lagged effects between within-person centered latent variables
  WFX2 + WFY2 ~ WFX1 + WFY1
  WFX3 + WFY3 ~ WFX2 + WFY2

  # Estimate correlations within same wave
  WFX1 ~~ WFY1
  WFX2 ~~ WFY2
  WFX3 ~~ WFY3 
  
  ##########################
  # ADDITIONAL CONSTRAINTS #
  ##########################
  
  # Constrain covariance of between factors and exogenous within factors to 0 
  RIX1 + RIX2 + RIX3 + RIX4 + RIX5 + RIY1 + RIY2 + RIY3 + RIY4 ~~ 0*WFY1 + 0*WFX1
'

rst.2 <- cfa(RICLPM2, data = dta.l, ordered = names(dta.l)[9:77], estimator = 'wlsmv')

summary(rst.2, fit.measures = T)
lavaan 0.6-12 ended normally after 121 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                       173

  Number of observations                          1575

Model Test User Model:
                                              Standard      Robust
  Test Statistic                               139.991     271.808
  Degrees of freedom                               268         268
  P-value (Chi-square)                           1.000       0.424
  Scaling correction factor                                  0.931
  Shift parameter                                          121.447
    simple second-order correction                                

Model Test Baseline Model:

  Test statistic                            220659.560   79179.169
  Degrees of freedom                               351         351
  P-value                                        0.000       0.000
  Scaling correction factor                                  2.795

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000       1.000
  Tucker-Lewis Index (TLI)                       1.001       1.000
                                                                  
  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.000       0.003
  90 Percent confidence interval - lower         0.000       0.000
  90 Percent confidence interval - upper         0.000       0.011
  P-value RMSEA <= 0.05                          1.000       1.000
                                                                  
  Robust RMSEA                                                  NA
  90 Percent confidence interval - lower                     0.000
  90 Percent confidence interval - upper                        NA

Standardized Root Mean Square Residual:

  SRMR                                           0.022       0.022

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  RIX1 =~                                             
    motherinv01_T1    1.000                           
    motherinv01_T2    1.000                           
    motherinv01_T3    1.000                           
  RIX2 =~                                             
    motherinv02_T1    1.000                           
    motherinv02_T2    1.000                           
    motherinv02_T3    1.000                           
  RIX3 =~                                             
    motherinv03_T1    1.000                           
    motherinv03_T2    1.000                           
    motherinv03_T3    1.000                           
  RIX4 =~                                             
    motherinv04_T1    1.000                           
    motherinv04_T2    1.000                           
 [ 達到了 getOption("max.print") -- 省略最後 54 列 ]]

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  WFX2 ~                                              
    WFX1              0.173    0.075    2.288    0.022
    WFY1              0.099    0.148    0.673    0.501
  WFY2 ~                                              
    WFX1              0.020    0.062    0.319    0.750
    WFY1              0.364    0.153    2.376    0.017
  WFX3 ~                                              
    WFX2              0.199    0.075    2.643    0.008
    WFY2              0.129    0.088    1.466    0.143
  WFY3 ~                                              
    WFX2             -0.018    0.051   -0.365    0.715
    WFY2              0.466    0.071    6.539    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
  WFX1 ~~                                             
    WFY1              0.070    0.036    1.955    0.051
 .WFX2 ~~                                             
   .WFY2              0.032    0.025    1.279    0.201
 .WFX3 ~~                                             
   .WFY3              0.053    0.019    2.748    0.006
  RIX1 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
  RIX2 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
  RIX3 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
 [ 達到了 getOption("max.print") -- 省略最後 62 列 ]]

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .motherinv01_T1    0.000                           
   .motherinv01_T2    0.000                           
   .motherinv01_T3    0.000                           
   .motherinv02_T1    0.000                           
   .motherinv02_T2    0.000                           
   .motherinv02_T3    0.000                           
   .motherinv03_T1    0.000                           
   .motherinv03_T2    0.000                           
   .motherinv03_T3    0.000                           
   .motherinv04_T1    0.000                           
   .motherinv04_T2    0.000                           
   .motherinv04_T3    0.000                           
   .motherinv05_T1    0.000                           
   .motherinv05_T2    0.000                           
   .motherinv05_T3    0.000                           
 [ 達到了 getOption("max.print") -- 省略最後 27 列 ]]

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)
    mthrnv01_T1|t1   -2.669    0.137  -19.489    0.000
    mthrnv01_T1|t2   -1.902    0.064  -29.598    0.000
    mthrnv01_T1|t3   -1.026    0.038  -26.693    0.000
    mthrnv01_T2|t1   -2.729    0.147  -18.530    0.000
    mthrnv01_T2|t2   -1.975    0.068  -28.970    0.000
    mthrnv01_T2|t3   -1.065    0.039  -27.271    0.000
    mthrnv01_T3|t1   -2.729    0.147  -18.530    0.000
    mthrnv01_T3|t2   -1.975    0.068  -28.970    0.000
    mthrnv01_T3|t3   -1.056    0.039  -27.149    0.000
    mthrnv02_T1|t1   -2.669    0.137  -19.489    0.000
    mthrnv02_T1|t2   -1.856    0.062  -29.943    0.000
    mthrnv02_T1|t3   -0.842    0.036  -23.370    0.000
    mthrnv02_T2|t1   -2.802    0.161  -17.387    0.000
    mthrnv02_T2|t2   -1.964    0.068  -29.072    0.000
    mthrnv02_T2|t3   -0.924    0.037  -24.960    0.000
 [ 達到了 getOption("max.print") -- 省略最後 75 列 ]]

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .motherinv01_T1    0.048                           
   .motherinv01_T2    0.103                           
   .motherinv01_T3    0.083                           
   .motherinv02_T1    0.042                           
   .motherinv02_T2    0.024                           
   .motherinv02_T3    0.060                           
   .motherinv03_T1    0.066                           
   .motherinv03_T2    0.029                           
   .motherinv03_T3    0.062                           
   .motherinv04_T1    0.073                           
   .motherinv04_T2    0.018                           
   .motherinv04_T3    0.081                           
   .motherinv05_T1    0.063                           
   .motherinv05_T2    0.128                           
   .motherinv05_T3    0.130                           
 [ 達到了 getOption("max.print") -- 省略最後 27 列 ]]

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)
    motherinv01_T1    1.000                           
    motherinv01_T2    1.000                           
    motherinv01_T3    1.000                           
    motherinv02_T1    1.000                           
    motherinv02_T2    1.000                           
    motherinv02_T3    1.000                           
    motherinv03_T1    1.000                           
    motherinv03_T2    1.000                           
    motherinv03_T3    1.000                           
    motherinv04_T1    1.000                           
    motherinv04_T2    1.000                           
    motherinv04_T3    1.000                           
    motherinv05_T1    1.000                           
    motherinv05_T2    1.000                           
    motherinv05_T3    1.000                           
 [ 達到了 getOption("max.print") -- 省略最後 12 列 ]]

4 DESCIPLINE

RICLPM3 <- '
  
  ################
  # BETWEEN PART #
  ################
  
  # Create between factors (random intercepts) for each indicator separately
  RIX1 =~ 1*famedu01_T1 + 1*famedu01_T2 + 1*famedu01_T3
  RIX2 =~ 1*famedu02_T1 + 1*famedu02_T2 + 1*famedu02_T3
  RIX3 =~ 1*famedu03_T1 + 1*famedu03_T2 + 1*famedu03_T3

  RIY1 =~ 1*socc02_T1 + 1*socc02_T2 + 1*socc02_T3
  RIY2 =~ 1*socc03_T1 + 1*socc03_T2 + 1*socc03_T3
  RIY3 =~ 1*socc09_T1 + 1*socc09_T2 + 1*socc09_T3
  RIY4 =~ 1*socc10_T1 + 1*socc10_T2 + 1*socc10_T3
  
  ##################################
  # WITHIN PART: MEASUREMENT MODEL #
  ##################################
  
  # Factor models for X at 3 waves
  WFX1 =~ famedu01_T1 + famedu02_T1 + famedu03_T1
  WFX2 =~ famedu01_T2 + famedu02_T2 + famedu03_T2
  WFX3 =~ famedu01_T3 + famedu02_T3 + famedu03_T3

  # Factor models for Y at 3 waves
  WFY1 =~ socc02_T1 + socc03_T1 + socc09_T1 + socc10_T1
  WFY2 =~ socc02_T2 + socc03_T2 + socc09_T2 + socc10_T2
  WFY3 =~ socc02_T3 + socc03_T3 + socc09_T3 + socc10_T3

  #########################
  # WITHIN PART: DYNAMICS #
  #########################
  
  # Specify lagged effects between within-person centered latent variables
  WFX2 + WFY2 ~ WFX1 + WFY1
  WFX3 + WFY3 ~ WFX2 + WFY2

  # Estimate correlations within same wave
  WFX1 ~~ WFY1
  WFX2 ~~ WFY2
  WFX3 ~~ WFY3 
  
  ##########################
  # ADDITIONAL CONSTRAINTS #
  ##########################
  
  # Constrain covariance of between factors and exogenous within factors to 0 
  RIX1 + RIX2 + RIX3 + RIY1 + RIY2 + RIY3 + RIY4 ~~ 0*WFY1 + 0*WFX1
'

rst.3 <- cfa(RICLPM3, data = dta.l, ordered = names(dta.l)[9:77], estimator = 'wlsmv')

summary(rst.3, fit.measures = T)
lavaan 0.6-12 ended normally after 114 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                       132

  Number of observations                          1575

Model Test User Model:
                                              Standard      Robust
  Test Statistic                               108.422     168.520
  Degrees of freedom                               150         150
  P-value (Chi-square)                           0.996       0.143
  Scaling correction factor                                  0.802
  Shift parameter                                           33.289
    simple second-order correction                                

Model Test Baseline Model:

  Test statistic                             26186.682   14975.234
  Degrees of freedom                               210         210
  P-value                                        0.000       0.000
  Scaling correction factor                                  1.759

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000       0.999
  Tucker-Lewis Index (TLI)                       1.002       0.998
                                                                  
  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.000       0.009
  90 Percent confidence interval - lower         0.000       0.000
  90 Percent confidence interval - upper         0.000       0.015
  P-value RMSEA <= 0.05                          1.000       1.000
                                                                  
  Robust RMSEA                                                  NA
  90 Percent confidence interval - lower                     0.000
  90 Percent confidence interval - upper                        NA

Standardized Root Mean Square Residual:

  SRMR                                           0.020       0.020

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  RIX1 =~                                             
    famedu01_T1       1.000                           
    famedu01_T2       1.000                           
    famedu01_T3       1.000                           
  RIX2 =~                                             
    famedu02_T1       1.000                           
    famedu02_T2       1.000                           
    famedu02_T3       1.000                           
  RIX3 =~                                             
    famedu03_T1       1.000                           
    famedu03_T2       1.000                           
    famedu03_T3       1.000                           
  RIY1 =~                                             
    socc02_T1         1.000                           
    socc02_T2         1.000                           
 [ 達到了 getOption("max.print") -- 省略最後 40 列 ]]

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  WFX2 ~                                              
    WFX1              0.083    0.137    0.608    0.543
    WFY1             -0.177    0.120   -1.478    0.139
  WFY2 ~                                              
    WFX1             -0.378    0.129   -2.942    0.003
    WFY1              0.393    0.134    2.940    0.003
  WFX3 ~                                              
    WFX2              0.339    0.064    5.303    0.000
    WFY2             -0.114    0.066   -1.733    0.083
  WFY3 ~                                              
    WFX2             -0.104    0.056   -1.849    0.064
    WFY2              0.492    0.070    7.021    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
  WFX1 ~~                                             
    WFY1              0.001    0.023    0.035    0.972
 .WFX2 ~~                                             
   .WFY2             -0.016    0.021   -0.747    0.455
 .WFX3 ~~                                             
   .WFY3              0.014    0.014    1.011    0.312
  RIX1 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
  RIX2 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
  RIX3 ~~                                             
    WFY1              0.000                           
    WFX1              0.000                           
 [ 達到了 getOption("max.print") -- 省略最後 39 列 ]]

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .famedu01_T1       0.000                           
   .famedu01_T2       0.000                           
   .famedu01_T3       0.000                           
   .famedu02_T1       0.000                           
   .famedu02_T2       0.000                           
   .famedu02_T3       0.000                           
   .famedu03_T1       0.000                           
   .famedu03_T2       0.000                           
   .famedu03_T3       0.000                           
   .socc02_T1         0.000                           
   .socc02_T2         0.000                           
   .socc02_T3         0.000                           
   .socc03_T1         0.000                           
   .socc03_T2         0.000                           
   .socc03_T3         0.000                           
 [ 達到了 getOption("max.print") -- 省略最後 19 列 ]]

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)
    famedu01_T1|t1   -1.431    0.047  -30.661    0.000
    famedu01_T1|t2    0.211    0.032    6.620    0.000
    famedu01_T1|t3    1.662    0.054   30.845    0.000
    famedu01_T2|t1   -1.496    0.048  -30.861    0.000
    famedu01_T2|t2    0.055    0.032    1.738    0.082
    famedu01_T2|t3    1.715    0.056   30.689    0.000
    famedu01_T3|t1   -1.536    0.050  -30.926    0.000
    famedu01_T3|t2   -0.025    0.032   -0.781    0.435
    famedu01_T3|t3    1.608    0.052   30.932    0.000
    famedu02_T1|t1   -1.418    0.046  -30.606    0.000
    famedu02_T1|t2    0.141    0.032    4.457    0.000
    famedu02_T1|t3    1.722    0.056   30.663    0.000
    famedu02_T2|t1   -1.482    0.048  -30.827    0.000
    famedu02_T2|t2    0.130    0.032    4.105    0.000
    famedu02_T2|t3    1.821    0.060   30.168    0.000
 [ 達到了 getOption("max.print") -- 省略最後 57 列 ]]

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .famedu01_T1       0.413                           
   .famedu01_T2       0.255                           
   .famedu01_T3       0.232                           
   .famedu02_T1       0.249                           
   .famedu02_T2       0.153                           
   .famedu02_T3       0.177                           
   .famedu03_T1       0.479                           
   .famedu03_T2       0.464                           
   .famedu03_T3       0.392                           
   .socc02_T1         0.455                           
   .socc02_T2         0.355                           
   .socc02_T3         0.429                           
   .socc03_T1         0.670                           
   .socc03_T2         0.570                           
   .socc03_T3         0.552                           
 [ 達到了 getOption("max.print") -- 省略最後 19 列 ]]

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)
    famedu01_T1       1.000                           
    famedu01_T2       1.000                           
    famedu01_T3       1.000                           
    famedu02_T1       1.000                           
    famedu02_T2       1.000                           
    famedu02_T3       1.000                           
    famedu03_T1       1.000                           
    famedu03_T2       1.000                           
    famedu03_T3       1.000                           
    socc02_T1         1.000                           
    socc02_T2         1.000                           
    socc02_T3         1.000                           
    socc03_T1         1.000                           
    socc03_T2         1.000                           
    socc03_T3         1.000                           
 [ 達到了 getOption("max.print") -- 省略最後 6 列 ]]