5  CFA, Model Selection

Author
Affiliation

John T West

The Pennsylvania State University

Published

March 29, 2024

library(dplyr)
library(tidyr)
library(psych)
library(ggplot2)
library(Hmisc)
library(plyr)
library(lavaan)
library(semPlot)

Loading in data from data cleaning page

load("INDI_data.Rdata")

indi.data$Group = as.factor(indi.data$Group)

indi.data$numeric.id = as.character(indi.data$numeric.id)

indi.data = dplyr::select(indi.data, numeric.id, Group, 
                   WCST.Persev.Errors, Arithmetic, backward.span, letter.numbering,
                   PPVT, PPT, 
                   MVPT, OOO.High.Hit.Rate, OOO.Color.Hit.Rate, OOO.Size.Hit.Rate,
                   cat.drm.FA.Related.Rates, schematic.FA.Related.Rates, 
                   object.sim.FA.Related.Rates, abstract.img.FA.Related.Rates)

Standardizing numeric indicators, reversing bWCST

scale2 = function(x, na.rm = FALSE) (x - mean(x, na.rm = na.rm)) / sd(x, na.rm)

data.z = indi.data %>%
  mutate_if(is.numeric, scale2, na.rm = TRUE)

# Reversing WCST
data.z$WCST.Persev.Errors = -1*data.z$WCST.Persev.Errors

Initial Multigroup SEM

Initial attempt to fit the hypothesized multi-group SEM model.

Based on recommendations cited the manuscript, good model fit is indicated by…

  • Nonsignificant chi-squared test
  • TLI/CFI > 0.90
  • RMSEA < 0.01 (excellent), < 0.05 (moderate), > 0.08 (poor)
  • SRMR < 0.08 (good)
hypothesized.model = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    semantic.fm =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates
    per.fm =~ object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # regressions
    semantic.fm ~ semantic.disc + exec.func
    per.fm ~ per.disc + exec.func
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

hypothesized.fit = sem(hypothesized.model, 
                     missing = 'ML', 
                     data = data.z)
Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
variances are negative
semPaths(hypothesized.fit, 
         layout = "tree",
         residuals = FALSE, 
         intercepts = FALSE, 
         latents = c("semantic.disc", "exec.func", "per.disc",
                     "semantic.fm", "per.fm"), 
         #whatLabels = "std", 
         fixedStyle = c("black", 1), 
         nodeLabels = c("PPVT", "PPT", "WCST", "Arithmetic", 
                        "Backward\nSpan", "Letter\nNumbering", 
                        "MVPT", "OOO - High", "OOO - Color", "OOO - Size", 
                        "Categorical\nDRM FM", "Schematic\nFM", "Object Sim.\nFM", "Abstract\nImages FM",
                        "Semantic\nDiscrimination", "Frontal\nFunctioning", "Perceptual\nDiscrimination",
                        "False Memory\n(Semantic)", "False Memory\n(Perceptual)"), 
         sizeMan2 = 5, 
         sizeMan = 9,  
         sizeLat = 10,
         asize = 3.5, 
         esize = 2,
         border.width = 2,
         #edge.label.cex = 0.5,
         #edge.label.margin = 0.005,
         edge.color = "black", 
         #edge.label.color = "black",
         fade = FALSE,
         gray = FALSE,
         font = 8,
         label.scale = FALSE,
         label.cex = 0.5,           
         curve = 1.25,           
         mar = c(3,2,3,2)) 

title("Hypothesized Model", line = 3)

initial.model = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    semantic.fm =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates
    per.fm =~ object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # regressions
    semantic.fm ~ semantic.disc + exec.func
    per.fm ~ per.disc + exec.func
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

initial.fit = sem(initial.model, 
                     missing = 'ML', 
                     data = data.z, 
                     group = 'Group')
Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
variances are negative
Warning in lav_object_post_check(object): lavaan WARNING: covariance matrix of latent variables
                is not positive definite in group 1;
                use lavInspect(fit, "cov.lv") to investigate.
# Model Results

summary(initial.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 109 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                       106

  Number of observations per group:                   
    OA                                             152
    YA                                             211
  Number of missing patterns per group:               
    OA                                              10
    YA                                              18

Model Test User Model:
                                                      
  Test statistic                               189.677
  Degrees of freedom                               132
  P-value (Chi-square)                           0.001
  Test statistic for each group:
    OA                                          72.201
    YA                                         117.476

Model Test Baseline Model:

  Test statistic                              1321.706
  Degrees of freedom                               182
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.949
  Tucker-Lewis Index (TLI)                       0.930
                                                      
  Robust Comparative Fit Index (CFI)             0.943
  Robust Tucker-Lewis Index (TLI)                0.921

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5989.890
  Loglikelihood unrestricted model (H1)      -5895.051
                                                      
  Akaike (AIC)                               12191.780
  Bayesian (BIC)                             12604.587
  Sample-size adjusted Bayesian (SABIC)      12268.296

Root Mean Square Error of Approximation:

  RMSEA                                          0.049
  90 Percent confidence interval - lower         0.032
  90 Percent confidence interval - upper         0.064
  P-value H_0: RMSEA <= 0.050                    0.525
  P-value H_0: RMSEA >= 0.080                    0.000
                                                      
  Robust RMSEA                                   0.053
  90 Percent confidence interval - lower         0.036
  90 Percent confidence interval - upper         0.069
  P-value H_0: Robust RMSEA <= 0.050             0.368
  P-value H_0: Robust RMSEA >= 0.080             0.002

Standardized Root Mean Square Residual:

  SRMR                                           0.060

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian


Group 1 [OA]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.disc =~                                                      
    PPVT              1.000                               0.350    0.969
    PPT               0.462    0.202    2.286    0.022    0.162    0.319
  per.disc =~                                                           
    MVPT              1.000                               0.754    0.767
    OOO.High.Ht.Rt    0.663    0.144    4.590    0.000    0.500    0.515
    OOO.Colr.Ht.Rt    0.300    0.144    2.084    0.037    0.226    0.215
    OOO.Size.Ht.Rt    0.559    0.120    4.651    0.000    0.422    0.500
  exec.func =~                                                          
    WCST.Prsv.Errr    1.000                               0.427    0.348
    Arithmetic        1.532    0.436    3.512    0.000    0.654    0.713
    backward.span     0.969    0.322    3.005    0.003    0.414    0.415
    letter.numbrng    1.016    0.328    3.098    0.002    0.434    0.486
  semantic.fm =~                                                        
    ct.drm.FA.Rl.R    1.000                               0.537    0.596
    schmtc.FA.Rl.R    0.613    0.232    2.637    0.008    0.329    0.315
  per.fm =~                                                             
    objct.s.FA.R.R    1.000                               0.887    1.012
    abstrc..FA.R.R    0.453    0.143    3.167    0.002    0.402    0.440

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.fm ~                                                         
    semantic.disc     0.411    0.372    1.105    0.269    0.268    0.268
    exec.func        -1.239    0.440   -2.814    0.005   -0.984   -0.984
  per.fm ~                                                              
    per.disc         -0.320    0.275   -1.162    0.245   -0.272   -0.272
    exec.func        -0.346    0.467   -0.741    0.459   -0.167   -0.167

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.196    0.080    2.463    0.014    0.196    0.228
   .OOO.Size.Ht.Rt         0.261    0.065    4.023    0.000    0.261    0.430
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.223    0.070    3.177    0.001    0.223    0.297
  semantic.disc ~~                                                           
    per.disc               0.147    0.031    4.710    0.000    0.556    0.556
    exec.func              0.094    0.029    3.202    0.001    0.630    0.630
  per.disc ~~                                                                
    exec.func              0.248    0.079    3.138    0.002    0.770    0.770
 .semantic.fm ~~                                                             
   .per.fm                 0.243    0.061    3.962    0.000    1.035    1.035

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.874    0.029   29.823    0.000    0.874    2.419
   .PPT               0.654    0.041   15.868    0.000    0.654    1.287
   .MVPT             -0.213    0.080   -2.678    0.007   -0.213   -0.217
   .OOO.High.Ht.Rt   -0.248    0.079   -3.149    0.002   -0.248   -0.255
   .OOO.Colr.Ht.Rt   -0.376    0.086   -4.400    0.000   -0.376   -0.357
   .OOO.Size.Ht.Rt    0.125    0.068    1.833    0.067    0.125    0.149
   .WCST.Prsv.Errr   -0.268    0.102   -2.629    0.009   -0.268   -0.219
   .Arithmetic        0.299    0.074    4.016    0.000    0.299    0.326
   .backward.span     0.084    0.081    1.036    0.300    0.084    0.084
   .letter.numbrng   -0.144    0.072   -1.993    0.046   -0.144   -0.162
   .ct.drm.FA.Rl.R   -0.154    0.074   -2.082    0.037   -0.154   -0.171
   .schmtc.FA.Rl.R    0.082    0.103    0.794    0.427    0.082    0.078
   .objct.s.FA.R.R    0.034    0.072    0.476    0.634    0.034    0.039
   .abstrc..FA.R.R    0.263    0.074    3.530    0.000    0.263    0.288

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.008    0.045    0.175    0.861    0.008    0.061
   .PPT               0.232    0.028    8.192    0.000    0.232    0.898
   .MVPT              0.397    0.110    3.615    0.000    0.397    0.411
   .OOO.High.Ht.Rt    0.694    0.094    7.385    0.000    0.694    0.735
   .OOO.Colr.Ht.Rt    1.061    0.125    8.516    0.000    1.061    0.954
   .OOO.Size.Ht.Rt    0.532    0.070    7.550    0.000    0.532    0.750
   .WCST.Prsv.Errr    1.323    0.163    8.101    0.000    1.323    0.879
   .Arithmetic        0.415    0.073    5.648    0.000    0.415    0.492
   .backward.span     0.824    0.102    8.084    0.000    0.824    0.828
   .letter.numbrng    0.608    0.078    7.800    0.000    0.608    0.764
   .ct.drm.FA.Rl.R    0.524    0.140    3.731    0.000    0.524    0.645
   .schmtc.FA.Rl.R    0.987    0.147    6.714    0.000    0.987    0.901
   .objct.s.FA.R.R   -0.018    0.209   -0.087    0.930   -0.018   -0.024
   .abstrc..FA.R.R    0.670    0.089    7.569    0.000    0.670    0.806
    semantic.disc     0.123    0.048    2.573    0.010    1.000    1.000
    per.disc          0.568    0.142    4.003    0.000    1.000    1.000
    exec.func         0.182    0.098    1.859    0.063    1.000    1.000
   .semantic.fm       0.084    0.126    0.670    0.503    0.292    0.292
   .per.fm            0.651    0.228    2.862    0.004    0.828    0.828

R-Square:
                   Estimate
    PPVT              0.939
    PPT               0.102
    MVPT              0.589
    OOO.High.Ht.Rt    0.265
    OOO.Colr.Ht.Rt    0.046
    OOO.Size.Ht.Rt    0.250
    WCST.Prsv.Errr    0.121
    Arithmetic        0.508
    backward.span     0.172
    letter.numbrng    0.236
    ct.drm.FA.Rl.R    0.355
    schmtc.FA.Rl.R    0.099
    objct.s.FA.R.R       NA
    abstrc..FA.R.R    0.194
    semantic.fm       0.708
    per.fm            0.172


Group 2 [YA]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.disc =~                                                      
    PPVT              1.000                               0.483    0.597
    PPT               1.516    0.253    5.989    0.000    0.732    0.732
  per.disc =~                                                           
    MVPT              1.000                               0.834    0.849
    OOO.High.Ht.Rt    0.749    0.084    8.918    0.000    0.625    0.638
    OOO.Colr.Ht.Rt    0.520    0.075    6.961    0.000    0.434    0.504
    OOO.Size.Ht.Rt    0.651    0.099    6.578    0.000    0.543    0.499
  exec.func =~                                                          
    WCST.Prsv.Errr    1.000                               0.288    0.385
    Arithmetic        2.257    0.519    4.348    0.000    0.650    0.652
    backward.span     2.261    0.533    4.243    0.000    0.652    0.655
    letter.numbrng    1.944    0.472    4.120    0.000    0.560    0.530
  semantic.fm =~                                                        
    ct.drm.FA.Rl.R    1.000                               0.776    0.742
    schmtc.FA.Rl.R    0.560    0.116    4.839    0.000    0.435    0.451
  per.fm =~                                                             
    objct.s.FA.R.R    1.000                               0.928    0.872
    abstrc..FA.R.R    0.667    0.087    7.642    0.000    0.618    0.613

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.fm ~                                                         
    semantic.disc    -0.417    0.229   -1.819    0.069   -0.259   -0.259
    exec.func        -1.308    0.416   -3.146    0.002   -0.486   -0.486
  per.fm ~                                                              
    per.disc         -0.608    0.205   -2.964    0.003   -0.547   -0.547
    exec.func         0.054    0.576    0.095    0.925    0.017    0.017

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.148    0.046    3.193    0.001    0.148    0.264
   .OOO.Size.Ht.Rt         0.114    0.057    1.989    0.047    0.114    0.160
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.189    0.055    3.423    0.001    0.189    0.270
  semantic.disc ~~                                                           
    per.disc               0.297    0.058    5.132    0.000    0.736    0.736
    exec.func              0.042    0.020    2.080    0.037    0.298    0.298
  per.disc ~~                                                                
    exec.func              0.171    0.045    3.828    0.000    0.711    0.711
 .semantic.fm ~~                                                             
   .per.fm                 0.458    0.072    6.362    0.000    0.954    0.954

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT             -0.648    0.056  -11.534    0.000   -0.648   -0.802
   .PPT              -0.471    0.069   -6.840    0.000   -0.471   -0.471
   .MVPT              0.154    0.068    2.274    0.023    0.154    0.157
   .OOO.High.Ht.Rt    0.179    0.067    2.650    0.008    0.179    0.182
   .OOO.Colr.Ht.Rt    0.271    0.059    4.580    0.000    0.271    0.315
   .OOO.Size.Ht.Rt   -0.090    0.075   -1.204    0.229   -0.090   -0.083
   .WCST.Prsv.Errr    0.183    0.052    3.492    0.000    0.183    0.244
   .Arithmetic       -0.215    0.069   -3.125    0.002   -0.215   -0.216
   .backward.span    -0.060    0.069   -0.881    0.378   -0.060   -0.061
   .letter.numbrng    0.104    0.073    1.429    0.153    0.104    0.098
   .ct.drm.FA.Rl.R    0.111    0.073    1.528    0.127    0.111    0.107
   .schmtc.FA.Rl.R   -0.063    0.077   -0.825    0.409   -0.063   -0.066
   .objct.s.FA.R.R   -0.018    0.074   -0.239    0.811   -0.018   -0.017
   .abstrc..FA.R.R   -0.203    0.071   -2.869    0.004   -0.203   -0.201

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.421    0.055    7.592    0.000    0.421    0.644
   .PPT               0.464    0.101    4.589    0.000    0.464    0.464
   .MVPT              0.269    0.064    4.227    0.000    0.269    0.279
   .OOO.High.Ht.Rt    0.569    0.065    8.760    0.000    0.569    0.593
   .OOO.Colr.Ht.Rt    0.551    0.058    9.424    0.000    0.551    0.746
   .OOO.Size.Ht.Rt    0.890    0.094    9.440    0.000    0.890    0.751
   .WCST.Prsv.Errr    0.478    0.051    9.408    0.000    0.478    0.852
   .Arithmetic        0.574    0.076    7.510    0.000    0.574    0.576
   .backward.span     0.565    0.079    7.139    0.000    0.565    0.571
   .letter.numbrng    0.802    0.093    8.636    0.000    0.802    0.719
   .ct.drm.FA.Rl.R    0.491    0.116    4.229    0.000    0.491    0.449
   .schmtc.FA.Rl.R    0.739    0.091    8.083    0.000    0.739    0.796
   .objct.s.FA.R.R    0.271    0.093    2.918    0.004    0.271    0.239
   .abstrc..FA.R.R    0.636    0.075    8.500    0.000    0.636    0.625
    semantic.disc     0.233    0.061    3.808    0.000    1.000    1.000
    per.disc          0.695    0.107    6.490    0.000    1.000    1.000
    exec.func         0.083    0.034    2.423    0.015    1.000    1.000
   .semantic.fm       0.375    0.123    3.039    0.002    0.622    0.622
   .per.fm            0.614    0.126    4.888    0.000    0.714    0.714

R-Square:
                   Estimate
    PPVT              0.356
    PPT               0.536
    MVPT              0.721
    OOO.High.Ht.Rt    0.407
    OOO.Colr.Ht.Rt    0.254
    OOO.Size.Ht.Rt    0.249
    WCST.Prsv.Errr    0.148
    Arithmetic        0.424
    backward.span     0.429
    letter.numbrng    0.281
    ct.drm.FA.Rl.R    0.551
    schmtc.FA.Rl.R    0.204
    objct.s.FA.R.R    0.761
    abstrc..FA.R.R    0.375
    semantic.fm       0.378
    per.fm            0.286
modindices(initial.fit, sort = TRUE, maximum.number = 10)
Warning in lav_start_check_cov(lavpartable = lavpartable, start = start.values): lavaan WARNING: starting values imply a correlation larger than 1;
                   variables involved are:  semantic.fm   per.fm  [in block 1]
              lhs op                rhs block group level     mi    epc sepc.lv
444   semantic.fm  ~           per.disc     2     2     1 10.880 -1.169  -1.256
439      per.disc ~~        semantic.fm     2     2     1 10.879 -0.156  -0.306
441     exec.func ~~        semantic.fm     2     2     1 10.879  0.100   0.568
349          PPVT ~~                PPT     2     2     1 10.878  0.572   0.572
443   semantic.fm  ~             per.fm     2     2     1 10.878  1.922   2.296
437 semantic.disc ~~        semantic.fm     2     2     1 10.878  0.157   0.532
355          PPVT ~~         Arithmetic     2     2     1 10.496  0.137   0.137
309      per.disc =~      backward.span     2     2     1 10.411 -0.521  -0.434
307      per.disc =~ WCST.Persev.Errors     2     2     1 10.333  0.368   0.307
299 semantic.disc =~      backward.span     2     2     1  9.900 -0.592  -0.286
    sepc.all sepc.nox
444   -1.256   -1.256
439   -0.306   -0.306
441    0.568    0.568
349    1.293    1.293
443    2.296    2.296
437    0.532    0.532
355    0.280    0.280
309   -0.436   -0.436
307    0.410    0.410
299   -0.287   -0.287
## Inspecting correlations
 
lavInspect(initial.fit, "cor.ov")
$OA
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.309  1.000                                   
MVPT                           0.414  0.136  1.000                            
OOO.High.Hit.Rate              0.277  0.091  0.395  1.000                     
OOO.Color.Hit.Rate             0.116  0.038  0.165  0.302  1.000              
OOO.Size.Hit.Rate              0.270  0.089  0.384  0.577  0.358  1.000       
WCST.Persev.Errors             0.212  0.070  0.206  0.138  0.058  0.134  1.000
Arithmetic                     0.435  0.143  0.421  0.283  0.118  0.275  0.248
backward.span                  0.253  0.083  0.245  0.164  0.069  0.160  0.144
letter.numbering               0.297  0.098  0.287  0.193  0.080  0.187  0.169
cat.drm.FA.Related.Rates      -0.203 -0.067 -0.279 -0.187 -0.078 -0.182 -0.169
schematic.FA.Related.Rates    -0.107 -0.035 -0.147 -0.099 -0.041 -0.096 -0.089
object.sim.FA.Related.Rates   -0.251 -0.083 -0.311 -0.208 -0.087 -0.203 -0.132
abstract.img.FA.Related.Rates -0.109 -0.036 -0.135 -0.091 -0.038 -0.088 -0.058
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.296  1.000                                   
letter.numbering               0.346  0.202  1.000                            
cat.drm.FA.Related.Rates      -0.346 -0.202 -0.236  1.000                     
schematic.FA.Related.Rates    -0.183 -0.106 -0.125  0.188  1.000              
object.sim.FA.Related.Rates   -0.271 -0.158 -0.185  0.489  0.258  1.000       
abstract.img.FA.Related.Rates -0.118 -0.069 -0.080  0.213  0.112  0.446  1.000

$YA
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.437  1.000                                   
MVPT                           0.373  0.458  1.000                            
OOO.High.Hit.Rate              0.280  0.344  0.542  1.000                     
OOO.Color.Hit.Rate             0.222  0.272  0.428  0.497  1.000              
OOO.Size.Hit.Rate              0.219  0.269  0.424  0.425  0.454  1.000       
WCST.Persev.Errors             0.069  0.084  0.233  0.175  0.138  0.137  1.000
Arithmetic                     0.116  0.142  0.394  0.296  0.234  0.231  0.251
backward.span                  0.117  0.143  0.396  0.297  0.235  0.232  0.252
letter.numbering               0.094  0.116  0.320  0.241  0.190  0.188  0.204
cat.drm.FA.Related.Rates      -0.179 -0.220 -0.338 -0.254 -0.201 -0.199 -0.161
schematic.FA.Related.Rates    -0.109 -0.133 -0.206 -0.154 -0.122 -0.121 -0.098
object.sim.FA.Related.Rates   -0.207 -0.254 -0.396 -0.298 -0.235 -0.233 -0.125
abstract.img.FA.Related.Rates -0.145 -0.178 -0.278 -0.209 -0.165 -0.163 -0.088
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.427  1.000                                   
letter.numbering               0.345  0.347  1.000                            
cat.drm.FA.Related.Rates      -0.272 -0.274 -0.222  1.000                     
schematic.FA.Related.Rates    -0.166 -0.166 -0.135  0.335  1.000              
object.sim.FA.Related.Rates   -0.211 -0.212 -0.172  0.595  0.362  1.000       
abstract.img.FA.Related.Rates -0.148 -0.149 -0.121  0.418  0.254  0.534  1.000
lavInspect(initial.fit, "cor.lv")
$OA
              smntc.d pr.dsc exc.fn smntc.f per.fm
semantic.disc   1.000                             
per.disc        0.556  1.000                      
exec.func       0.630  0.770  1.000               
semantic.fm    -0.352 -0.609 -0.815   1.000       
per.fm         -0.256 -0.400 -0.376   0.811  1.000

$YA
              smntc.d pr.dsc exc.fn smntc.f per.fm
semantic.disc   1.000                             
per.disc        0.736  1.000                      
exec.func       0.298  0.711  1.000               
semantic.fm    -0.404 -0.536 -0.563   1.000       
per.fm         -0.398 -0.535 -0.372   0.919  1.000
# Covariance matrix determinent
det(lavInspect(initial.fit, "cov.lv")$OA) # negative determinant
[1] -1.204078e-05
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.initial = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.model.initial = withCallingHandlers(
  expr = {
   sem(initial.model, 
                     missing = 'ML', 
                     data = data.z, 
                     group = 'Group')
  },
  warning = function(w) {
    warnings.initial <<- c(warnings.initial, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.initial) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.initial = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.initial, 
                                       collapse = "; ")))
} else {
  # If no warnings, set combined.warning to "No warnings"
  combined.warning.initial = "No warnings."
}


## Saving fit measures

initial.measures = as.data.frame(fitMeasures(initial.fit))
initial.measures[, 1] = as.numeric(initial.measures[, 1])

rm(warnings.model.initial, warnings.initial)

Initial Model Results:

  • Warnings: “some estimated ov variances are negative; covariance matrix of latent variables is not positive definite in group 1; use lavInspect(fit,”cov.lv”) to investigate.”
  • Chi-squared: X 2 (132) = 189.677, p = 0.001
  • CFI: 0.949
  • TLI: 0.93
  • RMSEA: 0.049 [0.032, 0.064] 90% CI
  • SRMR: 0.06

Although there is some indication of satisfactory model fit (e.g., RMSEA, SRMR), the chi-square test of model fit is significant.

Additionally, we get two errors indicating that 1) the variance associated with perceptual false memory is negative (i.e., a Heywood case) and 2) the latent covariance matrix is not positive definite. Both suggest potential model misspecification.

Given these issues, I chose to return to a stratified analysis to troubleshoot.

OA CFAs

Comparing the fit of three theory-driven measurement models in OAs: 1) A CFA with three cognitive factors and two false memory factors 2) A CFA with three cognitive factors and a single false memory factor 3) A CFA with a single cognitive factor and two false memory factors

Model 1-OA:

oa.cfa.1 = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    semantic.fm =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates
    per.fm =~ object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

oa.cfa.1.fit = sem(oa.cfa.1, 
                   missing = 'ML',
                   data = filter(data.z, Group == "OA"))
Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
variances are negative
Warning in lav_object_post_check(object): lavaan WARNING: covariance matrix of latent variables
                is not positive definite;
                use lavInspect(fit, "cov.lv") to investigate.
semPaths(oa.cfa.1.fit, layout = "circle", 
         residuals = FALSE, 
         intercepts = FALSE, 
         latents = c("semantic.disc", "exec.func", "per.disc",
                     "semantic.fm", "per.fm"), 
         #whatLabels = "std", 
         fixedStyle = c("black", 1), 
         nodeLabels = c("PPVT", "PPT", "WCST", "Arithmetic", 
                        "Backward\nSpan", "Letter\nNumbering", 
                        "MVPT", "OOO - High", "OOO - Color", "OOO - Size", 
                        "Categorical\nDRM FM", "Schematic\nFM", "Object Sim.\nFM", "Abstract\nImages FM",
                        "Semantic\nDiscrimination", "Frontal\nFunctioning", "Perceptual\nDiscrimination",
                        "False Memory\n(Semantic)", "False Memory\n(Perceptual)"), 
         sizeMan2 = 7, 
         sizeMan = 11,  
         sizeLat = 11,
         asize = 3.5, 
         esize = 2,
         border.width = 2,
         #edge.label.cex = 0.5,
         #edge.label.margin = 0.005,
         edge.color = "black", 
         #edge.label.color = "black",
         fade = FALSE,
         gray = FALSE,
         font = 8,
         label.scale = FALSE,
         label.cex = 0.575,           
         curve = 1.25,           
         mar = c(3,2,3,2)) 

title("Model 1", line = 3)

# Model Results

summary(oa.cfa.1.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 72 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        55

  Number of observations                           152
  Number of missing patterns                        10

Model Test User Model:
                                                      
  Test statistic                                72.181
  Degrees of freedom                                64
  P-value (Chi-square)                           0.226

Model Test Baseline Model:

  Test statistic                               459.020
  Degrees of freedom                                91
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.978
  Tucker-Lewis Index (TLI)                       0.968
                                                      
  Robust Comparative Fit Index (CFI)             0.973
  Robust Tucker-Lewis Index (TLI)                0.962

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -2397.905
  Loglikelihood unrestricted model (H1)      -2361.815
                                                      
  Akaike (AIC)                                4905.810
  Bayesian (BIC)                              5072.124
  Sample-size adjusted Bayesian (SABIC)       4898.050

Root Mean Square Error of Approximation:

  RMSEA                                          0.029
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.058
  P-value H_0: RMSEA <= 0.050                    0.862
  P-value H_0: RMSEA >= 0.080                    0.001
                                                      
  Robust RMSEA                                   0.032
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.063
  P-value H_0: Robust RMSEA <= 0.050             0.804
  P-value H_0: Robust RMSEA >= 0.080             0.002

Standardized Root Mean Square Residual:

  SRMR                                           0.061

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.disc =~                                                      
    PPVT              1.000                               0.352    0.973
    PPT               0.459    0.204    2.249    0.025    0.161    0.317
  per.disc =~                                                           
    MVPT              1.000                               0.755    0.768
    OOO.High.Ht.Rt    0.662    0.145    4.570    0.000    0.500    0.514
    OOO.Colr.Ht.Rt    0.299    0.144    2.078    0.038    0.226    0.214
    OOO.Size.Ht.Rt    0.558    0.120    4.634    0.000    0.421    0.500
  exec.func =~                                                          
    WCST.Prsv.Errr    1.000                               0.427    0.348
    Arithmetic        1.536    0.440    3.490    0.000    0.656    0.715
    backward.span     0.969    0.324    2.989    0.003    0.414    0.415
    letter.numbrng    1.015    0.329    3.085    0.002    0.433    0.486
  semantic.fm =~                                                        
    ct.drm.FA.Rl.R    1.000                               0.537    0.596
    schmtc.FA.Rl.R    0.613    0.233    2.628    0.009    0.329    0.314
  per.fm =~                                                             
    objct.s.FA.R.R    1.000                               0.888    1.014
    abstrc..FA.R.R    0.451    0.144    3.144    0.002    0.401    0.440

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.196    0.080    2.462    0.014    0.196    0.228
   .OOO.Size.Ht.Rt         0.262    0.065    4.021    0.000    0.262    0.430
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.223    0.070    3.177    0.001    0.223    0.297
  semantic.disc ~~                                                           
    per.disc               0.147    0.031    4.690    0.000    0.553    0.553
    exec.func              0.094    0.030    3.183    0.001    0.626    0.626
    semantic.fm           -0.067    0.027   -2.450    0.014   -0.355   -0.355
    per.fm                -0.082    0.027   -3.044    0.002   -0.262   -0.262
  per.disc ~~                                                                
    exec.func              0.248    0.080    3.088    0.002    0.769    0.769
    semantic.fm           -0.248    0.076   -3.278    0.001   -0.611   -0.611
    per.fm                -0.267    0.072   -3.702    0.000   -0.398   -0.398
  exec.func ~~                                                               
    semantic.fm           -0.186    0.066   -2.805    0.005   -0.812   -0.812
    per.fm                -0.141    0.055   -2.567    0.010   -0.371   -0.371
  semantic.fm ~~                                                             
    per.fm                 0.386    0.071    5.431    0.000    0.808    0.808

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.874    0.029   29.823    0.000    0.874    2.419
   .PPT               0.654    0.041   15.868    0.000    0.654    1.287
   .MVPT             -0.213    0.080   -2.678    0.007   -0.213   -0.217
   .OOO.High.Ht.Rt   -0.248    0.079   -3.149    0.002   -0.248   -0.255
   .OOO.Colr.Ht.Rt   -0.376    0.086   -4.400    0.000   -0.376   -0.357
   .OOO.Size.Ht.Rt    0.125    0.068    1.833    0.067    0.125    0.149
   .WCST.Prsv.Errr   -0.268    0.102   -2.629    0.009   -0.268   -0.219
   .Arithmetic        0.299    0.074    4.016    0.000    0.299    0.326
   .backward.span     0.084    0.081    1.036    0.300    0.084    0.084
   .letter.numbrng   -0.144    0.072   -1.993    0.046   -0.144   -0.162
   .ct.drm.FA.Rl.R   -0.154    0.074   -2.083    0.037   -0.154   -0.171
   .schmtc.FA.Rl.R    0.082    0.103    0.794    0.427    0.082    0.078
   .objct.s.FA.R.R    0.034    0.072    0.475    0.635    0.034    0.039
   .abstrc..FA.R.R    0.262    0.074    3.529    0.000    0.262    0.288

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.007    0.047    0.151    0.880    0.007    0.054
   .PPT               0.232    0.028    8.181    0.000    0.232    0.899
   .MVPT              0.395    0.110    3.578    0.000    0.395    0.410
   .OOO.High.Ht.Rt    0.694    0.094    7.379    0.000    0.694    0.735
   .OOO.Colr.Ht.Rt    1.061    0.125    8.515    0.000    1.061    0.954
   .OOO.Size.Ht.Rt    0.532    0.071    7.549    0.000    0.532    0.750
   .WCST.Prsv.Errr    1.323    0.163    8.099    0.000    1.323    0.879
   .Arithmetic        0.412    0.077    5.373    0.000    0.412    0.489
   .backward.span     0.824    0.102    8.050    0.000    0.824    0.828
   .letter.numbrng    0.609    0.078    7.758    0.000    0.609    0.764
   .ct.drm.FA.Rl.R    0.524    0.141    3.717    0.000    0.524    0.645
   .schmtc.FA.Rl.R    0.987    0.147    6.714    0.000    0.987    0.901
   .objct.s.FA.R.R   -0.021    0.211   -0.099    0.921   -0.021   -0.027
   .abstrc..FA.R.R    0.671    0.089    7.561    0.000    0.671    0.807
    semantic.disc     0.124    0.049    2.526    0.012    1.000    1.000
    per.disc          0.570    0.143    3.995    0.000    1.000    1.000
    exec.func         0.182    0.098    1.858    0.063    1.000    1.000
    semantic.fm       0.288    0.148    1.954    0.051    1.000    1.000
    per.fm            0.789    0.230    3.429    0.001    1.000    1.000

R-Square:
                   Estimate
    PPVT              0.946
    PPT               0.101
    MVPT              0.590
    OOO.High.Ht.Rt    0.265
    OOO.Colr.Ht.Rt    0.046
    OOO.Size.Ht.Rt    0.250
    WCST.Prsv.Errr    0.121
    Arithmetic        0.511
    backward.span     0.172
    letter.numbrng    0.236
    ct.drm.FA.Rl.R    0.355
    schmtc.FA.Rl.R    0.099
    objct.s.FA.R.R       NA
    abstrc..FA.R.R    0.193
modindices(oa.cfa.1.fit, sort = TRUE, maximum.number = 10)
                           lhs op                         rhs    mi    epc
95                   exec.func =~  schematic.FA.Related.Rates 8.481  1.304
94                   exec.func =~    cat.drm.FA.Related.Rates 8.481 -2.128
207 schematic.FA.Related.Rates ~~ object.sim.FA.Related.Rates 7.886  0.282
85                    per.disc =~  schematic.FA.Related.Rates 7.432  0.639
84                    per.disc =~    cat.drm.FA.Related.Rates 7.432 -1.042
120                     per.fm =~    cat.drm.FA.Related.Rates 5.770 -0.984
121                     per.fm =~  schematic.FA.Related.Rates 5.770  0.603
179          OOO.Size.Hit.Rate ~~  schematic.FA.Related.Rates 5.003  0.146
102                semantic.fm =~          OOO.Color.Hit.Rate 4.922 -0.517
169         OOO.Color.Hit.Rate ~~            letter.numbering 4.875  0.142
    sepc.lv sepc.all sepc.nox
95    0.557    0.532    0.532
94   -0.909   -1.009   -1.009
207   0.282    1.963    1.963
85    0.482    0.461    0.461
84   -0.787   -0.873   -0.873
120  -0.874   -0.970   -0.970
121   0.536    0.512    0.512
179   0.146    0.201    0.201
102  -0.278   -0.263   -0.263
169   0.142    0.177    0.177
# Standardized factor loadings

inspect(oa.cfa.1.fit, what = "std")$lambda
                              smntc.d pr.dsc exc.fn smntc.f per.fm
PPVT                            0.973  0.000  0.000   0.000  0.000
PPT                             0.317  0.000  0.000   0.000  0.000
MVPT                            0.000  0.768  0.000   0.000  0.000
OOO.High.Hit.Rate               0.000  0.514  0.000   0.000  0.000
OOO.Color.Hit.Rate              0.000  0.214  0.000   0.000  0.000
OOO.Size.Hit.Rate               0.000  0.500  0.000   0.000  0.000
WCST.Persev.Errors              0.000  0.000  0.348   0.000  0.000
Arithmetic                      0.000  0.000  0.715   0.000  0.000
backward.span                   0.000  0.000  0.415   0.000  0.000
letter.numbering                0.000  0.000  0.486   0.000  0.000
cat.drm.FA.Related.Rates        0.000  0.000  0.000   0.596  0.000
schematic.FA.Related.Rates      0.000  0.000  0.000   0.314  0.000
object.sim.FA.Related.Rates     0.000  0.000  0.000   0.000  1.014
abstract.img.FA.Related.Rates   0.000  0.000  0.000   0.000  0.440
## Inspecting correlations
 
lavInspect(oa.cfa.1.fit, "cor.ov")
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.309  1.000                                   
MVPT                           0.413  0.135  1.000                            
OOO.High.Hit.Rate              0.277  0.090  0.395  1.000                     
OOO.Color.Hit.Rate             0.115  0.038  0.165  0.302  1.000              
OOO.Size.Hit.Rate              0.269  0.088  0.384  0.577  0.358  1.000       
WCST.Persev.Errors             0.212  0.069  0.206  0.138  0.057  0.134  1.000
Arithmetic                     0.435  0.142  0.422  0.283  0.118  0.275  0.249
backward.span                  0.252  0.082  0.245  0.164  0.068  0.159  0.144
letter.numbering               0.296  0.096  0.287  0.192  0.080  0.187  0.169
cat.drm.FA.Related.Rates      -0.206 -0.067 -0.280 -0.187 -0.078 -0.182 -0.168
schematic.FA.Related.Rates    -0.109 -0.035 -0.148 -0.099 -0.041 -0.096 -0.089
object.sim.FA.Related.Rates   -0.258 -0.084 -0.310 -0.208 -0.086 -0.202 -0.131
abstract.img.FA.Related.Rates -0.112 -0.037 -0.134 -0.090 -0.038 -0.088 -0.057
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.296  1.000                                   
letter.numbering               0.347  0.201  1.000                            
cat.drm.FA.Related.Rates      -0.346 -0.201 -0.235  1.000                     
schematic.FA.Related.Rates    -0.182 -0.106 -0.124  0.187  1.000              
object.sim.FA.Related.Rates   -0.269 -0.156 -0.183  0.488  0.258  1.000       
abstract.img.FA.Related.Rates -0.117 -0.068 -0.079  0.212  0.112  0.446  1.000
lavInspect(oa.cfa.1.fit, "cor.lv")
              smntc.d pr.dsc exc.fn smntc.f per.fm
semantic.disc   1.000                             
per.disc        0.553  1.000                      
exec.func       0.626  0.769  1.000               
semantic.fm    -0.355 -0.611 -0.812   1.000       
per.fm         -0.262 -0.398 -0.371   0.808  1.000
# Covariance matrix determinent
det(lavInspect(oa.cfa.1.fit, "cov.lv"))
[1] -9.04941e-06
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.1 = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.model.1 = withCallingHandlers(
  expr = {
    sem(oa.cfa.1, 
                   missing = 'ML',
                   data = filter(data.z, Group == "OA"))
  },
  warning = function(w) {
    warnings.1 <<- c(warnings.1, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.1) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.1 = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.1, collapse = "; ")))
} else {
  # If no warnings, set combined.warning to "No warnings"
  combined.warning.1 = "No warnings."
}


## Saving fit measures

oa.cfa.1.measures = as.data.frame(fitMeasures(oa.cfa.1.fit))
oa.cfa.1.measures[, 1] = as.numeric(oa.cfa.1.measures[, 1])

rm(warnings.model.1, warnings.1)

Model 2-OA:

oa.cfa.2 = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    FM =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates +
    object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

oa.cfa.2.fit = sem(oa.cfa.2, 
                   missing = 'ML',
                   data = filter(data.z, Group == "OA"))

semPaths(oa.cfa.2.fit, layout = "circle", 
         residuals = FALSE, 
         intercepts = FALSE, 
         latents = c("semantic.disc", "exec.func", "per.disc",
                     "FM"), 
         #whatLabels = "std", 
         fixedStyle = c("black", 1), 
         nodeLabels = c("PPVT", "PPT", "WCST", "Arithmetic", 
                        "Backward\nSpan", "Letter\nNumbering", 
                        "MVPT", "OOO - High", "OOO - Color", "OOO - Size", 
                        "Categorical\nDRM FM", "Schematic\nFM", "Object Sim.\nFM", "Abstract\nImages FM",
                        "Semantic\nDiscrimination", "Frontal\nFunctioning", "Perceptual\nDiscrimination",
                        "False Memory\n(General)"), 
        sizeMan2 = 7, 
         sizeMan = 11,  
         sizeLat = 11,
         asize = 3.5, 
         esize = 2,
         border.width = 2,
         #edge.label.cex = 0.5,
         #edge.label.margin = 0.005,
         edge.color = "black", 
         #edge.label.color = "black",
         fade = FALSE,
         gray = FALSE,
         font = 8,
         label.scale = FALSE,
         label.cex = 0.575,           
         curve = 1.25,           
         mar = c(3,2,3,2)) 

title("Model 2", line = 3)

# Model Results

summary(oa.cfa.2.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 64 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        51

  Number of observations                           152
  Number of missing patterns                        10

Model Test User Model:
                                                      
  Test statistic                                83.456
  Degrees of freedom                                68
  P-value (Chi-square)                           0.098

Model Test Baseline Model:

  Test statistic                               459.020
  Degrees of freedom                                91
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.958
  Tucker-Lewis Index (TLI)                       0.944
                                                      
  Robust Comparative Fit Index (CFI)             0.955
  Robust Tucker-Lewis Index (TLI)                0.939

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -2403.543
  Loglikelihood unrestricted model (H1)      -2361.815
                                                      
  Akaike (AIC)                                4909.085
  Bayesian (BIC)                              5063.303
  Sample-size adjusted Bayesian (SABIC)       4901.889

Root Mean Square Error of Approximation:

  RMSEA                                          0.039
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.064
  P-value H_0: RMSEA <= 0.050                    0.740
  P-value H_0: RMSEA >= 0.080                    0.002
                                                      
  Robust RMSEA                                   0.041
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.068
  P-value H_0: Robust RMSEA <= 0.050             0.682
  P-value H_0: Robust RMSEA >= 0.080             0.006

Standardized Root Mean Square Residual:

  SRMR                                           0.065

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.disc =~                                                      
    PPVT              1.000                               0.347    0.961
    PPT               0.470    0.205    2.294    0.022    0.163    0.321
  per.disc =~                                                           
    MVPT              1.000                               0.747    0.760
    OOO.High.Ht.Rt    0.676    0.146    4.637    0.000    0.505    0.520
    OOO.Colr.Ht.Rt    0.311    0.146    2.125    0.034    0.232    0.220
    OOO.Size.Ht.Rt    0.570    0.122    4.693    0.000    0.426    0.505
  exec.func =~                                                          
    WCST.Prsv.Errr    1.000                               0.411    0.335
    Arithmetic        1.574    0.474    3.322    0.001    0.647    0.705
    backward.span     1.011    0.350    2.884    0.004    0.416    0.417
    letter.numbrng    1.093    0.367    2.981    0.003    0.450    0.504
  FM =~                                                                 
    ct.drm.FA.Rl.R    1.000                               0.492    0.547
    schmtc.FA.Rl.R    0.737    0.258    2.859    0.004    0.362    0.347
    objct.s.FA.R.R    1.561    0.389    4.010    0.000    0.768    0.875
    abstrc..FA.R.R    0.896    0.214    4.181    0.000    0.441    0.483

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.192    0.080    2.410    0.016    0.192    0.225
   .OOO.Size.Ht.Rt         0.257    0.065    3.965    0.000    0.257    0.426
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.219    0.070    3.129    0.002    0.219    0.293
  semantic.disc ~~                                                           
    per.disc               0.146    0.031    4.654    0.000    0.561    0.561
    exec.func              0.091    0.030    3.076    0.002    0.637    0.637
    FM                    -0.052    0.020   -2.538    0.011   -0.302   -0.302
  per.disc ~~                                                                
    exec.func              0.237    0.080    2.962    0.003    0.770    0.770
    FM                    -0.182    0.064   -2.856    0.004   -0.494   -0.494
  exec.func ~~                                                               
    FM                    -0.097    0.046   -2.104    0.035   -0.481   -0.481

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.874    0.029   29.823    0.000    0.874    2.419
   .PPT               0.654    0.041   15.868    0.000    0.654    1.287
   .MVPT             -0.213    0.080   -2.678    0.007   -0.213   -0.217
   .OOO.High.Ht.Rt   -0.248    0.079   -3.149    0.002   -0.248   -0.255
   .OOO.Colr.Ht.Rt   -0.376    0.086   -4.400    0.000   -0.376   -0.357
   .OOO.Size.Ht.Rt    0.125    0.068    1.833    0.067    0.125    0.149
   .WCST.Prsv.Errr   -0.268    0.102   -2.624    0.009   -0.268   -0.218
   .Arithmetic        0.299    0.074    4.016    0.000    0.299    0.326
   .backward.span     0.084    0.081    1.036    0.300    0.084    0.084
   .letter.numbrng   -0.144    0.072   -1.993    0.046   -0.144   -0.162
   .ct.drm.FA.Rl.R   -0.149    0.074   -2.022    0.043   -0.149   -0.166
   .schmtc.FA.Rl.R    0.077    0.102    0.756    0.450    0.077    0.074
   .objct.s.FA.R.R    0.035    0.072    0.488    0.625    0.035    0.040
   .abstrc..FA.R.R    0.263    0.074    3.539    0.000    0.263    0.289

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.010    0.045    0.226    0.821    0.010    0.077
   .PPT               0.231    0.028    8.170    0.000    0.231    0.897
   .MVPT              0.408    0.108    3.771    0.000    0.408    0.422
   .OOO.High.Ht.Rt    0.688    0.094    7.344    0.000    0.688    0.730
   .OOO.Colr.Ht.Rt    1.058    0.124    8.499    0.000    1.058    0.951
   .OOO.Size.Ht.Rt    0.529    0.070    7.510    0.000    0.529    0.745
   .WCST.Prsv.Errr    1.336    0.165    8.090    0.000    1.336    0.888
   .Arithmetic        0.424    0.080    5.271    0.000    0.424    0.503
   .backward.span     0.822    0.103    7.964    0.000    0.822    0.826
   .letter.numbrng    0.594    0.079    7.542    0.000    0.594    0.746
   .ct.drm.FA.Rl.R    0.567    0.088    6.449    0.000    0.567    0.701
   .schmtc.FA.Rl.R    0.957    0.140    6.852    0.000    0.957    0.879
   .objct.s.FA.R.R    0.181    0.115    1.573    0.116    0.181    0.235
   .abstrc..FA.R.R    0.637    0.080    7.973    0.000    0.637    0.766
    semantic.disc     0.121    0.047    2.560    0.010    1.000    1.000
    per.disc          0.557    0.140    3.986    0.000    1.000    1.000
    exec.func         0.169    0.096    1.763    0.078    1.000    1.000
    FM                0.242    0.090    2.705    0.007    1.000    1.000

R-Square:
                   Estimate
    PPVT              0.923
    PPT               0.103
    MVPT              0.578
    OOO.High.Ht.Rt    0.270
    OOO.Colr.Ht.Rt    0.049
    OOO.Size.Ht.Rt    0.255
    WCST.Prsv.Errr    0.112
    Arithmetic        0.497
    backward.span     0.174
    letter.numbrng    0.254
    ct.drm.FA.Rl.R    0.299
    schmtc.FA.Rl.R    0.121
    objct.s.FA.R.R    0.765
    abstrc..FA.R.R    0.234
modindices(oa.cfa.2.fit, sort = TRUE, maximum.number = 10)
                            lhs op                           rhs     mi    epc
88                    exec.func =~      cat.drm.FA.Related.Rates 14.581 -0.977
78                     per.disc =~      cat.drm.FA.Related.Rates  9.611 -0.448
171                  Arithmetic ~~      cat.drm.FA.Related.Rates  5.573 -0.117
189 object.sim.FA.Related.Rates ~~ abstract.img.FA.Related.Rates  5.324  0.218
159           OOO.Size.Hit.Rate ~~    schematic.FA.Related.Rates  5.042  0.144
131                        MVPT ~~                    Arithmetic  5.012  0.139
149          OOO.Color.Hit.Rate ~~              letter.numbering  4.901  0.142
133                        MVPT ~~              letter.numbering  4.821 -0.125
96                           FM =~            OOO.Color.Hit.Rate  4.406 -0.479
185    cat.drm.FA.Related.Rates ~~   object.sim.FA.Related.Rates  4.158 -0.224
    sepc.lv sepc.all sepc.nox
88   -0.402   -0.447   -0.447
78   -0.335   -0.372   -0.372
171  -0.117   -0.238   -0.238
189   0.218    0.642    0.642
159   0.144    0.203    0.203
131   0.139    0.334    0.334
149   0.142    0.179    0.179
133  -0.125   -0.253   -0.253
96   -0.236   -0.224   -0.224
185  -0.224   -0.697   -0.697
# Standardized factor loadings

inspect(oa.cfa.2.fit, what = "std")$lambda
                              smntc. pr.dsc exc.fn    FM
PPVT                           0.961  0.000  0.000 0.000
PPT                            0.321  0.000  0.000 0.000
MVPT                           0.000  0.760  0.000 0.000
OOO.High.Hit.Rate              0.000  0.520  0.000 0.000
OOO.Color.Hit.Rate             0.000  0.220  0.000 0.000
OOO.Size.Hit.Rate              0.000  0.505  0.000 0.000
WCST.Persev.Errors             0.000  0.000  0.335 0.000
Arithmetic                     0.000  0.000  0.705 0.000
backward.span                  0.000  0.000  0.417 0.000
letter.numbering               0.000  0.000  0.504 0.000
cat.drm.FA.Related.Rates       0.000  0.000  0.000 0.547
schematic.FA.Related.Rates     0.000  0.000  0.000 0.347
object.sim.FA.Related.Rates    0.000  0.000  0.000 0.875
abstract.img.FA.Related.Rates  0.000  0.000  0.000 0.483
## Inspecting correlations
 
lavInspect(oa.cfa.2.fit, "cor.ov")
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.309  1.000                                   
MVPT                           0.410  0.137  1.000                            
OOO.High.Hit.Rate              0.280  0.094  0.395  1.000                     
OOO.Color.Hit.Rate             0.119  0.040  0.167  0.302  1.000              
OOO.Size.Hit.Rate              0.273  0.091  0.384  0.577  0.358  1.000       
WCST.Persev.Errors             0.205  0.069  0.196  0.134  0.057  0.131  1.000
Arithmetic                     0.432  0.144  0.413  0.282  0.120  0.275  0.236
backward.span                  0.255  0.085  0.244  0.167  0.071  0.162  0.140
letter.numbering               0.308  0.103  0.295  0.202  0.085  0.196  0.169
cat.drm.FA.Related.Rates      -0.158 -0.053 -0.205 -0.141 -0.060 -0.137 -0.088
schematic.FA.Related.Rates    -0.101 -0.034 -0.131 -0.089 -0.038 -0.087 -0.056
object.sim.FA.Related.Rates   -0.253 -0.085 -0.329 -0.225 -0.095 -0.218 -0.141
abstract.img.FA.Related.Rates -0.140 -0.047 -0.182 -0.124 -0.053 -0.121 -0.078
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.294  1.000                                   
letter.numbering               0.355  0.210  1.000                            
cat.drm.FA.Related.Rates      -0.185 -0.110 -0.132  1.000                     
schematic.FA.Related.Rates    -0.118 -0.070 -0.084  0.190  1.000              
object.sim.FA.Related.Rates   -0.296 -0.175 -0.212  0.478  0.304  1.000       
abstract.img.FA.Related.Rates -0.164 -0.097 -0.117  0.264  0.168  0.423  1.000
lavInspect(oa.cfa.2.fit, "cor.lv")
              smntc. pr.dsc exc.fn     FM
semantic.disc  1.000                     
per.disc       0.561  1.000              
exec.func      0.637  0.770  1.000       
FM            -0.302 -0.494 -0.481  1.000
# Covariance matrix determinent
det(lavInspect(oa.cfa.2.fit, "cov.lv"))
[1] 0.0004749246
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.2 = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.model.2 = withCallingHandlers(
  expr = {
    sem(oa.cfa.2, 
                   missing = 'ML',
                   data = filter(data.z, Group == "OA"))
  },
  warning = function(w) {
    warnings.2 <<- c(warnings.2, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.2) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.2 = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.2, collapse = "; ")))
} else {
  # If no warnings, set combined.warning to "No warnings"
  combined.warning.2 = "No warnings."
}


## Saving fit measures

oa.cfa.2.measures = as.data.frame(fitMeasures(oa.cfa.2.fit))
oa.cfa.2.measures[, 1] = as.numeric(oa.cfa.2.measures[, 1])

rm(warnings.model.2, warnings.2)

Model 3-OA:

oa.cfa.3 = '
  # measurement model
    cognitive.ability =~ PPVT + PPT + 
    MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate + 
    WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    semantic.fm =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates
    per.fm =~ object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

oa.cfa.3.fit = sem(oa.cfa.3, 
                   missing = 'ML',
                   data = filter(data.z, Group == "OA"))
Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
variances are negative
semPaths(oa.cfa.3.fit, layout = "circle", 
         residuals = FALSE, 
         intercepts = FALSE, 
         latents = c("cognitive.ability",
                     "semantic.fm", "per.fm"), 
         #whatLabels = "std", 
         fixedStyle = c("black", 1), 
         nodeLabels = c("PPVT", "PPT", 
                        "MVPT", "OOO - High", "OOO - Color", "OOO - Size", 
                        "WCST", "Arithmetic", "Backward\nSpan", "Letter\nNumbering",
                        "Categorical\nDRM FM", "Schematic\nFM", "Object Sim.\nFM", 
                        "Abstract\nImages FM",
                        "Cognitive\nAbility",
                        "False Memory\n(Semantic)", "False Memory\n(Perceptual)"), 
         sizeMan2 = 7, 
         sizeMan = 11,  
         sizeLat = 11,
         asize = 3.5, 
         esize = 2,
         border.width = 2,
         #edge.label.cex = 0.5,
         #edge.label.margin = 0.005,
         edge.color = "black", 
         #edge.label.color = "black",
         fade = FALSE,
         gray = FALSE,
         font = 8,
         label.scale = FALSE,
         label.cex = 0.575,           
         curve = 1.25,           
         mar = c(3,2,3,2)) 

title("Model 3", line = 3)

# Model Results

summary(oa.cfa.3.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 57 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        48

  Number of observations                           152
  Number of missing patterns                        10

Model Test User Model:
                                                      
  Test statistic                                89.726
  Degrees of freedom                                71
  P-value (Chi-square)                           0.066

Model Test Baseline Model:

  Test statistic                               459.020
  Degrees of freedom                                91
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.949
  Tucker-Lewis Index (TLI)                       0.935
                                                      
  Robust Comparative Fit Index (CFI)             0.942
  Robust Tucker-Lewis Index (TLI)                0.926

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -2406.678
  Loglikelihood unrestricted model (H1)      -2361.815
                                                      
  Akaike (AIC)                                4909.355
  Bayesian (BIC)                              5054.502
  Sample-size adjusted Bayesian (SABIC)       4902.583

Root Mean Square Error of Approximation:

  RMSEA                                          0.042
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.066
  P-value H_0: RMSEA <= 0.050                    0.686
  P-value H_0: RMSEA >= 0.080                    0.003
                                                      
  Robust RMSEA                                   0.045
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.070
  P-value H_0: Robust RMSEA <= 0.050             0.597
  P-value H_0: Robust RMSEA >= 0.080             0.009

Standardized Root Mean Square Residual:

  SRMR                                           0.067

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian

Latent Variables:
                       Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  cognitive.ability =~                                                      
    PPVT                  1.000                               0.227    0.627
    PPT                   0.584    0.207    2.815    0.005    0.132    0.260
    MVPT                  2.901    0.478    6.073    0.000    0.657    0.669
    OOO.High.Ht.Rt        1.999    0.442    4.523    0.000    0.453    0.466
    OOO.Colr.Ht.Rt        0.897    0.446    2.011    0.044    0.203    0.193
    OOO.Size.Ht.Rt        1.646    0.377    4.367    0.000    0.373    0.443
    WCST.Prsv.Errr        1.918    0.547    3.506    0.000    0.434    0.354
    Arithmetic            2.761    0.449    6.156    0.000    0.626    0.681
    backward.span         1.659    0.434    3.823    0.000    0.376    0.377
    letter.numbrng        1.842    0.389    4.734    0.000    0.417    0.467
  semantic.fm =~                                                            
    ct.drm.FA.Rl.R        1.000                               0.543    0.603
    schmtc.FA.Rl.R        0.595    0.241    2.466    0.014    0.323    0.309
  per.fm =~                                                                 
    objct.s.FA.R.R        1.000                               0.899    1.026
    abstrc..FA.R.R        0.441    0.144    3.066    0.002    0.397    0.435

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.217    0.078    2.765    0.006    0.217    0.244
   .OOO.Size.Ht.Rt         0.303    0.064    4.715    0.000    0.303    0.467
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.242    0.070    3.475    0.001    0.242    0.310
  cognitive.ability ~~                                                       
    semantic.fm           -0.090    0.023   -3.836    0.000   -0.728   -0.728
    per.fm                -0.083    0.022   -3.800    0.000   -0.407   -0.407
  semantic.fm ~~                                                             
    per.fm                 0.385    0.071    5.423    0.000    0.788    0.788

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.874    0.029   29.823    0.000    0.874    2.419
   .PPT               0.654    0.041   15.868    0.000    0.654    1.287
   .MVPT             -0.213    0.080   -2.678    0.007   -0.213   -0.217
   .OOO.High.Ht.Rt   -0.248    0.079   -3.149    0.002   -0.248   -0.255
   .OOO.Colr.Ht.Rt   -0.376    0.086   -4.400    0.000   -0.376   -0.357
   .OOO.Size.Ht.Rt    0.125    0.068    1.833    0.067    0.125    0.149
   .WCST.Prsv.Errr   -0.270    0.102   -2.646    0.008   -0.270   -0.220
   .Arithmetic        0.299    0.074    4.016    0.000    0.299    0.326
   .backward.span     0.084    0.081    1.036    0.300    0.084    0.084
   .letter.numbrng   -0.144    0.072   -1.993    0.046   -0.144   -0.162
   .ct.drm.FA.Rl.R   -0.153    0.074   -2.070    0.038   -0.153   -0.170
   .schmtc.FA.Rl.R    0.087    0.103    0.848    0.396    0.087    0.083
   .objct.s.FA.R.R    0.033    0.072    0.466    0.641    0.033    0.038
   .abstrc..FA.R.R    0.263    0.074    3.531    0.000    0.263    0.288

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.079    0.011    7.051    0.000    0.079    0.607
   .PPT               0.241    0.028    8.531    0.000    0.241    0.932
   .MVPT              0.533    0.080    6.645    0.000    0.533    0.553
   .OOO.High.Ht.Rt    0.739    0.092    7.991    0.000    0.739    0.783
   .OOO.Colr.Ht.Rt    1.070    0.124    8.609    0.000    1.070    0.963
   .OOO.Size.Ht.Rt    0.571    0.071    8.061    0.000    0.571    0.804
   .WCST.Prsv.Errr    1.317    0.162    8.134    0.000    1.317    0.875
   .Arithmetic        0.451    0.069    6.559    0.000    0.451    0.536
   .backward.span     0.854    0.103    8.286    0.000    0.854    0.858
   .letter.numbrng    0.623    0.078    7.964    0.000    0.623    0.782
   .ct.drm.FA.Rl.R    0.517    0.147    3.507    0.000    0.517    0.637
   .schmtc.FA.Rl.R    0.992    0.148    6.715    0.000    0.992    0.905
   .objct.s.FA.R.R   -0.041    0.223   -0.182    0.855   -0.041   -0.053
   .abstrc..FA.R.R    0.674    0.089    7.559    0.000    0.674    0.811
    cognitive.blty    0.051    0.014    3.767    0.000    1.000    1.000
    semantic.fm       0.295    0.154    1.911    0.056    1.000    1.000
    per.fm            0.808    0.241    3.357    0.001    1.000    1.000

R-Square:
                   Estimate
    PPVT              0.393
    PPT               0.068
    MVPT              0.447
    OOO.High.Ht.Rt    0.217
    OOO.Colr.Ht.Rt    0.037
    OOO.Size.Ht.Rt    0.196
    WCST.Prsv.Errr    0.125
    Arithmetic        0.464
    backward.span     0.142
    letter.numbrng    0.218
    ct.drm.FA.Rl.R    0.363
    schmtc.FA.Rl.R    0.095
    objct.s.FA.R.R       NA
    abstrc..FA.R.R    0.189
modindices(oa.cfa.3.fit, sort = TRUE, maximum.number = 10)
                           lhs op                         rhs    mi    epc
56           cognitive.ability =~  schematic.FA.Related.Rates 8.247  2.518
55           cognitive.ability =~    cat.drm.FA.Related.Rates 8.247 -4.231
81                      per.fm =~    cat.drm.FA.Related.Rates 8.247 -1.290
82                      per.fm =~  schematic.FA.Related.Rates 8.246  0.768
168 schematic.FA.Related.Rates ~~ object.sim.FA.Related.Rates 8.096  0.290
83                        PPVT ~~                         PPT 7.171  0.034
114                       MVPT ~~            letter.numbering 5.816 -0.139
140          OOO.Size.Hit.Rate ~~  schematic.FA.Related.Rates 5.428  0.153
130         OOO.Color.Hit.Rate ~~            letter.numbering 4.809  0.143
156              backward.span ~~            letter.numbering 4.747  0.138
    sepc.lv sepc.all sepc.nox
56    0.570    0.545    0.545
55   -0.959   -1.064   -1.064
81   -1.160   -1.287   -1.287
82    0.690    0.659    0.659
168   0.290    1.444    1.444
83    0.034    0.244    0.244
114  -0.139   -0.241   -0.241
140   0.153    0.204    0.204
130   0.143    0.175    0.175
156   0.138    0.189    0.189
# Standardized factor loadings

inspect(oa.cfa.3.fit, what = "std")$lambda
                              cgntv. smntc. per.fm
PPVT                           0.627  0.000  0.000
PPT                            0.260  0.000  0.000
MVPT                           0.669  0.000  0.000
OOO.High.Hit.Rate              0.466  0.000  0.000
OOO.Color.Hit.Rate             0.193  0.000  0.000
OOO.Size.Hit.Rate              0.443  0.000  0.000
WCST.Persev.Errors             0.354  0.000  0.000
Arithmetic                     0.681  0.000  0.000
backward.span                  0.377  0.000  0.000
letter.numbering               0.467  0.000  0.000
cat.drm.FA.Related.Rates       0.000  0.603  0.000
schematic.FA.Related.Rates     0.000  0.309  0.000
object.sim.FA.Related.Rates    0.000  0.000  1.026
abstract.img.FA.Related.Rates  0.000  0.000  0.435
## Inspecting correlations
 
lavInspect(oa.cfa.3.fit, "cor.ov")
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.163  1.000                                   
MVPT                           0.419  0.174  1.000                            
OOO.High.Hit.Rate              0.292  0.121  0.312  1.000                     
OOO.Color.Hit.Rate             0.121  0.050  0.129  0.302  1.000              
OOO.Size.Hit.Rate              0.277  0.115  0.296  0.577  0.358  1.000       
WCST.Persev.Errors             0.222  0.092  0.237  0.165  0.068  0.157  1.000
Arithmetic                     0.427  0.177  0.456  0.318  0.131  0.302  0.241
backward.span                  0.236  0.098  0.252  0.176  0.073  0.167  0.133
letter.numbering               0.293  0.122  0.313  0.218  0.090  0.207  0.166
cat.drm.FA.Related.Rates      -0.275 -0.114 -0.293 -0.204 -0.085 -0.194 -0.155
schematic.FA.Related.Rates    -0.141 -0.058 -0.150 -0.105 -0.043 -0.099 -0.080
object.sim.FA.Related.Rates   -0.262 -0.109 -0.279 -0.195 -0.080 -0.185 -0.148
abstract.img.FA.Related.Rates -0.111 -0.046 -0.118 -0.083 -0.034 -0.078 -0.063
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.257  1.000                                   
letter.numbering               0.318  0.176  1.000                            
cat.drm.FA.Related.Rates      -0.299 -0.165 -0.205  1.000                     
schematic.FA.Related.Rates    -0.153 -0.085 -0.105  0.186  1.000              
object.sim.FA.Related.Rates   -0.285 -0.157 -0.195  0.488  0.250  1.000       
abstract.img.FA.Related.Rates -0.121 -0.067 -0.083  0.207  0.106  0.446  1.000
lavInspect(oa.cfa.3.fit, "cor.lv")
                  cgntv. smntc. per.fm
cognitive.ability  1.000              
semantic.fm       -0.728  1.000       
per.fm            -0.407  0.788  1.000
# Covariance matrix determinent
det(lavInspect(oa.cfa.3.fit, "cov.lv"))
[1] 0.001835717
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.3 = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.model.3 = withCallingHandlers(
  expr = {
    sem(oa.cfa.3, 
                   missing = 'ML',
                   data = filter(data.z, Group == "OA"))
  },
  warning = function(w) {
    warnings.3 <<- c(warnings.3, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.3) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.3 = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.3, collapse = "; ")))
} else {
  # If no warnings, set combined.warning to "No warnings"
  combined.warning.3 = "No warnings."
}


## Saving fit measures

oa.cfa.3.measures = as.data.frame(fitMeasures(oa.cfa.3.fit))
oa.cfa.3.measures[, 1] = as.numeric(oa.cfa.3.measures[, 1])

rm(warnings.model.3, warnings.3)

OA CFA Comparisons

Model 1 (Original):

  • Warnings: “some estimated ov variances are negative; covariance matrix of latent variables is not positive definite; use lavInspect(fit,”cov.lv”) to investigate.”
  • Chi-squared: X 2 (64) = 72.181, p = 0.226
  • CFI: 0.978
  • TLI: 0.968
  • RMSEA: 0.029 [0, 0.058] 90% CI
  • SRMR: 0.061

Model 2 (Single FM Factor):

  • Warnings: “No warnings.”
  • Chi-squared: X 2 (68) = 83.456, p = 0.098
  • CFI: 0.958
  • TLI: 0.944
  • RMSEA: 0.039 [0, 0.064] 90% CI
  • SRMR: 0.065

Model 3 (Single Cognitive Ability Factor):

  • Warnings: “some estimated ov variances are negative”
  • Chi-squared: X 2 (71) = 89.726, p = 0.066
  • CFI: 0.949
  • TLI: 0.935
  • RMSEA: 0.042 [0, 0.066] 90% CI
  • SRMR: 0.067

The CFA with false memory treated as a single factor is the only one that converges without warnings. Strong fit in model 1 despite warnings may indicate overfitting.

Comparing OA CFA models in terms of BIC/AIC. Lower values are better.

OA Model 1 OA Model 2 OA Model 3
BIC 5072.124 5063.303 5054.502
AIC 4905.81 4909.085 4909.355

BIC favors Model 3, whereas AIC favors Model 1. However, given that Model 2 is the only one to converge without warnings, this may be the optimal model for OAs.

YA CFAs

Comparing the three measurement models in YAs.

Model 1-YA:

ya.cfa.1 = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    semantic.fm =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates
    per.fm =~ object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

ya.cfa.1.fit = sem(ya.cfa.1, 
                   missing = 'ML',
                   data = filter(data.z, Group == "YA"))

summary(ya.cfa.1.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 60 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        55

  Number of observations                           211
  Number of missing patterns                        18

Model Test User Model:
                                                      
  Test statistic                               103.797
  Degrees of freedom                                64
  P-value (Chi-square)                           0.001

Model Test Baseline Model:

  Test statistic                               862.686
  Degrees of freedom                                91
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.948
  Tucker-Lewis Index (TLI)                       0.927
                                                      
  Robust Comparative Fit Index (CFI)             0.943
  Robust Tucker-Lewis Index (TLI)                0.919

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -3585.135
  Loglikelihood unrestricted model (H1)      -3533.237
                                                      
  Akaike (AIC)                                7280.270
  Bayesian (BIC)                              7464.623
  Sample-size adjusted Bayesian (SABIC)       7290.348

Root Mean Square Error of Approximation:

  RMSEA                                          0.054
  90 Percent confidence interval - lower         0.034
  90 Percent confidence interval - upper         0.073
  P-value H_0: RMSEA <= 0.050                    0.339
  P-value H_0: RMSEA >= 0.080                    0.010
                                                      
  Robust RMSEA                                   0.058
  90 Percent confidence interval - lower         0.037
  90 Percent confidence interval - upper         0.078
  P-value H_0: Robust RMSEA <= 0.050             0.245
  P-value H_0: Robust RMSEA >= 0.080             0.032

Standardized Root Mean Square Residual:

  SRMR                                           0.057

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.disc =~                                                      
    PPVT              1.000                               0.513    0.634
    PPT               1.417    0.250    5.672    0.000    0.728    0.728
  per.disc =~                                                           
    MVPT              1.000                               0.868    0.884
    OOO.High.Ht.Rt    0.721    0.087    8.323    0.000    0.626    0.639
    OOO.Colr.Ht.Rt    0.499    0.073    6.817    0.000    0.433    0.504
    OOO.Size.Ht.Rt    0.624    0.100    6.253    0.000    0.542    0.497
  exec.func =~                                                          
    WCST.Prsv.Errr    1.000                               0.291    0.388
    Arithmetic        2.290    0.528    4.336    0.000    0.666    0.667
    backward.span     2.256    0.533    4.233    0.000    0.656    0.659
    letter.numbrng    2.004    0.477    4.199    0.000    0.583    0.552
  semantic.fm =~                                                        
    ct.drm.FA.Rl.R    1.000                               0.809    0.769
    schmtc.FA.Rl.R    0.527    0.113    4.680    0.000    0.427    0.442
  per.fm =~                                                             
    objct.s.FA.R.R    1.000                               0.944    0.878
    abstrc..FA.R.R    0.662    0.085    7.751    0.000    0.624    0.615

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.147    0.046    3.191    0.001    0.147    0.264
   .OOO.Size.Ht.Rt         0.114    0.060    1.913    0.056    0.114    0.160
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.190    0.056    3.411    0.001    0.190    0.271
  semantic.disc ~~                                                           
    per.disc               0.298    0.058    5.143    0.000    0.670    0.670
    exec.func              0.049    0.022    2.211    0.027    0.328    0.328
    semantic.fm           -0.159    0.050   -3.181    0.001   -0.382   -0.382
    per.fm                -0.242    0.057   -4.225    0.000   -0.500   -0.500
  per.disc ~~                                                                
    exec.func              0.162    0.043    3.776    0.000    0.641    0.641
    semantic.fm           -0.425    0.077   -5.492    0.000   -0.605   -0.605
    per.fm                -0.428    0.077   -5.557    0.000   -0.522   -0.522
  exec.func ~~                                                               
    semantic.fm           -0.113    0.035   -3.275    0.001   -0.482   -0.482
    per.fm                -0.097    0.034   -2.874    0.004   -0.354   -0.354
  semantic.fm ~~                                                             
    per.fm                 0.702    0.092    7.616    0.000    0.919    0.919

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT             -0.650    0.056  -11.559    0.000   -0.650   -0.803
   .PPT              -0.471    0.069   -6.840    0.000   -0.471   -0.471
   .MVPT              0.154    0.068    2.274    0.023    0.154    0.157
   .OOO.High.Ht.Rt    0.179    0.067    2.650    0.008    0.179    0.182
   .OOO.Colr.Ht.Rt    0.271    0.059    4.580    0.000    0.271    0.315
   .OOO.Size.Ht.Rt   -0.090    0.075   -1.204    0.229   -0.090   -0.083
   .WCST.Prsv.Errr    0.182    0.052    3.482    0.000    0.182    0.243
   .Arithmetic       -0.216    0.069   -3.139    0.002   -0.216   -0.217
   .backward.span    -0.060    0.069   -0.881    0.378   -0.060   -0.061
   .letter.numbrng    0.104    0.073    1.429    0.153    0.104    0.098
   .ct.drm.FA.Rl.R    0.110    0.073    1.505    0.132    0.110    0.105
   .schmtc.FA.Rl.R   -0.063    0.077   -0.819    0.413   -0.063   -0.065
   .objct.s.FA.R.R   -0.017    0.075   -0.225    0.822   -0.017   -0.016
   .abstrc..FA.R.R   -0.202    0.071   -2.844    0.004   -0.202   -0.199

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.391    0.058    6.789    0.000    0.391    0.598
   .PPT               0.471    0.098    4.814    0.000    0.471    0.470
   .MVPT              0.211    0.068    3.104    0.002    0.211    0.219
   .OOO.High.Ht.Rt    0.568    0.066    8.566    0.000    0.568    0.592
   .OOO.Colr.Ht.Rt    0.551    0.058    9.527    0.000    0.551    0.746
   .OOO.Size.Ht.Rt    0.892    0.096    9.327    0.000    0.892    0.752
   .WCST.Prsv.Errr    0.476    0.051    9.345    0.000    0.476    0.849
   .Arithmetic        0.553    0.078    7.058    0.000    0.553    0.555
   .backward.span     0.560    0.080    6.996    0.000    0.560    0.565
   .letter.numbrng    0.777    0.092    8.450    0.000    0.777    0.696
   .ct.drm.FA.Rl.R    0.452    0.120    3.783    0.000    0.452    0.408
   .schmtc.FA.Rl.R    0.750    0.092    8.169    0.000    0.750    0.805
   .objct.s.FA.R.R    0.265    0.091    2.917    0.004    0.265    0.229
   .abstrc..FA.R.R    0.640    0.074    8.599    0.000    0.640    0.622
    semantic.disc     0.264    0.067    3.940    0.000    1.000    1.000
    per.disc          0.753    0.112    6.710    0.000    1.000    1.000
    exec.func         0.085    0.035    2.421    0.015    1.000    1.000
    semantic.fm       0.655    0.149    4.392    0.000    1.000    1.000
    per.fm            0.890    0.140    6.338    0.000    1.000    1.000

R-Square:
                   Estimate
    PPVT              0.402
    PPT               0.530
    MVPT              0.781
    OOO.High.Ht.Rt    0.408
    OOO.Colr.Ht.Rt    0.254
    OOO.Size.Ht.Rt    0.248
    WCST.Prsv.Errr    0.151
    Arithmetic        0.445
    backward.span     0.435
    letter.numbrng    0.304
    ct.drm.FA.Rl.R    0.592
    schmtc.FA.Rl.R    0.195
    objct.s.FA.R.R    0.771
    abstrc..FA.R.R    0.378
modindices(ya.cfa.1.fit, sort = TRUE, maximum.number = 10)
                  lhs op                        rhs     mi    epc sepc.lv
72      semantic.disc =~              backward.span 10.846 -0.576  -0.296
80           per.disc =~         WCST.Persev.Errors  9.210  0.299   0.260
201  letter.numbering ~~ schematic.FA.Related.Rates  9.109 -0.205  -0.205
128              PPVT ~~                 Arithmetic  8.748  0.123   0.123
103       semantic.fm =~          OOO.Size.Hit.Rate  7.737 -0.340  -0.275
70      semantic.disc =~         WCST.Persev.Errors  7.584  0.363   0.187
130              PPVT ~~           letter.numbering  7.065  0.122   0.122
176 OOO.Size.Hit.Rate ~~              backward.span  5.976  0.130   0.130
89          exec.func =~                        PPT  5.494 -0.930  -0.271
88          exec.func =~                       PPVT  5.494  0.656   0.191
    sepc.all sepc.nox
72    -0.297   -0.297
80     0.347    0.347
201   -0.268   -0.268
128    0.265    0.265
103   -0.253   -0.253
70     0.249    0.249
130    0.222    0.222
176    0.184    0.184
89    -0.271   -0.271
88     0.236    0.236
# Standardized factor loadings

inspect(ya.cfa.1.fit, what = "std")$lambda
                              smntc.d pr.dsc exc.fn smntc.f per.fm
PPVT                            0.634  0.000  0.000   0.000  0.000
PPT                             0.728  0.000  0.000   0.000  0.000
MVPT                            0.000  0.884  0.000   0.000  0.000
OOO.High.Hit.Rate               0.000  0.639  0.000   0.000  0.000
OOO.Color.Hit.Rate              0.000  0.504  0.000   0.000  0.000
OOO.Size.Hit.Rate               0.000  0.497  0.000   0.000  0.000
WCST.Persev.Errors              0.000  0.000  0.388   0.000  0.000
Arithmetic                      0.000  0.000  0.667   0.000  0.000
backward.span                   0.000  0.000  0.659   0.000  0.000
letter.numbering                0.000  0.000  0.552   0.000  0.000
cat.drm.FA.Related.Rates        0.000  0.000  0.000   0.769  0.000
schematic.FA.Related.Rates      0.000  0.000  0.000   0.442  0.000
object.sim.FA.Related.Rates     0.000  0.000  0.000   0.000  0.878
abstract.img.FA.Related.Rates   0.000  0.000  0.000   0.000  0.615
## Inspecting correlations
 
lavInspect(ya.cfa.1.fit, "cor.ov")
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.462  1.000                                   
MVPT                           0.376  0.431  1.000                            
OOO.High.Hit.Rate              0.272  0.311  0.565  1.000                     
OOO.Color.Hit.Rate             0.214  0.246  0.445  0.497  1.000              
OOO.Size.Hit.Rate              0.211  0.242  0.440  0.425  0.454  1.000       
WCST.Persev.Errors             0.081  0.093  0.220  0.159  0.126  0.124  1.000
Arithmetic                     0.139  0.159  0.378  0.273  0.216  0.213  0.259
backward.span                  0.137  0.158  0.374  0.270  0.213  0.210  0.256
letter.numbering               0.115  0.132  0.313  0.226  0.178  0.176  0.214
cat.drm.FA.Related.Rates      -0.187 -0.214 -0.411 -0.297 -0.234 -0.231 -0.144
schematic.FA.Related.Rates    -0.107 -0.123 -0.236 -0.171 -0.135 -0.133 -0.083
object.sim.FA.Related.Rates   -0.278 -0.319 -0.405 -0.293 -0.231 -0.228 -0.121
abstract.img.FA.Related.Rates -0.195 -0.224 -0.284 -0.205 -0.162 -0.160 -0.085
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.440  1.000                                   
letter.numbering               0.368  0.364  1.000                            
cat.drm.FA.Related.Rates      -0.247 -0.244 -0.204  1.000                     
schematic.FA.Related.Rates    -0.142 -0.140 -0.117  0.340  1.000              
object.sim.FA.Related.Rates   -0.207 -0.205 -0.171  0.621  0.357  1.000       
abstract.img.FA.Related.Rates -0.145 -0.144 -0.120  0.435  0.250  0.540  1.000
lavInspect(ya.cfa.1.fit, "cor.lv")
              smntc.d pr.dsc exc.fn smntc.f per.fm
semantic.disc   1.000                             
per.disc        0.670  1.000                      
exec.func       0.328  0.641  1.000               
semantic.fm    -0.382 -0.605 -0.482   1.000       
per.fm         -0.500 -0.522 -0.354   0.919  1.000
# Covariance matrix determinent
det(lavInspect(ya.cfa.1.fit, "cov.lv"))
[1] 0.0001851511
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.ya.1 = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.ya.model.1 = withCallingHandlers(
  expr = {
    sem(ya.cfa.1, 
                   missing = 'ML',
                   data = filter(data.z, Group == "YA"))
  },
  warning = function(w) {
    warnings.ya.1 <<- c(warnings.ya.1, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.ya.1) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.ya.1 = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.ya.1, collapse = "; ")))
} else {
  # If no warnings, set combined.warning.ya to "No warnings"
  combined.warning.ya.1 = "No warnings."
}


## Saving fit measures

ya.cfa.1.measures = as.data.frame(fitMeasures(ya.cfa.1.fit))
ya.cfa.1.measures[, 1] = as.numeric(ya.cfa.1.measures[, 1])

rm(warnings.ya.model.1, warnings.ya.1)

Model 2-YA:

ya.cfa.2 = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    FM =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates +
    object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

ya.cfa.2.fit = sem(ya.cfa.2, 
                   missing = 'ML',
                   data = filter(data.z, Group == "YA"))

summary(ya.cfa.2.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 54 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        51

  Number of observations                           211
  Number of missing patterns                        18

Model Test User Model:
                                                      
  Test statistic                               111.089
  Degrees of freedom                                68
  P-value (Chi-square)                           0.001

Model Test Baseline Model:

  Test statistic                               862.686
  Degrees of freedom                                91
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.944
  Tucker-Lewis Index (TLI)                       0.925
                                                      
  Robust Comparative Fit Index (CFI)             0.937
  Robust Tucker-Lewis Index (TLI)                0.916

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -3588.782
  Loglikelihood unrestricted model (H1)      -3533.237
                                                      
  Akaike (AIC)                                7279.563
  Bayesian (BIC)                              7450.508
  Sample-size adjusted Bayesian (SABIC)       7288.908

Root Mean Square Error of Approximation:

  RMSEA                                          0.055
  90 Percent confidence interval - lower         0.036
  90 Percent confidence interval - upper         0.073
  P-value H_0: RMSEA <= 0.050                    0.318
  P-value H_0: RMSEA >= 0.080                    0.009
                                                      
  Robust RMSEA                                   0.059
  90 Percent confidence interval - lower         0.039
  90 Percent confidence interval - upper         0.078
  P-value H_0: Robust RMSEA <= 0.050             0.211
  P-value H_0: Robust RMSEA >= 0.080             0.035

Standardized Root Mean Square Residual:

  SRMR                                           0.059

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  semantic.disc =~                                                      
    PPVT              1.000                               0.499    0.616
    PPT               1.499    0.272    5.514    0.000    0.748    0.748
  per.disc =~                                                           
    MVPT              1.000                               0.868    0.884
    OOO.High.Ht.Rt    0.720    0.087    8.301    0.000    0.625    0.638
    OOO.Colr.Ht.Rt    0.503    0.074    6.813    0.000    0.436    0.508
    OOO.Size.Ht.Rt    0.623    0.100    6.240    0.000    0.541    0.497
  exec.func =~                                                          
    WCST.Prsv.Errr    1.000                               0.296    0.395
    Arithmetic        2.253    0.514    4.384    0.000    0.666    0.668
    backward.span     2.205    0.514    4.291    0.000    0.652    0.655
    letter.numbrng    1.965    0.463    4.247    0.000    0.581    0.550
  FM =~                                                                 
    ct.drm.FA.Rl.R    1.000                               0.767    0.730
    schmtc.FA.Rl.R    0.556    0.113    4.928    0.000    0.426    0.441
    objct.s.FA.R.R    1.193    0.127    9.383    0.000    0.914    0.850
    abstrc..FA.R.R    0.820    0.106    7.697    0.000    0.628    0.619

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.146    0.046    3.149    0.002    0.146    0.261
   .OOO.Size.Ht.Rt         0.115    0.060    1.929    0.054    0.115    0.162
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.189    0.056    3.385    0.001    0.189    0.269
  semantic.disc ~~                                                           
    per.disc               0.288    0.059    4.887    0.000    0.664    0.664
    exec.func              0.047    0.022    2.144    0.032    0.317    0.317
    FM                    -0.183    0.046   -3.937    0.000   -0.477   -0.477
  per.disc ~~                                                                
    exec.func              0.165    0.043    3.826    0.000    0.643    0.643
    FM                    -0.374    0.070   -5.322    0.000   -0.562   -0.562
  exec.func ~~                                                               
    FM                    -0.092    0.030   -3.069    0.002   -0.406   -0.406

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT             -0.650    0.056  -11.558    0.000   -0.650   -0.803
   .PPT              -0.471    0.069   -6.840    0.000   -0.471   -0.471
   .MVPT              0.154    0.068    2.274    0.023    0.154    0.157
   .OOO.High.Ht.Rt    0.179    0.067    2.650    0.008    0.179    0.182
   .OOO.Colr.Ht.Rt    0.271    0.059    4.580    0.000    0.271    0.315
   .OOO.Size.Ht.Rt   -0.090    0.075   -1.204    0.229   -0.090   -0.083
   .WCST.Prsv.Errr    0.182    0.052    3.483    0.000    0.182    0.243
   .Arithmetic       -0.216    0.069   -3.138    0.002   -0.216   -0.216
   .backward.span    -0.060    0.069   -0.881    0.378   -0.060   -0.061
   .letter.numbrng    0.104    0.073    1.429    0.153    0.104    0.098
   .ct.drm.FA.Rl.R    0.111    0.073    1.514    0.130    0.111    0.106
   .schmtc.FA.Rl.R   -0.059    0.077   -0.770    0.441   -0.059   -0.061
   .objct.s.FA.R.R   -0.017    0.075   -0.232    0.816   -0.017   -0.016
   .abstrc..FA.R.R   -0.202    0.071   -2.847    0.004   -0.202   -0.199

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.406    0.058    7.047    0.000    0.406    0.620
   .PPT               0.441    0.104    4.258    0.000    0.441    0.441
   .MVPT              0.211    0.068    3.087    0.002    0.211    0.219
   .OOO.High.Ht.Rt    0.569    0.066    8.569    0.000    0.569    0.593
   .OOO.Colr.Ht.Rt    0.549    0.058    9.501    0.000    0.549    0.742
   .OOO.Size.Ht.Rt    0.893    0.096    9.331    0.000    0.893    0.753
   .WCST.Prsv.Errr    0.473    0.051    9.316    0.000    0.473    0.844
   .Arithmetic        0.552    0.078    7.039    0.000    0.552    0.554
   .backward.span     0.565    0.080    7.070    0.000    0.565    0.570
   .letter.numbrng    0.778    0.092    8.449    0.000    0.778    0.697
   .ct.drm.FA.Rl.R    0.516    0.071    7.234    0.000    0.516    0.467
   .schmtc.FA.Rl.R    0.750    0.091    8.259    0.000    0.750    0.805
   .objct.s.FA.R.R    0.321    0.074    4.355    0.000    0.321    0.277
   .abstrc..FA.R.R    0.635    0.073    8.677    0.000    0.635    0.617
    semantic.disc     0.249    0.065    3.828    0.000    1.000    1.000
    per.disc          0.753    0.112    6.703    0.000    1.000    1.000
    exec.func         0.087    0.035    2.466    0.014    1.000    1.000
    FM                0.588    0.108    5.433    0.000    1.000    1.000

R-Square:
                   Estimate
    PPVT              0.380
    PPT               0.559
    MVPT              0.781
    OOO.High.Ht.Rt    0.407
    OOO.Colr.Ht.Rt    0.258
    OOO.Size.Ht.Rt    0.247
    WCST.Prsv.Errr    0.156
    Arithmetic        0.446
    backward.span     0.430
    letter.numbrng    0.303
    ct.drm.FA.Rl.R    0.533
    schmtc.FA.Rl.R    0.195
    objct.s.FA.R.R    0.723
    abstrc..FA.R.R    0.383
modindices(ya.cfa.2.fit, sort = TRUE, maximum.number = 10)
                  lhs op                        rhs    mi    epc sepc.lv
66      semantic.disc =~              backward.span 9.507 -0.552  -0.275
74           per.disc =~         WCST.Persev.Errors 9.229  0.300   0.261
108              PPVT ~~                 Arithmetic 8.607  0.123   0.123
181  letter.numbering ~~ schematic.FA.Related.Rates 8.476 -0.196  -0.196
83          exec.func =~                        PPT 7.454 -1.127  -0.333
82          exec.func =~                       PPVT 7.454  0.752   0.222
110              PPVT ~~           letter.numbering 6.669  0.119   0.119
64      semantic.disc =~         WCST.Persev.Errors 6.642  0.348   0.173
156 OOO.Size.Hit.Rate ~~              backward.span 6.060  0.131   0.131
97                 FM =~          OOO.Size.Hit.Rate 5.353 -0.284  -0.217
    sepc.all sepc.nox
66    -0.277   -0.277
74     0.348    0.348
108    0.259    0.259
181   -0.257   -0.257
83    -0.333   -0.333
82     0.275    0.275
110    0.213    0.213
64     0.232    0.232
156    0.185    0.185
97    -0.200   -0.200
# Standardized factor loadings

inspect(ya.cfa.2.fit, what = "std")$lambda
                              smntc. pr.dsc exc.fn    FM
PPVT                           0.616  0.000  0.000 0.000
PPT                            0.748  0.000  0.000 0.000
MVPT                           0.000  0.884  0.000 0.000
OOO.High.Hit.Rate              0.000  0.638  0.000 0.000
OOO.Color.Hit.Rate             0.000  0.508  0.000 0.000
OOO.Size.Hit.Rate              0.000  0.497  0.000 0.000
WCST.Persev.Errors             0.000  0.000  0.395 0.000
Arithmetic                     0.000  0.000  0.668 0.000
backward.span                  0.000  0.000  0.655 0.000
letter.numbering               0.000  0.000  0.550 0.000
cat.drm.FA.Related.Rates       0.000  0.000  0.000 0.730
schematic.FA.Related.Rates     0.000  0.000  0.000 0.441
object.sim.FA.Related.Rates    0.000  0.000  0.000 0.850
abstract.img.FA.Related.Rates  0.000  0.000  0.000 0.619
## Inspecting correlations
 
lavInspect(ya.cfa.2.fit, "cor.ov")
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.461  1.000                                   
MVPT                           0.362  0.439  1.000                            
OOO.High.Hit.Rate              0.261  0.317  0.564  1.000                     
OOO.Color.Hit.Rate             0.208  0.252  0.449  0.497  1.000              
OOO.Size.Hit.Rate              0.203  0.247  0.439  0.425  0.454  1.000       
WCST.Persev.Errors             0.077  0.094  0.225  0.162  0.129  0.126  1.000
Arithmetic                     0.131  0.158  0.380  0.274  0.218  0.213  0.264
backward.span                  0.128  0.155  0.373  0.269  0.214  0.209  0.259
letter.numbering               0.108  0.130  0.313  0.226  0.180  0.176  0.217
cat.drm.FA.Related.Rates      -0.215 -0.260 -0.363 -0.262 -0.208 -0.204 -0.117
schematic.FA.Related.Rates    -0.130 -0.158 -0.219 -0.158 -0.126 -0.123 -0.071
object.sim.FA.Related.Rates   -0.250 -0.303 -0.423 -0.305 -0.243 -0.237 -0.136
abstract.img.FA.Related.Rates -0.182 -0.221 -0.308 -0.222 -0.177 -0.173 -0.099
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.438  1.000                                   
letter.numbering               0.367  0.361  1.000                            
cat.drm.FA.Related.Rates      -0.198 -0.194 -0.163  1.000                     
schematic.FA.Related.Rates    -0.120 -0.117 -0.099  0.322  1.000              
object.sim.FA.Related.Rates   -0.230 -0.226 -0.190  0.620  0.375  1.000       
abstract.img.FA.Related.Rates -0.168 -0.165 -0.138  0.452  0.273  0.526  1.000
lavInspect(ya.cfa.2.fit, "cor.lv")
              smntc. pr.dsc exc.fn     FM
semantic.disc  1.000                     
per.disc       0.664  1.000              
exec.func      0.317  0.643  1.000       
FM            -0.477 -0.562 -0.406  1.000
# Covariance matrix determinent
det(lavInspect(ya.cfa.2.fit, "cov.lv"))
[1] 0.001998426
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.ya.2 = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.ya.model.2 = withCallingHandlers(
  expr = {
    sem(ya.cfa.2, 
                   missing = 'ML',
                   data = filter(data.z, Group == "YA"))
  },
  warning = function(w) {
    warnings.ya.2 <<- c(warnings.ya.2, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.ya.2) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.ya.2 = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.ya.2, collapse = "; ")))
} else {
  # If no warnings, set combined.warning.ya to "No warnings"
  combined.warning.ya.2 = "No warnings."
}


## Saving fit measures

ya.cfa.2.measures = as.data.frame(fitMeasures(ya.cfa.2.fit))
ya.cfa.2.measures[, 1] = as.numeric(ya.cfa.2.measures[, 1])

rm(warnings.ya.model.2, warnings.ya.2)

Model 3-YA:

ya.cfa.3 = '
  # measurement model
    cognitive.ability =~ PPVT + PPT + 
    MVPT + OOO.High.Hit.Rate + OOO.Color.Hit.Rate + OOO.Size.Hit.Rate + 
    WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    semantic.fm =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates
    per.fm =~ object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Color.Hit.Rate + OOO.Size.Hit.Rate
    OOO.Color.Hit.Rate ~~ OOO.Size.Hit.Rate
'

ya.cfa.3.fit = sem(ya.cfa.3, 
                   missing = 'ML',
                   data = filter(data.z, Group == "YA"))

summary(ya.cfa.3.fit, 
        fit.measures = TRUE, 
        standardized = TRUE, 
        rsquare = TRUE)
lavaan 0.6.17 ended normally after 43 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        48

  Number of observations                           211
  Number of missing patterns                        18

Model Test User Model:
                                                      
  Test statistic                               171.833
  Degrees of freedom                                71
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                               862.686
  Degrees of freedom                                91
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.869
  Tucker-Lewis Index (TLI)                       0.833
                                                      
  Robust Comparative Fit Index (CFI)             0.862
  Robust Tucker-Lewis Index (TLI)                0.824

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -3619.153
  Loglikelihood unrestricted model (H1)      -3533.237
                                                      
  Akaike (AIC)                                7334.306
  Bayesian (BIC)                              7495.195
  Sample-size adjusted Bayesian (SABIC)       7343.102

Root Mean Square Error of Approximation:

  RMSEA                                          0.082
  90 Percent confidence interval - lower         0.066
  90 Percent confidence interval - upper         0.098
  P-value H_0: RMSEA <= 0.050                    0.001
  P-value H_0: RMSEA >= 0.080                    0.600
                                                      
  Robust RMSEA                                   0.085
  90 Percent confidence interval - lower         0.069
  90 Percent confidence interval - upper         0.102
  P-value H_0: Robust RMSEA <= 0.050             0.000
  P-value H_0: Robust RMSEA >= 0.080             0.718

Standardized Root Mean Square Residual:

  SRMR                                           0.068

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian

Latent Variables:
                       Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  cognitive.ability =~                                                      
    PPVT                  1.000                               0.384    0.475
    PPT                   1.260    0.242    5.204    0.000    0.484    0.484
    MVPT                  2.119    0.331    6.402    0.000    0.814    0.829
    OOO.High.Ht.Rt        1.623    0.282    5.756    0.000    0.624    0.637
    OOO.Colr.Ht.Rt        1.120    0.223    5.026    0.000    0.430    0.501
    OOO.Size.Ht.Rt        1.450    0.288    5.043    0.000    0.557    0.512
    WCST.Prsv.Errr        0.805    0.179    4.507    0.000    0.309    0.414
    Arithmetic            1.378    0.259    5.314    0.000    0.530    0.530
    backward.span         1.111    0.247    4.498    0.000    0.427    0.429
    letter.numbrng        1.048    0.245    4.280    0.000    0.403    0.381
  semantic.fm =~                                                            
    ct.drm.FA.Rl.R        1.000                               0.806    0.767
    schmtc.FA.Rl.R        0.533    0.114    4.667    0.000    0.429    0.444
  per.fm =~                                                                 
    objct.s.FA.R.R        1.000                               0.945    0.878
    abstrc..FA.R.R        0.662    0.087    7.623    0.000    0.626    0.617

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .OOO.High.Hit.Rate ~~                                                       
   .OOO.Colr.Ht.Rt         0.150    0.046    3.262    0.001    0.150    0.267
   .OOO.Size.Ht.Rt         0.106    0.057    1.866    0.062    0.106    0.150
 .OOO.Color.Hit.Rate ~~                                                      
   .OOO.Size.Ht.Rt         0.185    0.055    3.373    0.001    0.185    0.265
  cognitive.ability ~~                                                       
    semantic.fm           -0.191    0.043   -4.469    0.000   -0.616   -0.616
    per.fm                -0.201    0.044   -4.517    0.000   -0.553   -0.553
  semantic.fm ~~                                                             
    per.fm                 0.702    0.092    7.603    0.000    0.921    0.921

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT             -0.647    0.056  -11.501    0.000   -0.647   -0.800
   .PPT              -0.471    0.069   -6.840    0.000   -0.471   -0.471
   .MVPT              0.154    0.068    2.274    0.023    0.154    0.157
   .OOO.High.Ht.Rt    0.179    0.067    2.650    0.008    0.179    0.182
   .OOO.Colr.Ht.Rt    0.271    0.059    4.580    0.000    0.271    0.315
   .OOO.Size.Ht.Rt   -0.090    0.075   -1.204    0.229   -0.090   -0.083
   .WCST.Prsv.Errr    0.181    0.052    3.464    0.001    0.181    0.242
   .Arithmetic       -0.215    0.069   -3.128    0.002   -0.215   -0.216
   .backward.span    -0.060    0.069   -0.881    0.378   -0.060   -0.061
   .letter.numbrng    0.104    0.073    1.429    0.153    0.104    0.098
   .ct.drm.FA.Rl.R    0.112    0.073    1.533    0.125    0.112    0.107
   .schmtc.FA.Rl.R   -0.059    0.077   -0.763    0.445   -0.059   -0.061
   .objct.s.FA.R.R   -0.017    0.075   -0.233    0.815   -0.017   -0.016
   .abstrc..FA.R.R   -0.203    0.071   -2.860    0.004   -0.203   -0.200

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .PPVT              0.507    0.053    9.496    0.000    0.507    0.774
   .PPT               0.766    0.080    9.563    0.000    0.766    0.766
   .MVPT              0.301    0.054    5.589    0.000    0.301    0.312
   .OOO.High.Ht.Rt    0.571    0.065    8.803    0.000    0.571    0.595
   .OOO.Colr.Ht.Rt    0.554    0.058    9.478    0.000    0.554    0.749
   .OOO.Size.Ht.Rt    0.874    0.093    9.402    0.000    0.874    0.738
   .WCST.Prsv.Errr    0.464    0.048    9.681    0.000    0.464    0.829
   .Arithmetic        0.716    0.077    9.302    0.000    0.716    0.719
   .backward.span     0.808    0.084    9.673    0.000    0.808    0.816
   .letter.numbrng    0.954    0.097    9.834    0.000    0.954    0.855
   .ct.drm.FA.Rl.R    0.456    0.119    3.817    0.000    0.456    0.412
   .schmtc.FA.Rl.R    0.749    0.092    8.148    0.000    0.749    0.803
   .objct.s.FA.R.R    0.265    0.093    2.841    0.004    0.265    0.229
   .abstrc..FA.R.R    0.639    0.075    8.522    0.000    0.639    0.620
    cognitive.blty    0.148    0.045    3.314    0.001    1.000    1.000
    semantic.fm       0.650    0.149    4.373    0.000    1.000    1.000
    per.fm            0.893    0.142    6.274    0.000    1.000    1.000

R-Square:
                   Estimate
    PPVT              0.226
    PPT               0.234
    MVPT              0.688
    OOO.High.Ht.Rt    0.405
    OOO.Colr.Ht.Rt    0.251
    OOO.Size.Ht.Rt    0.262
    WCST.Prsv.Errr    0.171
    Arithmetic        0.281
    backward.span     0.184
    letter.numbrng    0.145
    ct.drm.FA.Rl.R    0.588
    schmtc.FA.Rl.R    0.197
    objct.s.FA.R.R    0.771
    abstrc..FA.R.R    0.380
modindices(ya.cfa.3.fit, sort = TRUE, maximum.number = 10)
                  lhs op                        rhs     mi    epc sepc.lv
150        Arithmetic ~~              backward.span 20.859  0.257   0.257
83               PPVT ~~                        PPT 20.430  0.210   0.210
156     backward.span ~~           letter.numbering 20.423  0.285   0.285
102               PPT ~~              backward.span 12.083 -0.200  -0.200
151        Arithmetic ~~           letter.numbering  8.115  0.173   0.173
162  letter.numbering ~~ schematic.FA.Related.Rates  8.088 -0.203  -0.203
90               PPVT ~~              backward.span  7.970 -0.133  -0.133
101               PPT ~~                 Arithmetic  6.971 -0.146  -0.146
114              MVPT ~~           letter.numbering  6.208 -0.129  -0.129
137 OOO.Size.Hit.Rate ~~              backward.span  5.521  0.137   0.137
    sepc.all sepc.nox
150    0.338    0.338
83     0.337    0.337
156    0.325    0.325
102   -0.254   -0.254
151    0.209    0.209
162   -0.240   -0.240
90    -0.208   -0.208
101   -0.198   -0.198
114   -0.241   -0.241
137    0.163    0.163
# Standardized factor loadings

inspect(ya.cfa.3.fit, what = "std")$lambda
                              cgntv. smntc. per.fm
PPVT                           0.475  0.000  0.000
PPT                            0.484  0.000  0.000
MVPT                           0.829  0.000  0.000
OOO.High.Hit.Rate              0.637  0.000  0.000
OOO.Color.Hit.Rate             0.501  0.000  0.000
OOO.Size.Hit.Rate              0.512  0.000  0.000
WCST.Persev.Errors             0.414  0.000  0.000
Arithmetic                     0.530  0.000  0.000
backward.span                  0.429  0.000  0.000
letter.numbering               0.381  0.000  0.000
cat.drm.FA.Related.Rates       0.000  0.767  0.000
schematic.FA.Related.Rates     0.000  0.444  0.000
object.sim.FA.Related.Rates    0.000  0.000  0.878
abstract.img.FA.Related.Rates  0.000  0.000  0.617
## Inspecting correlations
 
lavInspect(ya.cfa.3.fit, "cor.ov")
                                PPVT    PPT   MVPT OOO.H. OOO.C. OOO.S. WCST.P
PPVT                           1.000                                          
PPT                            0.230  1.000                                   
MVPT                           0.394  0.401  1.000                            
OOO.High.Hit.Rate              0.302  0.308  0.528  1.000                     
OOO.Color.Hit.Rate             0.238  0.242  0.415  0.497  1.000              
OOO.Size.Hit.Rate              0.243  0.248  0.424  0.425  0.454  1.000       
WCST.Persev.Errors             0.196  0.200  0.343  0.263  0.207  0.212  1.000
Arithmetic                     0.252  0.257  0.440  0.338  0.266  0.271  0.219
backward.span                  0.204  0.208  0.356  0.273  0.215  0.220  0.177
letter.numbering               0.181  0.185  0.316  0.243  0.191  0.195  0.158
cat.drm.FA.Related.Rates      -0.224 -0.229 -0.391 -0.301 -0.236 -0.242 -0.195
schematic.FA.Related.Rates    -0.130 -0.132 -0.227 -0.174 -0.137 -0.140 -0.113
object.sim.FA.Related.Rates   -0.231 -0.235 -0.403 -0.309 -0.243 -0.248 -0.201
abstract.img.FA.Related.Rates -0.162 -0.165 -0.283 -0.217 -0.171 -0.174 -0.141
                              Arthmt bckwr. lttr.n c..FA. s.FA.R o..FA. a..FA.
PPVT                                                                          
PPT                                                                           
MVPT                                                                          
OOO.High.Hit.Rate                                                             
OOO.Color.Hit.Rate                                                            
OOO.Size.Hit.Rate                                                             
WCST.Persev.Errors                                                            
Arithmetic                     1.000                                          
backward.span                  0.228  1.000                                   
letter.numbering               0.202  0.164  1.000                            
cat.drm.FA.Related.Rates      -0.250 -0.203 -0.180  1.000                     
schematic.FA.Related.Rates    -0.145 -0.117 -0.104  0.341  1.000              
object.sim.FA.Related.Rates   -0.258 -0.208 -0.185  0.620  0.360  1.000       
abstract.img.FA.Related.Rates -0.181 -0.146 -0.130  0.436  0.252  0.541  1.000
lavInspect(ya.cfa.3.fit, "cor.lv")
                  cgntv. smntc. per.fm
cognitive.ability  1.000              
semantic.fm       -0.616  1.000       
per.fm            -0.553  0.921  1.000
# Covariance matrix determinent
det(lavInspect(ya.cfa.3.fit, "cov.lv"))
[1] 0.008000753
## Saving Warning Messages

# Create an empty list to store warning messages
warnings.ya.3 = list()

# Run the model using 'withCallingHandlers' to capture the warnings
warnings.ya.model.3 = withCallingHandlers(
  expr = {
    sem(ya.cfa.3, 
                   missing = 'ML',
                   data = filter(data.z, Group == "YA"))
  },
  warning = function(w) {
    warnings.ya.3 <<- c(warnings.ya.3, list(conditionMessage(w)))
    invokeRestart("muffleWarning")
  }
)

if (length(warnings.ya.3) > 0) {
# Combine the warning messages into a single character string separated by a semicolon
  combined.warning.ya.3 = gsub("lavaan WARNING: ", "",
                            gsub("\\s{2,}", " ",
                                 paste(warnings.ya.3, collapse = "; ")))
} else {
  # If no warnings, set combined.warning.ya to "No warnings"
  combined.warning.ya.3 = "No warnings."
}


## Saving fit measures

ya.cfa.3.measures = as.data.frame(fitMeasures(ya.cfa.3.fit))
ya.cfa.3.measures[, 1] = as.numeric(ya.cfa.3.measures[, 1])

rm(warnings.ya.model.3, warnings.ya.3)

YA CFA Comparisons

Model 1 (Original):

  • Warnings: “No warnings.”
  • Chi-squared: X 2 (64) = 103.797, p = 0.001
  • CFI: 0.948
  • TLI: 0.927
  • RMSEA: 0.054 [0.034, 0.073] 90% CI
  • SRMR: 0.057

Model 2 (Single FM Factor):

  • Warnings: “No warnings.”
  • Chi-squared: X 2 (68) = 111.089, p = 0.001
  • CFI: 0.944
  • TLI: 0.925
  • RMSEA: 0.055 [0.036, 0.073] 90% CI
  • SRMR: 0.059

Model 3 (Single Cognitive Ability Factor):

  • Warnings: “No warnings.”
  • Chi-squared: X 2 (71) = 171.833, p = 0.000
  • CFI: 0.869
  • TLI: 0.833
  • RMSEA: 0.082 [0.066, 0.098] 90% CI
  • SRMR: 0.068

All three YA models converge without warnings. Fit is comparable in Models 1 and 2 but poor in Model 3.

Comparing YA CFA models in terms of BIC/AIC. Lower values are better.

YA Model 1 YA Model 2 YA Model 3
BIC 7464.623 7450.508 7495.195
AIC 7280.27 7279.563 7334.306

Both BIC and AIC favor Model 2 in YAs.

Model Selection Decision

BIC/AIC model comparisons favor Model 2 in YAs. Although this wasn’t the case for OAs, Model 2 was the only model to converge without warnings, and fit the data well.

Additionally, the latent correlation between Perceptual and Semantic FM is high in both groups (OA r = 811, YA r = 0.811), suggesting redundancy of these factors.

Lastly, inspection of the correlation matrices within each group does not provide evidence of distinctive functioning for the two types of false memories:

  • In both groups, the highest FM correlations are between the Semantic and Perceptual tests
  • In both groups, semantic tests are generally not more related to semantic FM than perceptual FM. The same is true for perceptual tests.

As such, we selected Model 2 as the optimal model for both groups.

We also chose to remove the OOO-Color indicator from the perceptual factor given its low factor loading for OAs (0.220).

The final model is depicted below:

final.model = '
  # measurement model
    semantic.disc =~ PPVT + PPT
    per.disc =~ MVPT + OOO.High.Hit.Rate + OOO.Size.Hit.Rate
    exec.func =~ WCST.Persev.Errors + Arithmetic + backward.span + letter.numbering
    false.memory =~ cat.drm.FA.Related.Rates + schematic.FA.Related.Rates + object.sim.FA.Related.Rates + abstract.img.FA.Related.Rates
  # regressions
    false.memory ~ semantic.disc + exec.func + per.disc
  # residual correlations
    OOO.High.Hit.Rate ~~ OOO.Size.Hit.Rate
'

final.fit = sem(final.model, 
                     missing = 'ML', 
                     data = filter(data.z, Group == "OA"))

hypothesized.diagram = semPaths(final.fit, 
         layout = "tree",
         residuals = FALSE, 
         intercepts = FALSE, 
         latents = c("semantic.disc", "exec.func", "per.disc",
                     "false.memory"), 
         #whatLabels = "std", 
         fixedStyle = c("black", 1), 
         nodeLabels = c("PPVT", "PPT", "WCST", "Arithmetic", 
                        "Backward\nSpan", "Letter\nNumbering", 
                        "MVPT", "OOO - High", "OOO - Size", 
                        "Categorical\nDRM FM", "Schematic\nFM", "Object Sim.\nFM", "Abstract\nImages FM",
                        "Semantic\nDiscrimination", "Frontal\nFunctioning", "Perceptual\nDiscrimination",
                        "False Memory\n(General)"), 
         sizeMan2 = 5, 
         sizeMan = 9,  
         sizeLat = 10,
         asize = 3.5, 
         esize = 2,
         border.width = 2,
         #edge.label.cex = 0.5,
         #edge.label.margin = 0.005,
         edge.color = "black", 
         #edge.label.color = "black",
         fade = FALSE,
         gray = FALSE,
         font = 8,
         label.scale = FALSE,
         label.cex = 0.5,           
         curve = 1.25,           
         mar = c(3,2,3,2)) 

title("Final Model", line = 3)