#Load in Packages

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(lavaan)
## This is lavaan 0.6-21
## lavaan is FREE software! Please report any bugs.
library(ggplot2)

library(corrplot)
## corrplot 0.95 loaded
library(ggcorrplot)

library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## The following object is masked from 'package:lavaan':
## 
##     cor2cov
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ lubridate 1.9.5     ✔ tibble    3.3.1
## ✔ purrr     1.2.1     ✔ tidyr     1.3.2
## ✔ readr     2.2.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ psych::%+%()    masks ggplot2::%+%()
## ✖ psych::alpha()  masks ggplot2::alpha()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

#Read in Data

setwd("~/Downloads/foldah")

ANES <- read.csv("ANES_merged.csv")

#Recode Missing Codes to NA

ANES <- ANES %>%
  mutate(across(
    .cols = starts_with("V2"),
    .fns = ~replace(., . %in% c(-9, -8, -7, -6, -5, -4, -2, -1), NA)
  ))

ANES <- ANES %>%
  mutate(across(
    .cols = starts_with("V1"),
    .fns = ~replace(., . %in% c(-9, -8, -7, -6, -5, -4, -2, -1), NA)
  ))

#Critical Reflection Scale

ANES$CR_slav_w1 <- dplyr::recode(ANES$V162212,
                                         `1` = 5,
                                         `2` = 4,
                                         `3` = 3,
                                         `4` = 2,
                                         `5` = 1)

ANES$CR_wrk_w1 <- ANES$V162214


ANES$CR_slav_w2 <- dplyr::recode(ANES$V202301,
                                         `1` = 5,
                                         `2` = 4,
                                         `3` = 3,
                                         `4` = 2,
                                         `5` = 1)


ANES$CR_wrk_w2 <- ANES$V202303

ANES$CR_slav_w3 <- dplyr::recode(ANES$V242301,
                                         `1` = 5,
                                         `2` = 4,
                                         `3` = 3,
                                         `4` = 2,
                                         `5` = 1)

ANES$CR_wrk_w3 <-ANES$V242303


ANES$c_ref_w1 <- ((ANES$CR_wrk_w1 + ANES$CR_slav_w1)/2)

ANES$c_ref_w2 <- ((ANES$CR_wrk_w2 + ANES$CR_slav_w2)/2)

ANES$c_ref_w3 <- ((ANES$CR_wrk_w3 + ANES$CR_slav_w3)/2)

#Critical Action Scale

ANES$CA_rep_w1 <- ifelse(ANES$V162019 == 1, 1, 0)

ANES$CA_pro_w1 <- ifelse(ANES$V162018a == 1, 1, 0)

ANES$CA_org_w1 <- ifelse(ANES$V162195 == 1, 1, 0)

ANES$CA_mtn_w1 <- ifelse(ANES$V162196 == 1, 1, 0)



ANES$CA_rep_w2 <- ifelse(ANES$V202030 == 1, 1, 0)

ANES$CA_pro_w2 <- ifelse(ANES$V202025 == 1, 1, 0)

ANES$CA_org_w2 <- ifelse(ANES$V202031 == 1, 1, 0)

ANES$CA_mtn_w2 <- ifelse(ANES$V202032 == 1, 1, 0)



ANES$CA_rep_w3 <- ifelse(ANES$V242036 == 1, 1, 0)

ANES$CA_pro_w3 <- ifelse(ANES$V242029 == 1, 1, 0)

ANES$CA_mtn_w3 <- ifelse(ANES$V242034 == 1, 1, 0)




ANES$c_act_w1 <- ((ANES$CA_org_w1 + ANES$CA_mtn_w1 + ANES$CA_pro_w1 + ANES$CA_rep_w1)/4)

ANES$c_act_w2 <- ((ANES$CA_org_w2 + ANES$CA_mtn_w2 + ANES$CA_pro_w2 + ANES$CA_rep_w2)/4)

ANES$c_act_w3 <- ((ANES$CA_mtn_w3 + ANES$CA_pro_w3 + ANES$CA_rep_w3)/3)

#External Efficacy Scale

ANES$EPE_care_w1 <- ANES$V162215

ANES$EPE_say_w1 <- ANES$V162216


ANES$EPE_say_w2 <- ANES$V202213

ANES$EPE_care_w2 <- ANES$V202212



ANES$EPE_say_w3 <- ANES$V242201

ANES$EPE_care_w3 <- ANES$V242200



ANES$ex_eff_w1 <- ((ANES$EPE_say_w1 + ANES$EPE_care_w1)/2)

ANES$ex_eff_w2 <- ((ANES$EPE_say_w2 + ANES$EPE_care_w2)/2)

ANES$ex_eff_w3 <- ((ANES$EPE_say_w3 + ANES$EPE_care_w3)/2)

#Internal Efficacy Scale

ANES$IPE_comp_w1 <- ANES$V162217

ANES$IPE_und_w1 <- dplyr::recode(ANES$V162218,
                                         `1` = 5,
                                         `2` = 4,
                                         `3` = 3,
                                         `4` = 2,
                                         `5` = 1)


ANES$IPE_comp_w2 <- ANES$V202214

ANES$IPE_und_w2 <- dplyr::recode(ANES$V202215,
                                         `1` = 5,
                                         `2` = 4,
                                         `3` = 3,
                                         `4` = 2,
                                         `5` = 1)



ANES$IPE_comp_w3 <- ANES$V242202
ANES$IPE_und_w3 <- dplyr::recode(ANES$V242203,
                                         `1` = 5,
                                         `2` = 4,
                                         `3` = 3,
                                         `4` = 2,
                                         `5` = 1)



ANES$in_eff_w1 <- ((ANES$IPE_und_w1 + ANES$IPE_comp_w1)/2)

ANES$in_eff_w2 <- ((ANES$IPE_und_w2 + ANES$IPE_comp_w2)/2)

ANES$in_eff_w3 <- ((ANES$IPE_und_w3 + ANES$IPE_comp_w3)/2)

#Demographic Variables

ANES$Black <- ifelse(ANES$V201549x == 2, 1, 0)

ANES$White <- ifelse(ANES$V201549x == 1, 1, 0)

ANES$Hispanic <- ifelse(ANES$V201549x == 3, 1, 0)

ANES$Asian <- ifelse(ANES$V201549x == 4, 1, 0)

ANES$Native <- ifelse(ANES$V201549x == 5, 1, 0)

ANES$Other <- ifelse(ANES$V201549x == 6, 1, 0)

ANES$Female <- ifelse(ANES$V201600 == 2, 1, 0)

ANES$Age <- ANES$V161267

#Mean Split Variables for Moderation Analysis

ANES$in_eff_ms_w2 <- ifelse(ANES$in_eff_w2 > mean(ANES$in_eff_w2, na.rm = TRUE), 1, 0)

ANES$ex_eff_ms_w2 <- ifelse(ANES$ex_eff_w2 > mean(ANES$ex_eff_w2, na.rm = TRUE), 1, 0)

#Removing Empty Weight Cases

ANES_clean <- subset(ANES, !is.na(V240106b))

#Finding demographics of analytic sampe

mean(ANES_clean$Age[!is.na(ANES_clean$Age)])
## [1] 49.16766
mean(ANES_clean$Black[!is.na(ANES_clean$Black)])
## [1] 0.07846004
mean(ANES_clean$White[!is.na(ANES_clean$White)])
## [1] 0.7490253
mean(ANES_clean$Hispanic[!is.na(ANES_clean$Hispanic)])
## [1] 0.08966862
mean(ANES_clean$Asian[!is.na(ANES_clean$Asian)])
## [1] 0.03021442
mean(ANES_clean$Native[!is.na(ANES_clean$Native)])
## [1] 0.01998051
mean(ANES_clean$Other[!is.na(ANES_clean$Other)])
## [1] 0.03265107
mean(ANES_clean$Female[!is.na(ANES_clean$Female)])
## [1] 0.5406326

#Predictors of Missing Weights?

ANES$V240106b_missing <- ifelse(is.na(ANES$V240106b), 1, 0)


model <- lm(V240106b_missing ~ Black + Female + White + Asian + Native + Other + Age, data = ANES)
summary(model)
## 
## Call:
## lm(formula = V240106b_missing ~ Black + Female + White + Asian + 
##     Native + Other + Age, data = ANES)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.08189 -0.04860 -0.04500 -0.04101  0.96425 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  0.0548477  0.0200022   2.742  0.00616 **
## Black        0.0077297  0.0224986   0.344  0.73121   
## Female      -0.0046571  0.0092338  -0.504  0.61406   
## White        0.0043850  0.0163980   0.267  0.78918   
## Asian        0.0271410  0.0315729   0.860  0.39009   
## Native       0.0316348  0.0362262   0.873  0.38262   
## Other       -0.0132713  0.0298458  -0.445  0.65661   
## Age         -0.0002295  0.0002860  -0.803  0.42230   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2096 on 2082 degrees of freedom
##   (81 observations deleted due to missingness)
## Multiple R-squared:  0.001341,   Adjusted R-squared:  -0.002016 
## F-statistic: 0.3994 on 7 and 2082 DF,  p-value: 0.9031

#RICLPM IPE + CA

RICLPM1 <- '
  # Create between components (random intercepts)
  RIipe =~ 1*in_eff_w1 + 1*in_eff_w2 + 1*in_eff_w3 
  RIca =~ 1*c_act_w1 + 1*c_act_w2 + 1*c_act_w3 
  
  # Create within-person centered variables
  wipe1 =~ 1*in_eff_w1
  wipe2 =~ 1*in_eff_w2
  wipe3 =~ 1*in_eff_w3 

  wca1 =~ 1*c_act_w1
  wca2 =~ 1*c_act_w2
  wca3 =~ 1*c_act_w3
# Estimate lagged effects between within-person centered variables
  wipe2 + wca2 ~ wipe1 + wca1
  wipe3 + wca3 ~ wipe2 + wca2
  
  # Estimate covariance between within-person centered variables at first wave
  wipe1 ~~ wca1 # Covariance
  
  # Estimate covariances between residuals of within-person centered variables
  # (i.e., innovations)
  wipe2 ~~ wca2
  wipe3 ~~ wca3
  
  # Estimate variance and covariance of random intercepts
  RIipe ~~ RIipe
  RIca ~~ RIca
  RIipe ~~ RIca
  
  # Estimate (residual) variance of within-person centered variables
  wipe1 ~~ wipe1 # Variances
  wca1 ~~ wca1 
  wipe2 ~~ wipe2 # Residual variances
  wca2 ~~ wca2 
  wipe3 ~~ wipe3 
  wca3 ~~ wca3'

RICLPM1fit <- lavaan(RICLPM1, 
  data = ANES_clean, 
  missing = 'FIML',
  sampling.weights = 'V240106b',
  estimator = "MLR",
  meanstructure = T, 
  int.ov.free = T)

summary(RICLPM1fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-21 ended normally after 73 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        26
## 
##   Number of observations                          2070
##   Number of missing patterns                        12
##   Sampling weights variable                   V240106b
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.486       0.313
##   Degrees of freedom                                 1           1
##   P-value (Chi-square)                           0.486       0.576
##   Scaling correction factor                                  1.553
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              2871.247    1379.513
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.081
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.003       1.008
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.006
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5534.689   -5534.689
##   Scaling correction factor                                  2.265
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -5534.446   -5534.446
##   Scaling correction factor                                  2.239
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               11121.378   11121.378
##   Bayesian (BIC)                             11267.895   11267.895
##   Sample-size adjusted Bayesian (SABIC)      11185.291   11185.291
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.051       0.036
##   P-value H_0: RMSEA <= 0.050                    0.944       0.991
##   P-value H_0: RMSEA >= 0.080                    0.002       0.000
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.060
##   P-value H_0: Robust RMSEA <= 0.050                         0.905
##   P-value H_0: Robust RMSEA >= 0.080                         0.009
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.003       0.003
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIipe =~                                                              
##     in_eff_w1         1.000                               0.548    0.693
##     in_eff_w2         1.000                               0.548    0.645
##     in_eff_w3         1.000                               0.548    0.659
##   RIca =~                                                               
##     c_act_w1          1.000                               0.112    0.447
##     c_act_w2          1.000                               0.112    0.469
##     c_act_w3          1.000                               0.112    0.627
##   wipe1 =~                                                              
##     in_eff_w1         1.000                               0.571    0.721
##   wipe2 =~                                                              
##     in_eff_w2         1.000                               0.650    0.764
##   wipe3 =~                                                              
##     in_eff_w3         1.000                               0.626    0.752
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.224    0.894
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.211    0.883
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.139    0.779
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wipe2 ~                                                               
##     wipe1             0.146    0.073    1.987    0.047    0.128    0.128
##     wca1              0.403    0.122    3.308    0.001    0.139    0.139
##   wca2 ~                                                                
##     wipe1             0.046    0.015    3.061    0.002    0.126    0.126
##     wca1              0.251    0.041    6.056    0.000    0.266    0.266
##   wipe3 ~                                                               
##     wipe2             0.325    0.048    6.769    0.000    0.338    0.338
##     wca2              0.358    0.115    3.120    0.002    0.121    0.121
##   wca3 ~                                                                
##     wipe2             0.013    0.010    1.407    0.159    0.063    0.063
##     wca2              0.029    0.048    0.603    0.546    0.044    0.044
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wipe1 ~~                                                              
##     wca1              0.030    0.006    4.804    0.000    0.233    0.233
##  .wipe2 ~~                                                              
##    .wca2              0.018    0.005    3.690    0.000    0.142    0.142
##  .wipe3 ~~                                                              
##    .wca3              0.011    0.004    2.628    0.009    0.134    0.134
##   RIipe ~~                                                              
##     RIca              0.017    0.005    3.795    0.000    0.283    0.283
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .in_eff_w1         3.142    0.024  132.679    0.000    3.142    3.970
##    .in_eff_w2         3.259    0.026  124.842    0.000    3.259    3.831
##    .in_eff_w3         3.263    0.025  128.357    0.000    3.263    3.920
##    .c_act_w1          0.192    0.007   26.905    0.000    0.192    0.768
##    .c_act_w2          0.159    0.007   23.009    0.000    0.159    0.665
##    .c_act_w3          0.078    0.005   14.840    0.000    0.078    0.437
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIipe             0.301    0.029   10.369    0.000    1.000    1.000
##     RIca              0.013    0.002    5.759    0.000    1.000    1.000
##     wipe1             0.326    0.028   11.598    0.000    1.000    1.000
##     wca1              0.050    0.003   17.213    0.000    1.000    1.000
##    .wipe2             0.405    0.032   12.649    0.000    0.956    0.956
##    .wca2              0.040    0.003   15.625    0.000    0.898    0.898
##    .wipe3             0.335    0.019   17.451    0.000    0.855    0.855
##    .wca3              0.019    0.003    6.048    0.000    0.993    0.993
##    .in_eff_w1         0.000                               0.000    0.000
##    .in_eff_w2         0.000                               0.000    0.000
##    .in_eff_w3         0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wipe2             0.044
##     wca2              0.102
##     wipe3             0.145
##     wca3              0.007
##     in_eff_w1         1.000
##     in_eff_w2         1.000
##     in_eff_w3         1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
#Extracting covariance matrix
lavInspect(RICLPM1fit, "sampstat")
## $cov
##           in_f_1 in_f_2 in_f_3 c_ct_1 c_ct_2 c_ct_3
## in_eff_w1  0.627                                   
## in_eff_w2  0.361  0.724                            
## in_eff_w3  0.330  0.448  0.693                     
## c_act_w1   0.048  0.043  0.033  0.063              
## c_act_w2   0.040  0.044  0.042  0.026  0.057       
## c_act_w3   0.018  0.024  0.031  0.013  0.014  0.032
## 
## $mean
## in_eff_w1 in_eff_w2 in_eff_w3  c_act_w1  c_act_w2  c_act_w3 
##     3.142     3.259     3.263     0.192     0.159     0.078
#Extracting residual correlation matrix
resid(RICLPM1fit, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##           in_f_1 in_f_2 in_f_3 c_ct_1 c_ct_2 c_ct_3
## in_eff_w1  0.000                                   
## in_eff_w2  0.000  0.000                            
## in_eff_w3  0.002  0.000  0.000                     
## c_act_w1   0.003  0.004  0.012  0.000              
## c_act_w2  -0.001  0.000  0.001  0.000  0.000       
## c_act_w3  -0.005 -0.002  0.000  0.001  0.000  0.000
## 
## $mean
## in_eff_w1 in_eff_w2 in_eff_w3  c_act_w1  c_act_w2  c_act_w3 
##         0         0         0         0         0         0

#RICLPM EPE + CA

RICLPM2 <- '
  # Create between components (random intercepts)
  RIepe =~ 1*ex_eff_w1 + 1*ex_eff_w2 + 1*ex_eff_w3 
  RIca =~ 1*c_act_w1 + 1*c_act_w2 + 1*c_act_w3 
  
  # Create within-person centered variables
  wepe1 =~ 1*ex_eff_w1
  wepe2 =~ 1*ex_eff_w2
  wepe3 =~ 1*ex_eff_w3 

  wca1 =~ 1*c_act_w1
  wca2 =~ 1*c_act_w2
  wca3 =~ 1*c_act_w3
# Estimate lagged effects between within-person centered variables
  wepe2 + wca2 ~ wepe1 + wca1
  wepe3 + wca3 ~ wepe2 + wca2
  
  # Estimate covariance between within-person centered variables at first wave
  wepe1 ~~ wca1 # Covariance
  
  # Estimate covariances between residuals of within-person centered variables
  # (i.e., innovations)
  wepe2 ~~ wca2
  wepe3 ~~ wca3
  
  # Estimate variance and covariance of random intercepts
  RIepe ~~ RIepe
  RIca ~~ RIca
  RIepe ~~ RIca
  
  # Estimate (residual) variance of within-person centered variables
  wepe1 ~~ wepe1 # Variances
  wca1 ~~ wca1 
  wepe2 ~~ wepe2 # Residual variances
  wca2 ~~ wca2 
  wepe3 ~~ wepe3 
  wca3 ~~ wca3'

RICLPM2fit <- lavaan(RICLPM2, 
  data = ANES_clean, 
  missing = 'FIML',
  sampling.weights = 'V240106b',
  estimator = "MLR",
  meanstructure = T, 
  int.ov.free = T)

summary(RICLPM2fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-21 ended normally after 70 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        26
## 
##   Number of observations                          2070
##   Number of missing patterns                        10
##   Sampling weights variable                   V240106b
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 3.828       2.383
##   Degrees of freedom                                 1           1
##   P-value (Chi-square)                           0.050       0.123
##   Scaling correction factor                                  1.607
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1574.648     726.545
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.167
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.998       0.998
##   Tucker-Lewis Index (TLI)                       0.973       0.971
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.999
##   Robust Tucker-Lewis Index (TLI)                            0.980
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -7305.490   -7305.490
##   Scaling correction factor                                  2.243
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -7303.576   -7303.576
##   Scaling correction factor                                  2.220
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               14662.981   14662.981
##   Bayesian (BIC)                             14809.499   14809.499
##   Sample-size adjusted Bayesian (SABIC)      14726.895   14726.895
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.037       0.026
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.079       0.060
##   P-value H_0: RMSEA <= 0.050                    0.625       0.855
##   P-value H_0: RMSEA >= 0.080                    0.046       0.003
##                                                                   
##   Robust RMSEA                                               0.032
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.091
##   P-value H_0: Robust RMSEA <= 0.050                         0.594
##   P-value H_0: Robust RMSEA >= 0.080                         0.102
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.008       0.008
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIepe =~                                                              
##     ex_eff_w1         1.000                               0.543    0.545
##     ex_eff_w2         1.000                               0.543    0.535
##     ex_eff_w3         1.000                               0.543    0.571
##   RIca =~                                                               
##     c_act_w1          1.000                               0.113    0.451
##     c_act_w2          1.000                               0.113    0.474
##     c_act_w3          1.000                               0.113    0.635
##   wepe1 =~                                                              
##     ex_eff_w1         1.000                               0.835    0.838
##   wepe2 =~                                                              
##     ex_eff_w2         1.000                               0.858    0.845
##   wepe3 =~                                                              
##     ex_eff_w3         1.000                               0.781    0.821
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.223    0.892
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.210    0.881
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.137    0.772
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wepe2 ~                                                               
##     wepe1             0.053    0.049    1.089    0.276    0.052    0.052
##     wca1              0.087    0.158    0.554    0.579    0.023    0.023
##   wca2 ~                                                                
##     wepe1            -0.016    0.010   -1.584    0.113   -0.063   -0.063
##     wca1              0.280    0.042    6.602    0.000    0.297    0.297
##   wepe3 ~                                                               
##     wepe2             0.164    0.046    3.588    0.000    0.181    0.181
##     wca2             -0.244    0.170   -1.430    0.153   -0.066   -0.066
##   wca3 ~                                                                
##     wepe2             0.007    0.008    0.980    0.327    0.047    0.047
##     wca2              0.027    0.049    0.563    0.573    0.042    0.042
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wepe1 ~~                                                              
##     wca1              0.013    0.008    1.572    0.116    0.068    0.068
##  .wepe2 ~~                                                              
##    .wca2              0.013    0.007    1.835    0.067    0.076    0.076
##  .wepe3 ~~                                                              
##    .wca3             -0.011    0.005   -2.086    0.037   -0.103   -0.103
##   RIepe ~~                                                              
##     RIca              0.015    0.006    2.508    0.012    0.244    0.244
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ex_eff_w1         2.563    0.030   86.501    0.000    2.563    2.572
##    .ex_eff_w2         2.363    0.030   79.307    0.000    2.363    2.328
##    .ex_eff_w3         2.208    0.028   79.045    0.000    2.208    2.322
##    .c_act_w1          0.192    0.007   26.917    0.000    0.192    0.766
##    .c_act_w2          0.159    0.007   23.008    0.000    0.159    0.665
##    .c_act_w3          0.078    0.005   14.844    0.000    0.078    0.438
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIepe             0.295    0.033    8.908    0.000    1.000    1.000
##     RIca              0.013    0.002    6.064    0.000    1.000    1.000
##     wepe1             0.698    0.040   17.350    0.000    1.000    1.000
##     wca1              0.050    0.003   17.343    0.000    1.000    1.000
##    .wepe2             0.733    0.045   16.121    0.000    0.997    0.997
##    .wca2              0.040    0.003   15.284    0.000    0.910    0.910
##    .wepe3             0.588    0.036   16.375    0.000    0.965    0.965
##    .wca3              0.019    0.003    6.057    0.000    0.996    0.996
##    .ex_eff_w1         0.000                               0.000    0.000
##    .ex_eff_w2         0.000                               0.000    0.000
##    .ex_eff_w3         0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wepe2             0.003
##     wca2              0.090
##     wepe3             0.035
##     wca3              0.004
##     ex_eff_w1         1.000
##     ex_eff_w2         1.000
##     ex_eff_w3         1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
#Extracting covariance matrix
lavInspect(RICLPM2fit, "sampstat")
## $cov
##           ex_f_1 ex_f_2 ex_f_3 c_ct_1 c_ct_2 c_ct_3
## ex_eff_w1  0.994                                   
## ex_eff_w2  0.334  1.030                            
## ex_eff_w3  0.300  0.411  0.902                     
## c_act_w1   0.026  0.018  0.004  0.063              
## c_act_w2   0.008  0.029  0.005  0.026  0.057       
## c_act_w3   0.018  0.021  0.004  0.013  0.014  0.032
## 
## $mean
## ex_eff_w1 ex_eff_w2 ex_eff_w3  c_act_w1  c_act_w2  c_act_w3 
##     2.563     2.363     2.208     0.192     0.159     0.078
#Extracting residual correlation matrix
resid(RICLPM2fit, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##           ex_f_1 ex_f_2 ex_f_3 c_ct_1 c_ct_2 c_ct_3
## ex_eff_w1  0.000                                   
## ex_eff_w2  0.000  0.000                            
## ex_eff_w3 -0.003 -0.001  0.000                     
## c_act_w1  -0.005 -0.008 -0.035  0.000              
## c_act_w2   0.004  0.000 -0.004 -0.001  0.000       
## c_act_w3   0.018  0.003 -0.002  0.002  0.001  0.000
## 
## $mean
## ex_eff_w1 ex_eff_w2 ex_eff_w3  c_act_w1  c_act_w2  c_act_w3 
##         0         0         0         0         0         0

#RICLPM CR + CA

RICLPM3 <- '
  # Create between components (random intercepts)
  RIcr =~ 1*c_ref_w1 + 1*c_ref_w2 + 1*c_ref_w3 
  RIca =~ 1*c_act_w1 + 1*c_act_w2 + 1*c_act_w3 
  
  # Create within-person centered variables
  wcr1 =~ 1*c_ref_w1
  wcr2 =~ 1*c_ref_w2
  wcr3 =~ 1*c_ref_w3 

  wca1 =~ 1*c_act_w1
  wca2 =~ 1*c_act_w2
  wca3 =~ 1*c_act_w3
# Estimate lagged effects between within-person centered variables
  wcr2 + wca2 ~ wcr1 + wca1
  wcr3 + wca3 ~ wcr2 + wca2
  
  # Estimate covariance between within-person centered variables at first wave
  wcr1 ~~ wca1 # Covariance
  
  # Estimate covariances between residuals of within-person centered variables
  # (i.e., innovations)
  wcr2 ~~ wca2
  wcr3 ~~ wca3
  
  # Estimate variance and covariance of random intercepts
  RIcr ~~ RIcr
  RIca ~~ RIca
  RIcr ~~ RIca
  
  # Estimate (residual) variance of within-person centered variables
  wcr1 ~~ wcr1 # Variances
  wca1 ~~ wca1 
  wcr2 ~~ wcr2 # Residual variances
  wca2 ~~ wca2 
  wcr3 ~~ wcr3 
  wca3 ~~ wca3'
RICLPM3fit <- lavaan(RICLPM3, 
  data = ANES_clean, 
  missing = 'FIML',
  sampling.weights = 'V240106b',
  estimator = "MLR",
  meanstructure = T, 
  int.ov.free = T)

summary(RICLPM3fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-21 ended normally after 76 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        26
## 
##   Number of observations                          2070
##   Number of missing patterns                        10
##   Sampling weights variable                   V240106b
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 1.978       1.013
##   Degrees of freedom                                 1           1
##   P-value (Chi-square)                           0.160       0.314
##   Scaling correction factor                                  1.954
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              3830.775    1602.897
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.390
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       0.996       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -7490.719   -7490.719
##   Scaling correction factor                                  2.304
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -7489.729   -7489.729
##   Scaling correction factor                                  2.291
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               15033.437   15033.437
##   Bayesian (BIC)                             15179.955   15179.955
##   Sample-size adjusted Bayesian (SABIC)      15097.351   15097.351
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.022       0.002
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.067       0.044
##   P-value H_0: RMSEA <= 0.050                    0.808       0.977
##   P-value H_0: RMSEA >= 0.080                    0.013       0.000
##                                                                   
##   Robust RMSEA                                               0.006
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.081
##   P-value H_0: Robust RMSEA <= 0.050                         0.736
##   P-value H_0: Robust RMSEA >= 0.080                         0.054
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.006       0.006
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIcr =~                                                               
##     c_ref_w1          1.000                               0.969    0.790
##     c_ref_w2          1.000                               0.969    0.779
##     c_ref_w3          1.000                               0.969    0.802
##   RIca =~                                                               
##     c_act_w1          1.000                               0.113    0.452
##     c_act_w2          1.000                               0.113    0.473
##     c_act_w3          1.000                               0.113    0.632
##   wcr1 =~                                                               
##     c_ref_w1          1.000                               0.751    0.613
##   wcr2 =~                                                               
##     c_ref_w2          1.000                               0.781    0.628
##   wcr3 =~                                                               
##     c_ref_w3          1.000                               0.722    0.598
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.223    0.892
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.210    0.881
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.138    0.775
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr2 ~                                                                
##     wcr1              0.121    0.071    1.704    0.088    0.116    0.116
##     wca1              0.211    0.150    1.411    0.158    0.060    0.060
##   wca2 ~                                                                
##     wcr1              0.049    0.016    3.088    0.002    0.175    0.175
##     wca1              0.260    0.041    6.290    0.000    0.276    0.276
##   wcr3 ~                                                                
##     wcr2              0.174    0.064    2.725    0.006    0.188    0.188
##     wca2              0.593    0.211    2.815    0.005    0.173    0.173
##   wca3 ~                                                                
##     wcr2              0.008    0.009    0.891    0.373    0.047    0.047
##     wca2              0.025    0.048    0.522    0.602    0.038    0.038
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr1 ~~                                                               
##     wca1              0.014    0.008    1.733    0.083    0.086    0.086
##  .wcr2 ~~                                                               
##    .wca2              0.034    0.008    4.182    0.000    0.225    0.225
##  .wcr3 ~~                                                               
##    .wca3              0.009    0.005    1.693    0.090    0.093    0.093
##   RIcr ~~                                                               
##     RIca              0.030    0.007    4.281    0.000    0.277    0.277
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .c_ref_w1          3.023    0.037   82.590    0.000    3.023    2.465
##    .c_ref_w2          3.234    0.036   89.365    0.000    3.234    2.599
##    .c_ref_w3          3.113    0.036   86.139    0.000    3.113    2.576
##    .c_act_w1          0.192    0.007   26.911    0.000    0.192    0.769
##    .c_act_w2          0.159    0.007   23.008    0.000    0.159    0.665
##    .c_act_w3          0.078    0.005   14.840    0.000    0.078    0.437
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIcr              0.939    0.053   17.826    0.000    1.000    1.000
##     RIca              0.013    0.002    6.115    0.000    1.000    1.000
##     wcr1              0.565    0.043   13.166    0.000    1.000    1.000
##     wca1              0.050    0.003   17.431    0.000    1.000    1.000
##    .wcr2              0.598    0.046   12.986    0.000    0.982    0.982
##    .wca2              0.039    0.003   15.441    0.000    0.885    0.885
##    .wcr3              0.479    0.035   13.642    0.000    0.919    0.919
##    .wca3              0.019    0.003    6.168    0.000    0.995    0.995
##    .c_ref_w1          0.000                               0.000    0.000
##    .c_ref_w2          0.000                               0.000    0.000
##    .c_ref_w3          0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wcr2              0.018
##     wca2              0.115
##     wcr3              0.081
##     wca3              0.005
##     c_ref_w1          1.000
##     c_ref_w2          1.000
##     c_ref_w3          1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
#Extracting covariance matrix
lavInspect(RICLPM3fit, "sampstat")
## $cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  1.502                                   
## c_ref_w2  1.009  1.548                            
## c_ref_w3  0.969  1.070  1.461                     
## c_act_w1  0.048  0.047  0.048  0.063              
## c_act_w2  0.061  0.071  0.064  0.026  0.057       
## c_act_w3  0.029  0.035  0.040  0.013  0.014  0.032
## 
## $mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##    3.023    3.234    3.113    0.192    0.159    0.078
#Extracting residual correlation matrix
resid(RICLPM3fit, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  0.000                                   
## c_ref_w2  0.000  0.000                            
## c_ref_w3  0.000  0.000  0.000                     
## c_act_w1  0.012  0.013  0.024  0.000              
## c_act_w2 -0.002  0.000  0.002  0.001  0.000       
## c_act_w3 -0.011 -0.005 -0.003  0.002  0.000  0.000
## 
## $mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##        0        0        0        0        0        0

#RICLPM CR + EPE

RICLPM4 <- '
  # Create between components (random intercepts)
  RIcr =~ 1*c_ref_w1 + 1*c_ref_w2 + 1*c_ref_w3 
  RIepe =~ 1*ex_eff_w1 + 1*ex_eff_w2 + 1*ex_eff_w3 
  
  # Create within-person centered variables
  wcr1 =~ 1*c_ref_w1
  wcr2 =~ 1*c_ref_w2
  wcr3 =~ 1*c_ref_w3 

  wepe1 =~ 1*ex_eff_w1
  wepe2 =~ 1*ex_eff_w2
  wepe3 =~ 1*ex_eff_w3
# Estimate lagged effects between within-person centered variables
  wcr2 + wepe2 ~ wcr1 + wepe1
  wcr3 + wepe3 ~ wcr2 + wepe2
  
  # Estimate covariance between within-person centered variables at first wave
  wcr1 ~~ wepe1 # Covariance
  
  # Estimate covariances between residuals of within-person centered variables
  # (i.e., innovations)
  wcr2 ~~ wepe2
  wcr3 ~~ wepe3
  
  # Estimate variance and covariance of random intercepts
  RIcr ~~ RIcr
  RIepe ~~ RIepe
  RIcr ~~ RIepe
  
  # Estimate (residual) variance of within-person centered variables
  wcr1 ~~ wcr1 # Variances
  wepe1 ~~ wepe1 
  wcr2 ~~ wcr2 # Residual variances
  wepe2 ~~ wepe2 
  wcr3 ~~ wcr3 
  wepe3 ~~ wepe3'

RICLPM4fit <- lavaan(RICLPM4, 
  data = ANES_clean, 
  missing = 'FIML',
  estimator = "ML",
  sampling.weights = 'V240106b',
  meanstructure = T, 
  int.ov.free = T)

summary(RICLPM4fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-21 ended normally after 40 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        26
## 
##   Number of observations                          2070
##   Number of missing patterns                        15
##   Sampling weights variable                   V240106b
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 1.723       1.059
##   Degrees of freedom                                 1           1
##   P-value (Chi-square)                           0.189       0.303
##   Scaling correction factor                                  1.627
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              3748.533    1624.049
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.308
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       0.997       0.999
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)             -16811.657  -16811.657
##   Scaling correction factor                                  1.957
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)     -16810.796  -16810.796
##   Scaling correction factor                                  1.945
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               33675.314   33675.314
##   Bayesian (BIC)                             33821.832   33821.832
##   Sample-size adjusted Bayesian (SABIC)      33739.228   33739.228
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.019       0.005
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.065       0.048
##   P-value H_0: RMSEA <= 0.050                    0.832       0.960
##   P-value H_0: RMSEA >= 0.080                    0.010       0.000
##                                                                   
##   Robust RMSEA                                               0.004
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.076
##   P-value H_0: Robust RMSEA <= 0.050                         0.770
##   P-value H_0: Robust RMSEA >= 0.080                         0.038
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.006       0.006
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIcr =~                                                               
##     c_ref_w1          1.000                               0.957    0.781
##     c_ref_w2          1.000                               0.957    0.769
##     c_ref_w3          1.000                               0.957    0.791
##   RIepe =~                                                              
##     ex_eff_w1         1.000                               0.541    0.543
##     ex_eff_w2         1.000                               0.541    0.533
##     ex_eff_w3         1.000                               0.541    0.570
##   wcr1 =~                                                               
##     c_ref_w1          1.000                               0.765    0.625
##   wcr2 =~                                                               
##     c_ref_w2          1.000                               0.795    0.639
##   wcr3 =~                                                               
##     c_ref_w3          1.000                               0.740    0.612
##   wepe1 =~                                                              
##     ex_eff_w1         1.000                               0.837    0.840
##   wepe2 =~                                                              
##     ex_eff_w2         1.000                               0.859    0.846
##   wepe3 =~                                                              
##     ex_eff_w3         1.000                               0.780    0.822
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr2 ~                                                                
##     wcr1              0.158    0.068    2.311    0.021    0.152    0.152
##     wepe1             0.071    0.044    1.595    0.111    0.074    0.074
##   wepe2 ~                                                               
##     wcr1              0.309    0.063    4.876    0.000    0.276    0.276
##     wepe1             0.051    0.046    1.127    0.260    0.050    0.050
##   wcr3 ~                                                                
##     wcr2              0.179    0.063    2.861    0.004    0.192    0.192
##     wepe2             0.212    0.053    3.982    0.000    0.246    0.246
##   wepe3 ~                                                               
##     wcr2             -0.003    0.053   -0.062    0.950   -0.003   -0.003
##     wepe2             0.162    0.050    3.215    0.001    0.178    0.178
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr1 ~~                                                               
##     wepe1             0.017    0.031    0.546    0.585    0.027    0.027
##  .wcr2 ~~                                                               
##    .wepe2             0.166    0.038    4.356    0.000    0.257    0.257
##  .wcr3 ~~                                                               
##    .wepe3            -0.035    0.024   -1.432    0.152   -0.065   -0.065
##   RIcr ~~                                                               
##     RIepe             0.063    0.033    1.890    0.059    0.121    0.121
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .c_ref_w1          3.023    0.037   82.599    0.000    3.023    2.467
##    .c_ref_w2          3.235    0.036   89.375    0.000    3.235    2.599
##    .c_ref_w3          3.113    0.036   86.157    0.000    3.113    2.573
##    .ex_eff_w1         2.563    0.030   86.501    0.000    2.563    2.571
##    .ex_eff_w2         2.363    0.030   79.292    0.000    2.363    2.327
##    .ex_eff_w3         2.208    0.028   79.089    0.000    2.208    2.326
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIcr              0.916    0.052   17.612    0.000    1.000    1.000
##     RIepe             0.293    0.033    8.893    0.000    1.000    1.000
##     wcr1              0.586    0.044   13.306    0.000    1.000    1.000
##     wepe1             0.701    0.040   17.359    0.000    1.000    1.000
##    .wcr2              0.614    0.044   13.927    0.000    0.971    0.971
##    .wepe2             0.680    0.048   14.288    0.000    0.921    0.921
##    .wcr3              0.479    0.034   14.153    0.000    0.875    0.875
##    .wepe3             0.590    0.037   16.065    0.000    0.969    0.969
##    .c_ref_w1          0.000                               0.000    0.000
##    .c_ref_w2          0.000                               0.000    0.000
##    .c_ref_w3          0.000                               0.000    0.000
##    .ex_eff_w1         0.000                               0.000    0.000
##    .ex_eff_w2         0.000                               0.000    0.000
##    .ex_eff_w3         0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wcr2              0.029
##     wepe2             0.079
##     wcr3              0.125
##     wepe3             0.031
##     c_ref_w1          1.000
##     c_ref_w2          1.000
##     c_ref_w3          1.000
##     ex_eff_w1         1.000
##     ex_eff_w2         1.000
##     ex_eff_w3         1.000
#Extracting covariance matrix
lavInspect(RICLPM4fit, "sampstat")
## $cov
##           c_rf_1 c_rf_2 c_rf_3 ex_f_1 ex_f_2 ex_f_3
## c_ref_w1   1.502                                   
## c_ref_w2   1.010  1.549                            
## c_ref_w3   0.969  1.070  1.461                     
## ex_eff_w1  0.072  0.104  0.059  0.994              
## ex_eff_w2  0.248  0.260  0.252  0.334  1.031       
## ex_eff_w3  0.112  0.103  0.066  0.300  0.411  0.902
## 
## $mean
##  c_ref_w1  c_ref_w2  c_ref_w3 ex_eff_w1 ex_eff_w2 ex_eff_w3 
##     3.023     3.235     3.113     2.563     2.363     2.208
#Extracting residual correlation matrix
resid(RICLPM4fit, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##           c_rf_1 c_rf_2 c_rf_3 ex_f_1 ex_f_2 ex_f_3
## c_ref_w1   0.000                                   
## c_ref_w2   0.000  0.000                            
## c_ref_w3  -0.001  0.000  0.000                     
## ex_eff_w1 -0.007 -0.009 -0.018  0.000              
## ex_eff_w2  0.002  0.000 -0.002  0.000  0.000       
## ex_eff_w3  0.018  0.009  0.007  0.001  0.000  0.000
## 
## $mean
##  c_ref_w1  c_ref_w2  c_ref_w3 ex_eff_w1 ex_eff_w2 ex_eff_w3 
##         0         0         0         0         0         0

#RICLPM EPE Moderation

RICLPMmod1 <- '
  # Create between components (random intercepts)
  RIcr =~ 1*c_ref_w1 + 1*c_ref_w2 + 1*c_ref_w3 
  RIca =~ 1*c_act_w1 + 1*c_act_w2 + 1*c_act_w3 
  
  # Create within-person centered variables
  wcr1 =~ 1*c_ref_w1
  wcr2 =~ 1*c_ref_w2
  wcr3 =~ 1*c_ref_w3 

  wca1 =~ 1*c_act_w1
  wca2 =~ 1*c_act_w2
  wca3 =~ 1*c_act_w3
# Estimate lagged effects between within-person centered variables
  wcr2 ~ wcr1 + wca1
  wcr3 ~ wcr2 + wca2
  wca2 ~ wca1
  wca3 ~ wca2
  wca2 ~ wcr1
  wca3 ~ wcr2
  
  # Estimate covariance between within-person centered variables at first wave
  wcr1 ~~ wca1 # Covariance
  
  # Estimate covariances between residuals of within-person centered variables
  # (i.e., innovations)
  wcr2 ~~ wca2
  wcr3 ~~ wca3
  
  # Estimate variance and covariance of random intercepts
  RIcr ~~ RIcr
  RIca ~~ RIca
  RIcr ~~ RIca
  
  # Estimate (residual) variance of within-person centered variables
  wcr1 ~~ wcr1 # Variances
  wca1 ~~ wca1 
  wcr2 ~~ wcr2 # Residual variances
  wca2 ~~ wca2 
  wcr3 ~~ wcr3 
  wca3 ~~ wca3'

RICLPMmodfit1 <- lavaan(RICLPMmod1, 
  data = ANES_clean, 
  missing = 'FIML',
  estimator = "MLR",
  meanstructure = T, 
  group = "ex_eff_ms_w2",
  sampling.weights = "V240106b",
  int.ov.free = T)
## Warning: lavaan->lav_data_full():  
##    group variable 'ex_eff_ms_w2' contains missing values
summary(RICLPMmodfit1, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-21 ended normally after 129 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        52
## 
##   Number of observations per group:                   
##     0                                             1105
##     1                                              957
##   Number of missing patterns per group:               
##     0                                                8
##     1                                                7
##   Sampling weights variable                   V240106b
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 3.044       1.645
##   Degrees of freedom                                 2           2
##   P-value (Chi-square)                           0.218       0.439
##   Scaling correction factor                                  1.850
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                            0.846       0.846
##     1                                            0.799       0.799
## 
## Model Test Baseline Model:
## 
##   Test statistic                              3659.303    1581.181
##   Degrees of freedom                                30          30
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.314
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       0.996       1.003
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.003
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -7366.202   -7366.202
##   Scaling correction factor                                  2.223
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -7364.680   -7364.680
##   Scaling correction factor                                  2.209
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               14836.403   14836.403
##   Bayesian (BIC)                             15129.238   15129.238
##   Sample-size adjusted Bayesian (SABIC)      14964.029   14964.029
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.022       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.070       0.045
##   P-value H_0: RMSEA <= 0.050                    0.785       0.974
##   P-value H_0: RMSEA >= 0.080                    0.018       0.000
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.079
##   P-value H_0: Robust RMSEA <= 0.050                         0.776
##   P-value H_0: Robust RMSEA >= 0.080                         0.048
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.008       0.008
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIcr =~                                                               
##     c_ref_w1          1.000                               0.964    0.795
##     c_ref_w2          1.000                               0.964    0.769
##     c_ref_w3          1.000                               0.964    0.802
##   RIca =~                                                               
##     c_act_w1          1.000                               0.084    0.346
##     c_act_w2          1.000                               0.084    0.382
##     c_act_w3          1.000                               0.084    0.561
##   wcr1 =~                                                               
##     c_ref_w1          1.000                               0.734    0.606
##   wcr2 =~                                                               
##     c_ref_w2          1.000                               0.802    0.640
##   wcr3 =~                                                               
##     c_ref_w3          1.000                               0.719    0.598
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.226    0.938
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.202    0.924
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.123    0.828
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr2 ~                                                                
##     wcr1              0.111    0.100    1.103    0.270    0.101    0.101
##     wca1              0.171    0.200    0.855    0.392    0.048    0.048
##   wcr3 ~                                                                
##     wcr2              0.164    0.078    2.099    0.036    0.183    0.183
##     wca2              0.521    0.297    1.753    0.080    0.146    0.146
##   wca2 ~                                                                
##     wca1              0.272    0.055    4.949    0.000    0.305    0.305
##   wca3 ~                                                                
##     wca2              0.052    0.057    0.900    0.368    0.085    0.085
##   wca2 ~                                                                
##     wcr1              0.027    0.022    1.222    0.222    0.096    0.096
##   wca3 ~                                                                
##     wcr2             -0.003    0.010   -0.277    0.782   -0.018   -0.018
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr1 ~~                                                               
##     wca1              0.011    0.011    0.984    0.325    0.068    0.068
##  .wcr2 ~~                                                               
##    .wca2              0.025    0.011    2.286    0.022    0.161    0.161
##  .wcr3 ~~                                                               
##    .wca3              0.003    0.005    0.605    0.546    0.036    0.036
##   RIcr ~~                                                               
##     RIca              0.019    0.008    2.365    0.018    0.236    0.236
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .c_ref_w1          2.835    0.050   56.795    0.000    2.835    2.340
##    .c_ref_w2          3.036    0.050   60.681    0.000    3.036    2.422
##    .c_ref_w3          2.896    0.049   58.990    0.000    2.896    2.409
##    .c_act_w1          0.184    0.010   18.674    0.000    0.184    0.764
##    .c_act_w2          0.139    0.009   15.632    0.000    0.139    0.638
##    .c_act_w3          0.058    0.006   10.114    0.000    0.058    0.392
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIcr              0.928    0.071   13.096    0.000    1.000    1.000
##     RIca              0.007    0.002    3.461    0.001    1.000    1.000
##     wcr1              0.539    0.051   10.505    0.000    1.000    1.000
##     wca1              0.051    0.004   11.531    0.000    1.000    1.000
##    .wcr2              0.634    0.064    9.882    0.000    0.987    0.987
##    .wca2              0.036    0.003   12.129    0.000    0.893    0.893
##    .wcr3              0.483    0.045   10.712    0.000    0.935    0.935
##    .wca3              0.015    0.003    5.996    0.000    0.993    0.993
##    .c_ref_w1          0.000                               0.000    0.000
##    .c_ref_w2          0.000                               0.000    0.000
##    .c_ref_w3          0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wcr2              0.013
##     wca2              0.107
##     wcr3              0.065
##     wca3              0.007
##     c_ref_w1          1.000
##     c_ref_w2          1.000
##     c_ref_w3          1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIcr =~                                                               
##     c_ref_w1          1.000                               0.916    0.763
##     c_ref_w2          1.000                               0.916    0.769
##     c_ref_w3          1.000                               0.916    0.785
##   RIca =~                                                               
##     c_act_w1          1.000                               0.138    0.532
##     c_act_w2          1.000                               0.138    0.534
##     c_act_w3          1.000                               0.138    0.671
##   wcr1 =~                                                               
##     c_ref_w1          1.000                               0.775    0.646
##   wcr2 =~                                                               
##     c_ref_w2          1.000                               0.762    0.639
##   wcr3 =~                                                               
##     c_ref_w3          1.000                               0.722    0.619
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.220    0.846
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.219    0.846
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.153    0.741
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr2 ~                                                                
##     wcr1              0.140    0.098    1.424    0.154    0.142    0.142
##     wca1              0.269    0.226    1.191    0.234    0.078    0.078
##   wcr3 ~                                                                
##     wcr2              0.191    0.103    1.853    0.064    0.201    0.201
##     wca2              0.583    0.283    2.057    0.040    0.177    0.177
##   wca2 ~                                                                
##     wca1              0.240    0.062    3.836    0.000    0.240    0.240
##   wca3 ~                                                                
##     wca2             -0.021    0.076   -0.270    0.787   -0.030   -0.030
##   wca2 ~                                                                
##     wcr1              0.066    0.021    3.142    0.002    0.236    0.236
##   wca3 ~                                                                
##     wcr2              0.022    0.017    1.298    0.194    0.110    0.110
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr1 ~~                                                               
##     wca1              0.018    0.012    1.488    0.137    0.108    0.108
##  .wcr2 ~~                                                               
##    .wca2              0.043    0.012    3.581    0.000    0.280    0.280
##  .wcr3 ~~                                                               
##    .wca3              0.013    0.009    1.468    0.142    0.129    0.129
##   RIcr ~~                                                               
##     RIca              0.035    0.011    3.146    0.002    0.279    0.279
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .c_ref_w1          3.258    0.052   62.355    0.000    3.258    2.715
##    .c_ref_w2          3.476    0.051   68.025    0.000    3.476    2.918
##    .c_ref_w3          3.376    0.051   66.310    0.000    3.376    2.895
##    .c_act_w1          0.203    0.010   19.474    0.000    0.203    0.783
##    .c_act_w2          0.183    0.011   17.000    0.000    0.183    0.708
##    .c_act_w3          0.102    0.009   11.104    0.000    0.102    0.493
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIcr              0.839    0.079   10.626    0.000    1.000    1.000
##     RIca              0.019    0.004    5.294    0.000    1.000    1.000
##     wcr1              0.601    0.071    8.458    0.000    1.000    1.000
##     wca1              0.048    0.003   14.712    0.000    1.000    1.000
##    .wcr2              0.564    0.067    8.428    0.000    0.971    0.971
##    .wca2              0.042    0.004   10.318    0.000    0.874    0.874
##    .wcr3              0.472    0.051    9.321    0.000    0.906    0.906
##    .wca3              0.023    0.006    4.008    0.000    0.989    0.989
##    .c_ref_w1          0.000                               0.000    0.000
##    .c_ref_w2          0.000                               0.000    0.000
##    .c_ref_w3          0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wcr2              0.029
##     wca2              0.126
##     wcr3              0.094
##     wca3              0.011
##     c_ref_w1          1.000
##     c_ref_w2          1.000
##     c_ref_w3          1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
#Extracting covariance matrix
lavInspect(RICLPMmodfit1, "sampstat")
## $`0`
## $`0`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  1.467                                   
## c_ref_w2  0.990  1.571                            
## c_ref_w3  0.948  1.050  1.447                     
## c_act_w1  0.035  0.034  0.037  0.058              
## c_act_w2  0.036  0.048  0.045  0.021  0.048       
## c_act_w3  0.017  0.018  0.022  0.008  0.009  0.022
## 
## $`0`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##    2.835    3.036    2.896    0.184    0.139    0.058 
## 
## 
## $`1`
## $`1`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  1.438                                   
## c_ref_w2  0.927  1.419                            
## c_ref_w3  0.880  0.980  1.360                     
## c_act_w1  0.057  0.055  0.054  0.067              
## c_act_w2  0.079  0.088  0.074  0.032  0.067       
## c_act_w3  0.032  0.045  0.050  0.019  0.019  0.042
## 
## $`1`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##    3.258    3.476    3.376    0.203    0.183    0.102
#Extracting residual correlation matrix
resid(RICLPMmodfit1, type = "cor")
## $`0`
## $`0`$type
## [1] "cor.bollen"
## 
## $`0`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  0.000                                   
## c_ref_w2  0.000  0.000                            
## c_ref_w3  0.000  0.000  0.000                     
## c_act_w1  0.017  0.018  0.031  0.000              
## c_act_w2 -0.001  0.000  0.001  0.001  0.000       
## c_act_w3 -0.012 -0.006 -0.005  0.003  0.000  0.000
## 
## $`0`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##        0        0        0        0        0        0 
## 
## 
## $`1`
## $`1`$type
## [1] "cor.bollen"
## 
## $`1`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  0.000                                   
## c_ref_w2  0.000  0.000                            
## c_ref_w3 -0.001  0.000  0.000                     
## c_act_w1  0.011  0.014  0.029  0.000              
## c_act_w2 -0.003  0.000  0.003  0.001  0.000       
## c_act_w3 -0.016 -0.007 -0.003  0.002  0.000  0.000
## 
## $`1`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##        0        0        0        0        0        0

#RICLPM IPE Moderation

RICLPMmod2 <- '
  # Create between components (random intercepts)
  RIcr =~ 1*c_ref_w1 + 1*c_ref_w2 + 1*c_ref_w3 
  RIca =~ 1*c_act_w1 + 1*c_act_w2 + 1*c_act_w3 
  
  # Create within-person centered variables
  wcr1 =~ 1*c_ref_w1
  wcr2 =~ 1*c_ref_w2
  wcr3 =~ 1*c_ref_w3 

  wca1 =~ 1*c_act_w1
  wca2 =~ 1*c_act_w2
  wca3 =~ 1*c_act_w3
# Estimate lagged effects between within-person centered variables
  wcr2 ~ wcr1 + wca1
  wcr3 ~ wcr2 + wca2
  wca2 ~ wca1
  wca3 ~ wca2
  wca2 ~ wcr1
  wca3 ~ wcr2
  
  # Estimate covariance between within-person centered variables at first wave
  wcr1 ~~ wca1 # Covariance
  
  # Estimate covariances between residuals of within-person centered variables
  # (i.e., innovations)
  wcr2 ~~ wca2
  wcr3 ~~ wca3
  
  # Estimate variance and covariance of random intercepts
  RIcr ~~ RIcr
  RIca ~~ RIca
  RIcr ~~ RIca
  
  # Estimate (residual) variance of within-person centered variables
  wcr1 ~~ wcr1 # Variances
  wca1 ~~ wca1 
  wcr2 ~~ wcr2 # Residual variances
  wca2 ~~ wca2 
  wcr3 ~~ wcr3 
  wca3 ~~ wca3'

RICLPMmodfit2 <- lavaan(RICLPMmod2, 
  data = ANES_clean, 
  missing = 'FIML',
  estimator = "MLR",
  meanstructure = T, 
  group = "in_eff_ms_w2",
  sampling.weights = "V240106b",
  int.ov.free = T)
## Warning: lavaan->lav_data_full():  
##    group variable 'in_eff_ms_w2' contains missing values
summary(RICLPMmodfit2, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-21 ended normally after 128 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        52
## 
##   Number of observations per group:                   
##     0                                              862
##     1                                             1199
##   Number of missing patterns per group:               
##     0                                                8
##     1                                                7
##   Sampling weights variable                   V240106b
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 5.950       3.160
##   Degrees of freedom                                 2           2
##   P-value (Chi-square)                           0.051       0.206
##   Scaling correction factor                                  1.883
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     0                                            0.163       0.163
##     1                                            2.997       2.997
## 
## Model Test Baseline Model:
## 
##   Test statistic                              3704.261    1590.263
##   Degrees of freedom                                30          30
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.329
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.999       0.999
##   Tucker-Lewis Index (TLI)                       0.984       0.989
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.999
##   Robust Tucker-Lewis Index (TLI)                            0.992
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -7319.465   -7319.465
##   Scaling correction factor                                  2.411
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -7316.490   -7316.490
##   Scaling correction factor                                  2.392
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               14742.930   14742.930
##   Bayesian (BIC)                             15035.739   15035.739
##   Sample-size adjusted Bayesian (SABIC)      14870.531   14870.531
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.044       0.024
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.086       0.058
##   P-value H_0: RMSEA <= 0.050                    0.520       0.883
##   P-value H_0: RMSEA >= 0.080                    0.086       0.002
##                                                                   
##   Robust RMSEA                                               0.031
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.098
##   P-value H_0: Robust RMSEA <= 0.050                         0.578
##   P-value H_0: Robust RMSEA >= 0.080                         0.138
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.010       0.010
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [0]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIcr =~                                                               
##     c_ref_w1          1.000                               0.851    0.769
##     c_ref_w2          1.000                               0.851    0.748
##     c_ref_w3          1.000                               0.851    0.753
##   RIca =~                                                               
##     c_act_w1          1.000                               0.098    0.429
##     c_act_w2          1.000                               0.098    0.517
##     c_act_w3          1.000                               0.098    0.615
##   wcr1 =~                                                               
##     c_ref_w1          1.000                               0.708    0.640
##   wcr2 =~                                                               
##     c_ref_w2          1.000                               0.755    0.664
##   wcr3 =~                                                               
##     c_ref_w3          1.000                               0.743    0.658
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.207    0.903
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.163    0.856
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.126    0.789
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr2 ~                                                                
##     wcr1              0.098    0.114    0.855    0.392    0.092    0.092
##     wca1              0.013    0.234    0.056    0.955    0.004    0.004
##   wcr3 ~                                                                
##     wcr2              0.142    0.094    1.505    0.132    0.144    0.144
##     wca2              0.077    0.414    0.185    0.853    0.017    0.017
##   wca2 ~                                                                
##     wca1              0.174    0.054    3.252    0.001    0.221    0.221
##   wca3 ~                                                                
##     wca2             -0.111    0.081   -1.376    0.169   -0.144   -0.144
##   wca2 ~                                                                
##     wcr1              0.014    0.022    0.613    0.540    0.059    0.059
##   wca3 ~                                                                
##     wcr2              0.012    0.014    0.826    0.409    0.070    0.070
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr1 ~~                                                               
##     wca1              0.006    0.011    0.509    0.611    0.038    0.038
##  .wcr2 ~~                                                               
##    .wca2              0.015    0.010    1.445    0.149    0.124    0.124
##  .wcr3 ~~                                                               
##    .wca3              0.015    0.009    1.694    0.090    0.168    0.168
##   RIcr ~~                                                               
##     RIca              0.031    0.010    3.114    0.002    0.366    0.366
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .c_ref_w1          2.911    0.051   57.358    0.000    2.911    2.631
##    .c_ref_w2          3.096    0.051   61.182    0.000    3.096    2.722
##    .c_ref_w3          3.039    0.053   57.782    0.000    3.039    2.691
##    .c_act_w1          0.151    0.010   15.530    0.000    0.151    0.662
##    .c_act_w2          0.108    0.008   12.805    0.000    0.108    0.571
##    .c_act_w3          0.058    0.008    7.421    0.000    0.058    0.366
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIcr              0.723    0.072   10.039    0.000    1.000    1.000
##     RIca              0.010    0.002    3.913    0.000    1.000    1.000
##     wcr1              0.501    0.058    8.589    0.000    1.000    1.000
##     wca1              0.043    0.003   13.134    0.000    1.000    1.000
##    .wcr2              0.565    0.067    8.420    0.000    0.992    0.992
##    .wca2              0.025    0.003    7.955    0.000    0.946    0.946
##    .wcr3              0.540    0.057    9.407    0.000    0.978    0.978
##    .wca3              0.015    0.005    3.024    0.002    0.977    0.977
##    .c_ref_w1          0.000                               0.000    0.000
##    .c_ref_w2          0.000                               0.000    0.000
##    .c_ref_w3          0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wcr2              0.008
##     wca2              0.054
##     wcr3              0.022
##     wca3              0.023
##     c_ref_w1          1.000
##     c_ref_w2          1.000
##     c_ref_w3          1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
## 
## 
## Group 2 [1]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RIcr =~                                                               
##     c_ref_w1          1.000                               1.058    0.805
##     c_ref_w2          1.000                               1.058    0.799
##     c_ref_w3          1.000                               1.058    0.830
##   RIca =~                                                               
##     c_act_w1          1.000                               0.121    0.459
##     c_act_w2          1.000                               0.121    0.450
##     c_act_w3          1.000                               0.121    0.625
##   wcr1 =~                                                               
##     c_ref_w1          1.000                               0.781    0.594
##   wcr2 =~                                                               
##     c_ref_w2          1.000                               0.796    0.601
##   wcr3 =~                                                               
##     c_ref_w3          1.000                               0.712    0.558
##   wca1 =~                                                               
##     c_act_w1          1.000                               0.233    0.888
##   wca2 =~                                                               
##     c_act_w2          1.000                               0.240    0.893
##   wca3 =~                                                               
##     c_act_w3          1.000                               0.151    0.781
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr2 ~                                                                
##     wcr1              0.122    0.091    1.334    0.182    0.119    0.119
##     wca1              0.209    0.198    1.054    0.292    0.061    0.061
##   wcr3 ~                                                                
##     wcr2              0.210    0.089    2.367    0.018    0.234    0.234
##     wca2              0.788    0.251    3.136    0.002    0.266    0.266
##   wca2 ~                                                                
##     wca1              0.288    0.055    5.248    0.000    0.280    0.280
##   wca3 ~                                                                
##     wca2              0.076    0.060    1.278    0.201    0.121    0.121
##   wca2 ~                                                                
##     wcr1              0.067    0.022    3.028    0.002    0.218    0.218
##   wca3 ~                                                                
##     wcr2              0.005    0.012    0.369    0.712    0.024    0.024
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   wcr1 ~~                                                               
##     wca1              0.014    0.012    1.212    0.226    0.077    0.077
##  .wcr2 ~~                                                               
##    .wca2              0.046    0.013    3.637    0.000    0.264    0.264
##  .wcr3 ~~                                                               
##    .wca3              0.004    0.006    0.626    0.531    0.037    0.037
##   RIcr ~~                                                               
##     RIca              0.026    0.010    2.680    0.007    0.203    0.203
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .c_ref_w1          3.143    0.052   60.378    0.000    3.143    2.389
##    .c_ref_w2          3.373    0.051   65.816    0.000    3.373    2.548
##    .c_ref_w3          3.192    0.050   63.867    0.000    3.192    2.502
##    .c_act_w1          0.232    0.010   22.937    0.000    0.232    0.883
##    .c_act_w2          0.208    0.010   19.882    0.000    0.208    0.775
##    .c_act_w3          0.097    0.007   13.752    0.000    0.097    0.502
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     RIcr              1.120    0.073   15.310    0.000    1.000    1.000
##     RIca              0.015    0.003    4.719    0.000    1.000    1.000
##     wcr1              0.611    0.058   10.560    0.000    1.000    1.000
##     wca1              0.055    0.004   12.348    0.000    1.000    1.000
##    .wcr2              0.621    0.064    9.644    0.000    0.981    0.981
##    .wca2              0.050    0.004   12.898    0.000    0.865    0.865
##    .wcr3              0.425    0.041   10.340    0.000    0.838    0.838
##    .wca3              0.022    0.003    7.218    0.000    0.983    0.983
##    .c_ref_w1          0.000                               0.000    0.000
##    .c_ref_w2          0.000                               0.000    0.000
##    .c_ref_w3          0.000                               0.000    0.000
##    .c_act_w1          0.000                               0.000    0.000
##    .c_act_w2          0.000                               0.000    0.000
##    .c_act_w3          0.000                               0.000    0.000
## 
## R-Square:
##                    Estimate
##     wcr2              0.019
##     wca2              0.135
##     wcr3              0.162
##     wca3              0.017
##     c_ref_w1          1.000
##     c_ref_w2          1.000
##     c_ref_w3          1.000
##     c_act_w1          1.000
##     c_act_w2          1.000
##     c_act_w3          1.000
#Extracting covariance matrix
lavInspect(RICLPMmodfit2, "sampstat")
## $`0`
## $`0`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  1.226                                   
## c_ref_w2  0.773  1.293                            
## c_ref_w3  0.732  0.805  1.275                     
## c_act_w1  0.034  0.030  0.027  0.052              
## c_act_w2  0.039  0.046  0.035  0.017  0.036       
## c_act_w3  0.031  0.036  0.047  0.009  0.007  0.025
## 
## $`0`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##    2.911    3.096    3.039    0.151    0.108    0.058 
## 
## 
## $`1`
## $`1`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  1.725                                   
## c_ref_w2  1.195  1.753                            
## c_ref_w3  1.169  1.298  1.629                     
## c_act_w1  0.050  0.051  0.060  0.069              
## c_act_w2  0.070  0.081  0.084  0.031  0.072       
## c_act_w3  0.022  0.029  0.032  0.016  0.019  0.037
## 
## $`1`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##    3.143    3.373    3.192    0.232    0.208    0.097
#Extracting residual correlation matrix
resid(RICLPMmodfit2, type = "cor")
## $`0`
## $`0`$type
## [1] "cor.bollen"
## 
## $`0`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  0.000                                   
## c_ref_w2  0.000  0.000                            
## c_ref_w3  0.001  0.000  0.000                     
## c_act_w1 -0.006 -0.007 -0.015  0.000              
## c_act_w2  0.001  0.000 -0.001 -0.001  0.000       
## c_act_w3  0.006  0.002  0.001 -0.002  0.000  0.000
## 
## $`0`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##        0        0        0        0        0        0 
## 
## 
## $`1`
## $`1`$type
## [1] "cor.bollen"
## 
## $`1`$cov
##          c_rf_1 c_rf_2 c_rf_3 c_ct_1 c_ct_2 c_ct_3
## c_ref_w1  0.000                                   
## c_ref_w2  0.000  0.000                            
## c_ref_w3 -0.001  0.000  0.000                     
## c_act_w1  0.029  0.032  0.054  0.000              
## c_act_w2 -0.003  0.000  0.003  0.001  0.000       
## c_act_w3 -0.029 -0.015 -0.011  0.004  0.000  0.000
## 
## $`1`$mean
## c_ref_w1 c_ref_w2 c_ref_w3 c_act_w1 c_act_w2 c_act_w3 
##        0        0        0        0        0        0