Confirmatory Factor Analysis (CFA)

Tutorial

Author

Orlando Sabogal-Cardona

Published

May 23, 2024

Libraries and data

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.3     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(magrittr)

Attaching package: 'magrittr'

The following object is masked from 'package:purrr':

    set_names

The following object is masked from 'package:tidyr':

    extract
library(lavaan) #This is the primary library for CFA and SEM
This is lavaan 0.6-17
lavaan is FREE software! Please report any bugs.
library(semPlot)
Warning: package 'semPlot' was built under R version 4.3.3
library(psych) #To get access to our toy data (bfi)
Warning: package 'psych' was built under R version 4.3.3

Attaching package: 'psych'

The following object is masked from 'package:lavaan':

    cor2cov

The following objects are masked from 'package:ggplot2':

    %+%, alpha

Toy data: bfi

Test_Data <- bfi
Test_Data[1:10,]
      A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 N2 N3 N4 N5 O1 O2 O3 O4
61617  2  4  3  4  4  2  3  3  4  4  3  3  3  4  4  3  4  2  2  3  3  6  3  4
61618  2  4  5  2  5  5  4  4  3  4  1  1  6  4  3  3  3  3  5  5  4  2  4  3
61620  5  4  5  4  4  4  5  4  2  5  2  4  4  4  5  4  5  4  2  3  4  2  5  5
61621  4  4  6  5  5  4  4  3  5  5  5  3  4  4  4  2  5  2  4  1  3  3  4  3
61622  2  3  3  4  5  4  4  5  3  2  2  2  5  4  5  2  3  4  4  3  3  3  4  3
61623  6  6  5  6  5  6  6  6  1  3  2  1  6  5  6  3  5  2  2  3  4  3  5  6
61624  2  5  5  3  5  5  4  4  2  3  4  3  4  5  5  1  2  2  1  1  5  2  5  6
61629  4  3  1  5  1  3  2  4  2  4  3  6  4  2  1  6  3  2  6  4  3  2  4  5
61630  4  3  6  3  3  6  6  3  4  5  5  3 NA  4  3  5  5  2  3  3  6  6  6  6
61633  2  5  6  6  5  6  5  6  2  1  2  2  4  5  5  5  5  5  2  4  5  1  5  5
      O5 gender education age
61617  3      1        NA  16
61618  3      2        NA  18
61620  2      2        NA  17
61621  5      2        NA  17
61622  3      1        NA  17
61623  1      2         3  21
61624  1      1        NA  18
61629  3      1         2  19
61630  1      1         1  19
61633  2      2        NA  17
dim(Test_Data)
[1] 2800   28
glimpse(Test_Data)
Rows: 2,800
Columns: 28
$ A1        <int> 2, 2, 5, 4, 2, 6, 2, 4, 4, 2, 4, 2, 5, 5, 4, 4, 4, 5, 4, 4, …
$ A2        <int> 4, 4, 4, 4, 3, 6, 5, 3, 3, 5, 4, 5, 5, 5, 5, 3, 6, 5, 4, 4, …
$ A3        <int> 3, 5, 5, 6, 3, 5, 5, 1, 6, 6, 5, 5, 5, 5, 2, 6, 6, 5, 5, 6, …
$ A4        <int> 4, 2, 4, 5, 4, 6, 3, 5, 3, 6, 6, 5, 6, 6, 2, 6, 2, 4, 4, 5, …
$ A5        <int> 4, 5, 4, 5, 5, 5, 5, 1, 3, 5, 5, 5, 4, 6, 1, 3, 5, 5, 3, 5, …
$ C1        <int> 2, 5, 4, 4, 4, 6, 5, 3, 6, 6, 4, 5, 5, 4, 5, 5, 4, 5, 5, 1, …
$ C2        <int> 3, 4, 5, 4, 4, 6, 4, 2, 6, 5, 3, 4, 4, 4, 5, 5, 4, 5, 4, 1, …
$ C3        <int> 3, 4, 4, 3, 5, 6, 4, 4, 3, 6, 5, 5, 3, 4, 5, 5, 4, 5, 5, 1, …
$ C4        <int> 4, 3, 2, 5, 3, 1, 2, 2, 4, 2, 3, 4, 2, 2, 2, 3, 4, 4, 4, 5, …
$ C5        <int> 4, 4, 5, 5, 2, 3, 3, 4, 5, 1, 2, 5, 2, 1, 2, 5, 4, 3, 6, 6, …
$ E1        <int> 3, 1, 2, 5, 2, 2, 4, 3, 5, 2, 1, 3, 3, 2, 3, 1, 1, 2, 1, 1, …
$ E2        <int> 3, 1, 4, 3, 2, 1, 3, 6, 3, 2, 3, 3, 3, 2, 4, 1, 2, 2, 2, 1, …
$ E3        <int> 3, 6, 4, 4, 5, 6, 4, 4, NA, 4, 2, 4, 3, 4, 3, 6, 5, 4, 4, 4,…
$ E4        <int> 4, 4, 4, 4, 4, 5, 5, 2, 4, 5, 5, 5, 2, 6, 6, 6, 5, 6, 5, 5, …
$ E5        <int> 4, 3, 5, 4, 5, 6, 5, 1, 3, 5, 4, 4, 4, 5, 5, 4, 5, 6, 5, 6, …
$ N1        <int> 3, 3, 4, 2, 2, 3, 1, 6, 5, 5, 3, 4, 1, 1, 2, 4, 4, 6, 5, 5, …
$ N2        <int> 4, 3, 5, 5, 3, 5, 2, 3, 5, 5, 3, 5, 2, 1, 4, 5, 4, 5, 6, 5, …
$ N3        <int> 2, 3, 4, 2, 4, 2, 2, 2, 2, 5, 4, 3, 2, 1, 2, 4, 4, 5, 5, 5, …
$ N4        <int> 2, 5, 2, 4, 4, 2, 1, 6, 3, 2, 2, 2, 2, 2, 2, 5, 4, 4, 5, 1, …
$ N5        <int> 3, 5, 3, 1, 3, 3, 1, 4, 3, 4, 3, NA, 2, 1, 3, 5, 5, 4, 2, 1,…
$ O1        <int> 3, 4, 4, 3, 3, 4, 5, 3, 6, 5, 5, 4, 4, 5, 5, 6, 5, 5, 4, 4, …
$ O2        <int> 6, 2, 2, 3, 3, 3, 2, 2, 6, 1, 3, 6, 2, 3, 2, 6, 1, 1, 2, 1, …
$ O3        <int> 3, 4, 5, 4, 4, 5, 5, 4, 6, 5, 5, 4, 4, 4, 5, 6, 5, 4, 2, 5, …
$ O4        <int> 4, 3, 5, 3, 3, 6, 6, 5, 6, 5, 6, 5, 5, 4, 5, 3, 6, 5, 4, 3, …
$ O5        <int> 3, 3, 2, 5, 3, 1, 1, 3, 1, 2, 3, 4, 2, 4, 5, 2, 3, 4, 2, 2, …
$ gender    <int> 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, …
$ education <int> NA, NA, NA, NA, NA, 3, NA, 2, 1, NA, 1, NA, NA, NA, 1, NA, N…
$ age       <int> 16, 18, 17, 17, 17, 21, 18, 19, 19, 17, 21, 16, 16, 16, 17, …
Test_Data <- drop_na(Test_Data)
# Test_Data <- Test_Data[complete.cases(Test_Data),]
dim(Test_Data)
[1] 2236   28

Content

summary(Test_Data$A1)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  1.000   1.000   2.000   2.365   3.000   6.000 
Test_Data %>% group_by(A1) %>% summarise(Total = n())
# A tibble: 6 × 2
     A1 Total
  <int> <int>
1     1   767
2     2   666
3     3   315
4     4   260
5     5   163
6     6    65
Test_Data %>% group_by(A2) %>% summarise(Total = n())
# A tibble: 6 × 2
     A2 Total
  <int> <int>
1     1    34
2     2    99
3     3   115
4     4   433
5     5   830
6     6   725

Scale and distribution

Test_Data %>% select(-gender, -education, - age) %>% 
  mutate(Temp_Id = seq(1, dim(Test_Data)[1])) %>% 
  pivot_longer(cols = -Temp_Id, names_to = "Variable", values_to = "Score") %>% 
  group_by(Variable, Score) %>% summarise(Total = n()) %>% 
  pivot_wider(id_cols = Variable, names_from = Score, values_from = Total, values_fill = 0)
`summarise()` has grouped output by 'Variable'. You can override using the
`.groups` argument.
# A tibble: 25 × 7
# Groups:   Variable [25]
   Variable   `1`   `2`   `3`   `4`   `5`   `6`
   <chr>    <int> <int> <int> <int> <int> <int>
 1 A1         767   666   315   260   163    65
 2 A2          34    99   115   433   830   725
 3 A3          71   133   154   456   804   618
 4 A4          96   159   141   356   545   939
 5 A5          48   145   193   490   785   575
 6 C1          49   121   207   505   838   516
 7 C2          67   189   228   504   792   456
 8 C3          66   195   227   610   739   399
 9 C4         650   650   368   348   174    46
10 C5         420   473   266   485   377   215
# ℹ 15 more rows

My First CFA

names(Test_Data)
 [1] "A1"        "A2"        "A3"        "A4"        "A5"        "C1"       
 [7] "C2"        "C3"        "C4"        "C5"        "E1"        "E2"       
[13] "E3"        "E4"        "E5"        "N1"        "N2"        "N3"       
[19] "N4"        "N5"        "O1"        "O2"        "O3"        "O4"       
[25] "O5"        "gender"    "education" "age"      
MyFirstModel_Equations <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
  Conscientiousness =~ C1 + C2 + C3 + C4 + C5
  Extraversion =~ E1 + E2 + E3 + E4 + E5  
  Neuroticism =~ N1 + N2 + N3 + N4 + N5
  Opennness =~ O1 + O2 + O3 + O4 + O5
'
MyFirstModel <- sem(model = MyFirstModel_Equations, 
                    data = Test_Data)
MyFirstModel
lavaan 0.6.17 ended normally after 56 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        60

  Number of observations                          2236

Model Test User Model:
                                                      
  Test statistic                              3843.296
  Degrees of freedom                               265
  P-value (Chi-square)                           0.000
summary(MyFirstModel)
lavaan 0.6.17 ended normally after 56 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        60

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                       Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness =~                                        
    A1                    1.000                           
    A2                   -1.595    0.119  -13.378    0.000
    A3                   -2.077    0.151  -13.791    0.000
    A4                   -1.583    0.127  -12.502    0.000
    A5                   -1.852    0.136  -13.579    0.000
  Conscientiousness =~                                    
    C1                    1.000                           
    C2                    1.162    0.063   18.575    0.000
    C3                    1.085    0.060   18.025    0.000
    C4                   -1.456    0.072  -20.321    0.000
    C5                   -1.554    0.080  -19.339    0.000
  Extraversion =~                                         
    E1                    1.000                           
    E2                    1.229    0.054   22.760    0.000
    E3                   -0.955    0.044  -21.821    0.000
    E4                   -1.132    0.049  -22.933    0.000
    E5                   -0.823    0.041  -19.948    0.000
  Neuroticism =~                                          
    N1                    1.000                           
    N2                    0.951    0.025   37.549    0.000
    N3                    0.897    0.026   34.192    0.000
    N4                    0.694    0.026   26.358    0.000
    N5                    0.642    0.028   23.208    0.000
  Opennness =~                                            
    O1                    1.000                           
    O2                   -1.058    0.072  -14.654    0.000
    O3                    1.368    0.075   18.182    0.000
    O4                    0.413    0.049    8.390    0.000
    O5                   -1.006    0.064  -15.717    0.000

Covariances:
                       Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness ~~                                        
    Conscientisnss       -0.098    0.011   -8.529    0.000
    Extraversion          0.289    0.025   11.452    0.000
    Neuroticism           0.122    0.018    6.855    0.000
    Opennness            -0.078    0.011   -7.371    0.000
  Conscientiousness ~~                                    
    Extraversion         -0.213    0.020  -10.607    0.000
    Neuroticism          -0.234    0.025   -9.499    0.000
    Opennness             0.117    0.014    8.374    0.000
  Extraversion ~~                                         
    Neuroticism           0.272    0.032    8.424    0.000
    Opennness            -0.256    0.022  -11.765    0.000
  Neuroticism ~~                                          
    Opennness            -0.092    0.023   -4.036    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A1                1.725    0.053   32.366    0.000
   .A2                0.800    0.029   27.408    0.000
   .A3                0.749    0.033   22.455    0.000
   .A4                1.566    0.051   30.453    0.000
   .A5                0.851    0.033   25.743    0.000
   .C1                1.054    0.036   29.030    0.000
   .C2                1.144    0.041   27.927    0.000
   .C3                1.156    0.040   28.702    0.000
   .C4                0.955    0.041   23.026    0.000
   .C5                1.627    0.061   26.462    0.000
   .E1                1.795    0.060   29.892    0.000
   .E2                1.336    0.051   26.168    0.000
   .E3                1.052    0.038   27.886    0.000
   .E4                1.074    0.042   25.751    0.000
   .E5                1.211    0.041   29.874    0.000
   .N1                0.797    0.038   20.788    0.000
   .N2                0.862    0.038   22.748    0.000
   .N3                1.219    0.045   26.884    0.000
   .N4                1.640    0.054   30.599    0.000
   .N5                1.950    0.062   31.403    0.000
   .O1                0.858    0.033   26.204    0.000
   .O2                1.945    0.065   30.040    0.000
   .O3                0.682    0.040   17.205    0.000
   .O4                1.313    0.040   32.692    0.000
   .O5                1.366    0.047   29.009    0.000
    Agreeableness     0.212    0.030    7.164    0.000
    Conscientisnss    0.425    0.036   11.849    0.000
    Extraversion      0.822    0.063   13.047    0.000
    Neuroticism       1.649    0.075   21.871    0.000
    Opennness         0.396    0.034   11.622    0.000

Change the marker variable

First example (the “clever” way)

Equation <- '
  Agreeableness =~ A2 + A1 + A3 + A4 + A5
'
Model <- sem(model = Equation, data = Test_Data)
summary(Model)
lavaan 0.6.17 ended normally after 27 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness =~                                    
    A2                1.000                           
    A1               -0.683    0.047  -14.622    0.000
    A3                1.300    0.054   24.187    0.000
    A4                0.953    0.050   18.864    0.000
    A5                1.037    0.046   22.453    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A2                0.766    0.030   25.148    0.000
   .A1                1.670    0.053   31.778    0.000
   .A3                0.695    0.038   18.396    0.000
   .A4                1.576    0.053   29.959    0.000
   .A5                0.961    0.036   26.420    0.000
    Agreeableness     0.572    0.038   14.877    0.000

Seconf example

Equation <- '
  Agreeableness =~ NA*A1 + 1*A2 + A3 + A4 + A5
'
Model <- sem(model = Equation, data = Test_Data)
summary(Model)
lavaan 0.6.17 ended normally after 27 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness =~                                    
    A1               -0.683    0.047  -14.622    0.000
    A2                1.000                           
    A3                1.300    0.054   24.187    0.000
    A4                0.953    0.050   18.864    0.000
    A5                1.037    0.046   22.453    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A1                1.670    0.053   31.778    0.000
   .A2                0.766    0.030   25.148    0.000
   .A3                0.695    0.038   18.396    0.000
   .A4                1.576    0.053   29.959    0.000
   .A5                0.961    0.036   26.420    0.000
    Agreeableness     0.572    0.038   14.877    0.000

Standardized the mean

Just the variance

Equation <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
'
Model <- sem(model = Equation, data = Test_Data, std.lv = TRUE)
summary(Model)
lavaan 0.6.17 ended normally after 20 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness =~                                    
    A1                0.517    0.033   15.893    0.000
    A2               -0.756    0.025  -29.754    0.000
    A3               -0.983    0.028  -35.128    0.000
    A4               -0.721    0.033  -21.886    0.000
    A5               -0.785    0.028  -28.302    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A1                1.670    0.053   31.778    0.000
   .A2                0.766    0.030   25.148    0.000
   .A3                0.695    0.038   18.396    0.000
   .A4                1.576    0.053   29.959    0.000
   .A5                0.961    0.036   26.420    0.000
    Agreeableness     1.000                           

“Two extra columns of standardized parameter values are printed. In the first column (labeled Std.lv), only the latent variables are standardized. In the second column (labeled Std.all), both latent and observed variables are standardized. The latter is often called the ‘completely standardized solution’.” sourece: lavaan documentation

All in one

You SHOULD always do this

Equation <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
'
Model <- sem(model = Equation, data = Test_Data)
summary(Model, standardized = TRUE)
lavaan 0.6.17 ended normally after 32 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness =~                                                      
    A1                1.000                               0.517    0.371
    A2               -1.464    0.100  -14.622    0.000   -0.756   -0.654
    A3               -1.904    0.127  -14.986    0.000   -0.983   -0.763
    A4               -1.395    0.105  -13.335    0.000   -0.721   -0.498
    A5               -1.519    0.105  -14.445    0.000   -0.785   -0.625

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .A1                1.670    0.053   31.778    0.000    1.670    0.862
   .A2                0.766    0.030   25.148    0.000    0.766    0.572
   .A3                0.695    0.038   18.396    0.000    0.695    0.418
   .A4                1.576    0.053   29.959    0.000    1.576    0.752
   .A5                0.961    0.036   26.420    0.000    0.961    0.609
    Agreeableness     0.267    0.034    7.946    0.000    1.000    1.000

Communalities

The easy way

summary(Model, standardized = TRUE, rsquare = TRUE)
lavaan 0.6.17 ended normally after 32 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness =~                                                      
    A1                1.000                               0.517    0.371
    A2               -1.464    0.100  -14.622    0.000   -0.756   -0.654
    A3               -1.904    0.127  -14.986    0.000   -0.983   -0.763
    A4               -1.395    0.105  -13.335    0.000   -0.721   -0.498
    A5               -1.519    0.105  -14.445    0.000   -0.785   -0.625

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .A1                1.670    0.053   31.778    0.000    1.670    0.862
   .A2                0.766    0.030   25.148    0.000    0.766    0.572
   .A3                0.695    0.038   18.396    0.000    0.695    0.418
   .A4                1.576    0.053   29.959    0.000    1.576    0.752
   .A5                0.961    0.036   26.420    0.000    0.961    0.609
    Agreeableness     0.267    0.034    7.946    0.000    1.000    1.000

R-Square:
                   Estimate
    A1                0.138
    A2                0.428
    A3                0.582
    A4                0.248
    A5                0.391

The other way

standardized_results <- standardizedSolution(Model)
standardized_results
             lhs op           rhs est.std    se       z pvalue ci.lower
1  Agreeableness =~            A1   0.371 0.021  17.277      0    0.329
2  Agreeableness =~            A2  -0.654 0.017 -39.224      0   -0.687
3  Agreeableness =~            A3  -0.763 0.015 -50.008      0   -0.793
4  Agreeableness =~            A4  -0.498 0.019 -25.585      0   -0.536
5  Agreeableness =~            A5  -0.625 0.017 -36.458      0   -0.659
6             A1 ~~            A1   0.862 0.016  54.046      0    0.831
7             A2 ~~            A2   0.572 0.022  26.244      0    0.530
8             A3 ~~            A3   0.418 0.023  17.956      0    0.372
9             A4 ~~            A4   0.752 0.019  38.839      0    0.714
10            A5 ~~            A5   0.609 0.021  28.432      0    0.567
11 Agreeableness ~~ Agreeableness   1.000 0.000      NA     NA    1.000
   ci.upper
1     0.413
2    -0.621
3    -0.733
4    -0.460
5    -0.591
6     0.893
7     0.615
8     0.464
9     0.790
10    0.651
11    1.000
Loadings <- standardized_results %>% filter(op == "=~")
Loadings
            lhs op rhs est.std    se       z pvalue ci.lower ci.upper
1 Agreeableness =~  A1   0.371 0.021  17.277      0    0.329    0.413
2 Agreeableness =~  A2  -0.654 0.017 -39.224      0   -0.687   -0.621
3 Agreeableness =~  A3  -0.763 0.015 -50.008      0   -0.793   -0.733
4 Agreeableness =~  A4  -0.498 0.019 -25.585      0   -0.536   -0.460
5 Agreeableness =~  A5  -0.625 0.017 -36.458      0   -0.659   -0.591
Loadings$est.std*Loadings$est.std
[1] 0.1378110 0.4276852 0.5820366 0.2477713 0.3906677
FactorModel <- data.frame(Indicators = Loadings$lhs, 
                          Commun = Loadings$est.std*Loadings$est.std) %>% 
  mutate(Uniq = 1 - Commun)

FactorModel
     Indicators    Commun      Uniq
1 Agreeableness 0.1378110 0.8621890
2 Agreeableness 0.4276852 0.5723148
3 Agreeableness 0.5820366 0.4179634
4 Agreeableness 0.2477713 0.7522287
5 Agreeableness 0.3906677 0.6093323

Model Fit

One way

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

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Model Test Baseline Model:

  Test statistic                              2101.436
  Degrees of freedom                                10
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.967
  Tucker-Lewis Index (TLI)                       0.935

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)             -17817.725
  Loglikelihood unrestricted model (H1)     -17781.204
                                                      
  Akaike (AIC)                               35655.451
  Bayesian (BIC)                             35712.575
  Sample-size adjusted Bayesian (SABIC)      35680.804

Root Mean Square Error of Approximation:

  RMSEA                                          0.078
  90 Percent confidence interval - lower         0.063
  90 Percent confidence interval - upper         0.094
  P-value H_0: RMSEA <= 0.050                    0.002
  P-value H_0: RMSEA >= 0.080                    0.441

Standardized Root Mean Square Residual:

  SRMR                                           0.032

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness =~                                                      
    A1                1.000                               0.517    0.371
    A2               -1.464    0.100  -14.622    0.000   -0.756   -0.654
    A3               -1.904    0.127  -14.986    0.000   -0.983   -0.763
    A4               -1.395    0.105  -13.335    0.000   -0.721   -0.498
    A5               -1.519    0.105  -14.445    0.000   -0.785   -0.625

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .A1                1.670    0.053   31.778    0.000    1.670    0.862
   .A2                0.766    0.030   25.148    0.000    0.766    0.572
   .A3                0.695    0.038   18.396    0.000    0.695    0.418
   .A4                1.576    0.053   29.959    0.000    1.576    0.752
   .A5                0.961    0.036   26.420    0.000    0.961    0.609
    Agreeableness     0.267    0.034    7.946    0.000    1.000    1.000

R-Square:
                   Estimate
    A1                0.138
    A2                0.428
    A3                0.582
    A4                0.248
    A5                0.391

The better way

GoF = c("srmr", "rmsea", "tli", "cfi", "gfi", "agfi", "wrmr") 
fitmeasures(Model, fit.measures = GoF)
 srmr rmsea   tli   cfi   gfi  agfi  wrmr 
0.032 0.078 0.935 0.967 0.987 0.961 2.207 
fitmeasures(Model, fit.measures = "all")
                 npar                  fmin                 chisq 
               10.000                 0.016                73.043 
                   df                pvalue        baseline.chisq 
                5.000                 0.000              2101.436 
          baseline.df       baseline.pvalue                   cfi 
               10.000                 0.000                 0.967 
                  tli                  nnfi                   rfi 
                0.935                 0.935                 0.930 
                  nfi                  pnfi                   ifi 
                0.965                 0.483                 0.968 
                  rni                  logl     unrestricted.logl 
                0.967            -17817.725            -17781.204 
                  aic                   bic                ntotal 
            35655.451             35712.575              2236.000 
                 bic2                 rmsea        rmsea.ci.lower 
            35680.804                 0.078                 0.063 
       rmsea.ci.upper        rmsea.ci.level          rmsea.pvalue 
                0.094                 0.900                 0.002 
       rmsea.close.h0 rmsea.notclose.pvalue     rmsea.notclose.h0 
                0.050                 0.441                 0.080 
                  rmr            rmr_nomean                  srmr 
                0.054                 0.054                 0.032 
         srmr_bentler   srmr_bentler_nomean                  crmr 
                0.032                 0.032                 0.039 
          crmr_nomean            srmr_mplus     srmr_mplus_nomean 
                0.039                 0.032                 0.032 
                cn_05                 cn_01                   gfi 
              339.893               462.825                 0.987 
                 agfi                  pgfi                   mfi 
                0.961                 0.329                 0.985 
                 ecvi 
                0.042 

Model Fit: residual correlation matrix

lavInspect(Model)
$lambda
   Agrbln
A1      0
A2      1
A3      2
A4      3
A5      4

$theta
   A1 A2 A3 A4 A5
A1  5            
A2  0  6         
A3  0  0  7      
A4  0  0  0  8   
A5  0  0  0  0  9

$psi
              Agrbln
Agreeableness     10
fitted(Model)
$cov
       A1     A2     A3     A4     A5
A1  1.937                            
A2 -0.391  1.338                     
A3 -0.508  0.744  1.662              
A4 -0.372  0.545  0.709  2.096       
A5 -0.405  0.594  0.772  0.565  1.576
resid(Model)
$type
[1] "raw"

$cov
       A1     A2     A3     A4     A5
A1  0.000                            
A2 -0.157  0.000                     
A3  0.036 -0.021  0.000              
A4  0.083  0.028 -0.005  0.000       
A5  0.080 -0.039  0.042  0.007  0.000

Correlate errors

Equation <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
  A1 ~~ A2
'
Model <- sem(model = Equation, data = Test_Data)
summary(Model, standardized = TRUE, rsquare = TRUE,  fit.measures = TRUE)
lavaan 0.6.17 ended normally after 40 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        11

  Number of observations                          2236

Model Test User Model:
                                                      
  Test statistic                                11.480
  Degrees of freedom                                 4
  P-value (Chi-square)                           0.022

Model Test Baseline Model:

  Test statistic                              2101.436
  Degrees of freedom                                10
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.996
  Tucker-Lewis Index (TLI)                       0.991

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)             -17786.944
  Loglikelihood unrestricted model (H1)     -17781.204
                                                      
  Akaike (AIC)                               35595.888
  Bayesian (BIC)                             35658.725
  Sample-size adjusted Bayesian (SABIC)      35623.776

Root Mean Square Error of Approximation:

  RMSEA                                          0.029
  90 Percent confidence interval - lower         0.010
  90 Percent confidence interval - upper         0.049
  P-value H_0: RMSEA <= 0.050                    0.957
  P-value H_0: RMSEA >= 0.080                    0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.012

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness =~                                                      
    A1                1.000                               0.444    0.319
    A2               -1.626    0.121  -13.397    0.000   -0.723   -0.625
    A3               -2.267    0.182  -12.487    0.000   -1.007   -0.781
    A4               -1.626    0.140  -11.591    0.000   -0.722   -0.499
    A5               -1.789    0.145  -12.318    0.000   -0.795   -0.633

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .A1 ~~                                                                 
   .A2               -0.227    0.030   -7.537    0.000   -0.227   -0.190

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .A1                1.739    0.054   31.978    0.000    1.739    0.898
   .A2                0.816    0.031   26.003    0.000    0.816    0.610
   .A3                0.648    0.040   16.214    0.000    0.648    0.390
   .A4                1.574    0.053   29.846    0.000    1.574    0.751
   .A5                0.945    0.037   25.739    0.000    0.945    0.599
    Agreeableness     0.197    0.030    6.573    0.000    1.000    1.000

R-Square:
                   Estimate
    A1                0.102
    A2                0.390
    A3                0.610
    A4                0.249
    A5                0.401

Modification Indices

mod_indices <- modindices(Model)
mod_indices
   lhs op rhs    mi    epc sepc.lv sepc.all sepc.nox
13  A1 ~~  A3 3.656 -0.069  -0.069   -0.065   -0.065
14  A1 ~~  A4 2.093  0.054   0.054    0.032    0.032
15  A1 ~~  A5 1.010  0.032   0.032    0.025    0.025
16  A2 ~~  A3 1.616 -0.047  -0.047   -0.065   -0.065
17  A2 ~~  A4 8.826  0.088   0.088    0.078    0.078
18  A2 ~~  A5 1.880 -0.040  -0.040   -0.045   -0.045
19  A3 ~~  A4 4.517 -0.086  -0.086   -0.085   -0.085
20  A3 ~~  A5 5.447  0.110   0.110    0.141    0.141
21  A4 ~~  A5 0.005 -0.002  -0.002   -0.002   -0.002

Estimation method

Equation <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
'
Model <- sem(model = Equation, data = Test_Data, 
             estimator = "DWLS")
Warning in lav_options_set(opt): lavaan WARNING: estimator "DWLS" is not recommended for continuous data.
          Did you forget to set the ordered= argument?
summary(Model)
lavaan 0.6.17 ended normally after 39 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        10

  Number of observations                          2236

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

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness =~                                    
    A1                1.000                           
    A2               -1.545    0.101  -15.244    0.000
    A3               -1.927    0.128  -15.031    0.000
    A4               -1.403    0.097  -14.510    0.000
    A5               -1.505    0.100  -15.044    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A1                1.679    0.062   27.269    0.000
   .A2                0.722    0.068   10.622    0.000
   .A3                0.703    0.089    7.939    0.000
   .A4                1.588    0.079   20.077    0.000
   .A5                0.992    0.067   14.801    0.000
    Agreeableness     0.258    0.027    9.680    0.000
Model <- sem(model = Equation, data = Test_Data, 
             ordered = c("A1"))
summary(Model)
lavaan 0.6.17 ended normally after 33 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        18

  Number of observations                          2236

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                33.453      97.056
  Degrees of freedom                                 5           5
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  0.347
  Shift parameter                                            0.539
    simple second-order correction                                

Parameter Estimates:

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

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  Agreeableness =~                                    
    A1                1.000                           
    A2               -1.910    0.105  -18.262    0.000
    A3               -2.303    0.127  -18.111    0.000
    A4               -1.702    0.117  -14.535    0.000
    A5               -1.801    0.104  -17.309    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A2                4.834    0.032  150.429    0.000
   .A3                4.629    0.036  129.587    0.000
   .A4                4.750    0.045  105.702    0.000
   .A5                4.585    0.033  139.600    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)
    A1|t1            -0.404    0.027  -14.800    0.000
    A1|t2             0.361    0.027   13.291    0.000
    A1|t3             0.778    0.030   26.249    0.000
    A1|t4             1.270    0.036   35.331    0.000
    A1|t5             1.895    0.054   35.341    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .A1                0.825                           
   .A2                0.700    0.023   30.298    0.000
   .A3                0.734    0.030   24.245    0.000
   .A4                1.589    0.058   27.557    0.000
   .A5                1.009    0.033   30.685    0.000
    Agreeableness     0.175    0.017   10.248    0.000

Plots

Equation <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
  A1 ~~ A2
'
Model <- sem(model = Equation, data = Test_Data)
semPaths(Model)

semPaths(Model, "std")

semPaths(Model)

semPaths(Model, what = "std", whatLabels = "hide")

semPaths(Model, "std", weighted = FALSE, nCharNodes = 7, shapeMan = "rectangle",
         sizeMan = 8, sizeMan2 = 5)

Factor scores

CFA_Scores <- lavPredict(Model, method = "Bartlett")
CFA_Scores <- as.data.frame(CFA_Scores)
head(CFA_Scores)
  Agreeableness
1   -0.26825111
2    1.41612786
3   -0.07632916
4    1.16001828
5   -0.51745712
6   -0.34789907

Second CFA

Model_Equations <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
  Conscientiousness =~ C1 + C2 + C3 + C4 + C5
  Extraversion =~ E1 + E2 + E3 + E4 + E5  
  Neuroticism =~ N1 + N2 + N3 + N4 + N5
  Opennness =~ O1 + O2 + O3 + O4 + O5
'
Model <- sem(model = Model_Equations, 
                    data = Test_Data)
summary(Model, standardized = TRUE, rsquare = TRUE,  fit.measures = TRUE)
lavaan 0.6.17 ended normally after 56 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        60

  Number of observations                          2236

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

Model Test Baseline Model:

  Test statistic                             16560.077
  Degrees of freedom                               300
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.780
  Tucker-Lewis Index (TLI)                       0.751

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)             -91289.278
  Loglikelihood unrestricted model (H1)     -89367.630
                                                      
  Akaike (AIC)                              182698.556
  Bayesian (BIC)                            183041.303
  Sample-size adjusted Bayesian (SABIC)     182850.673

Root Mean Square Error of Approximation:

  RMSEA                                          0.078
  90 Percent confidence interval - lower         0.076
  90 Percent confidence interval - upper         0.080
  P-value H_0: RMSEA <= 0.050                    0.000
  P-value H_0: RMSEA >= 0.080                    0.042

Standardized Root Mean Square Residual:

  SRMR                                           0.076

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                       Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness =~                                                          
    A1                    1.000                               0.460    0.330
    A2                   -1.595    0.119  -13.378    0.000   -0.734   -0.634
    A3                   -2.077    0.151  -13.791    0.000   -0.955   -0.741
    A4                   -1.583    0.127  -12.502    0.000   -0.728   -0.503
    A5                   -1.852    0.136  -13.579    0.000   -0.852   -0.678
  Conscientiousness =~                                                      
    C1                    1.000                               0.652    0.536
    C2                    1.162    0.063   18.575    0.000    0.758    0.578
    C3                    1.085    0.060   18.025    0.000    0.707    0.550
    C4                   -1.456    0.072  -20.321    0.000   -0.949   -0.697
    C5                   -1.554    0.080  -19.339    0.000   -1.014   -0.622
  Extraversion =~                                                           
    E1                    1.000                               0.907    0.560
    E2                    1.229    0.054   22.760    0.000    1.114    0.694
    E3                   -0.955    0.044  -21.821    0.000   -0.866   -0.645
    E4                   -1.132    0.049  -22.933    0.000   -1.027   -0.704
    E5                   -0.823    0.041  -19.948    0.000   -0.746   -0.561
  Neuroticism =~                                                            
    N1                    1.000                               1.284    0.821
    N2                    0.951    0.025   37.549    0.000    1.222    0.796
    N3                    0.897    0.026   34.192    0.000    1.152    0.722
    N4                    0.694    0.026   26.358    0.000    0.891    0.571
    N5                    0.642    0.028   23.208    0.000    0.825    0.509
  Opennness =~                                                              
    O1                    1.000                               0.629    0.562
    O2                   -1.058    0.072  -14.654    0.000   -0.666   -0.431
    O3                    1.368    0.075   18.182    0.000    0.861    0.722
    O4                    0.413    0.049    8.390    0.000    0.260    0.221
    O5                   -1.006    0.064  -15.717    0.000   -0.633   -0.476

Covariances:
                       Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness ~~                                                          
    Conscientisnss       -0.098    0.011   -8.529    0.000   -0.326   -0.326
    Extraversion          0.289    0.025   11.452    0.000    0.693    0.693
    Neuroticism           0.122    0.018    6.855    0.000    0.207    0.207
    Opennness            -0.078    0.011   -7.371    0.000   -0.268   -0.268
  Conscientiousness ~~                                                      
    Extraversion         -0.213    0.020  -10.607    0.000   -0.360   -0.360
    Neuroticism          -0.234    0.025   -9.499    0.000   -0.279   -0.279
    Opennness             0.117    0.014    8.374    0.000    0.284    0.284
  Extraversion ~~                                                           
    Neuroticism           0.272    0.032    8.424    0.000    0.234    0.234
    Opennness            -0.256    0.022  -11.765    0.000   -0.448   -0.448
  Neuroticism ~~                                                            
    Opennness            -0.092    0.023   -4.036    0.000   -0.114   -0.114

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .A1                1.725    0.053   32.366    0.000    1.725    0.891
   .A2                0.800    0.029   27.408    0.000    0.800    0.598
   .A3                0.749    0.033   22.455    0.000    0.749    0.451
   .A4                1.566    0.051   30.453    0.000    1.566    0.747
   .A5                0.851    0.033   25.743    0.000    0.851    0.540
   .C1                1.054    0.036   29.030    0.000    1.054    0.713
   .C2                1.144    0.041   27.927    0.000    1.144    0.666
   .C3                1.156    0.040   28.702    0.000    1.156    0.698
   .C4                0.955    0.041   23.026    0.000    0.955    0.514
   .C5                1.627    0.061   26.462    0.000    1.627    0.613
   .E1                1.795    0.060   29.892    0.000    1.795    0.686
   .E2                1.336    0.051   26.168    0.000    1.336    0.519
   .E3                1.052    0.038   27.886    0.000    1.052    0.584
   .E4                1.074    0.042   25.751    0.000    1.074    0.505
   .E5                1.211    0.041   29.874    0.000    1.211    0.685
   .N1                0.797    0.038   20.788    0.000    0.797    0.326
   .N2                0.862    0.038   22.748    0.000    0.862    0.366
   .N3                1.219    0.045   26.884    0.000    1.219    0.479
   .N4                1.640    0.054   30.599    0.000    1.640    0.674
   .N5                1.950    0.062   31.403    0.000    1.950    0.741
   .O1                0.858    0.033   26.204    0.000    0.858    0.684
   .O2                1.945    0.065   30.040    0.000    1.945    0.814
   .O3                0.682    0.040   17.205    0.000    0.682    0.479
   .O4                1.313    0.040   32.692    0.000    1.313    0.951
   .O5                1.366    0.047   29.009    0.000    1.366    0.773
    Agreeableness     0.212    0.030    7.164    0.000    1.000    1.000
    Conscientisnss    0.425    0.036   11.849    0.000    1.000    1.000
    Extraversion      0.822    0.063   13.047    0.000    1.000    1.000
    Neuroticism       1.649    0.075   21.871    0.000    1.000    1.000
    Opennness         0.396    0.034   11.622    0.000    1.000    1.000

R-Square:
                   Estimate
    A1                0.109
    A2                0.402
    A3                0.549
    A4                0.253
    A5                0.460
    C1                0.287
    C2                0.334
    C3                0.302
    C4                0.486
    C5                0.387
    E1                0.314
    E2                0.481
    E3                0.416
    E4                0.495
    E5                0.315
    N1                0.674
    N2                0.634
    N3                0.521
    N4                0.326
    N5                0.259
    O1                0.316
    O2                0.186
    O3                0.521
    O4                0.049
    O5                0.227
semPaths(Model, what = "std", whatLabels = "hide")

Third CFA

Model_Equations <- '
  Agreeableness =~ A1 + A2 + A3 + A4 + A5
  Conscientiousness =~ C1 + C2 + C3 + C4 + C5
  Extraversion =~ E1 + E2 + E3 + E4 + E5  
  Neuroticism =~ N1 + N2 + N3 + N4 + N5
  Opennness =~ O1 + O2 + O3 + O4 + O5
  
  SuperLatent =~ Agreeableness + Conscientiousness +  Extraversion +  Neuroticism +  Opennness
'
Model <- sem(model = Model_Equations, 
                    data = Test_Data)
summary(Model, standardized = TRUE, rsquare = TRUE,  fit.measures = TRUE)
lavaan 0.6.17 ended normally after 76 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        55

  Number of observations                          2236

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

Model Test Baseline Model:

  Test statistic                             16560.077
  Degrees of freedom                               300
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.775
  Tucker-Lewis Index (TLI)                       0.750

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)             -91328.791
  Loglikelihood unrestricted model (H1)     -89367.630
                                                      
  Akaike (AIC)                              182767.581
  Bayesian (BIC)                            183081.766
  Sample-size adjusted Bayesian (SABIC)     182907.022

Root Mean Square Error of Approximation:

  RMSEA                                          0.078
  90 Percent confidence interval - lower         0.076
  90 Percent confidence interval - upper         0.080
  P-value H_0: RMSEA <= 0.050                    0.000
  P-value H_0: RMSEA >= 0.080                    0.046

Standardized Root Mean Square Residual:

  SRMR                                           0.079

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Latent Variables:
                       Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Agreeableness =~                                                          
    A1                    1.000                               0.465    0.334
    A2                   -1.580    0.117  -13.506    0.000   -0.734   -0.635
    A3                   -2.061    0.148  -13.933    0.000   -0.958   -0.743
    A4                   -1.550    0.123  -12.559    0.000   -0.721   -0.498
    A5                   -1.831    0.134  -13.708    0.000   -0.851   -0.678
  Conscientiousness =~                                                      
    C1                    1.000                               0.662    0.544
    C2                    1.172    0.062   18.915    0.000    0.776    0.592
    C3                    1.083    0.059   18.255    0.000    0.717    0.557
    C4                   -1.408    0.069  -20.284    0.000   -0.932   -0.684
    C5                   -1.507    0.078  -19.267    0.000   -0.997   -0.612
  Extraversion =~                                                           
    E1                    1.000                               0.903    0.558
    E2                    1.246    0.055   22.776    0.000    1.125    0.701
    E3                   -0.946    0.044  -21.558    0.000   -0.854   -0.636
    E4                   -1.142    0.050  -22.877    0.000   -1.031   -0.707
    E5                   -0.828    0.042  -19.901    0.000   -0.748   -0.562
  Neuroticism =~                                                            
    N1                    1.000                               1.285    0.822
    N2                    0.953    0.025   37.577    0.000    1.225    0.798
    N3                    0.896    0.026   34.138    0.000    1.151    0.721
    N4                    0.690    0.026   26.201    0.000    0.887    0.568
    N5                    0.642    0.028   23.197    0.000    0.824    0.508
  Opennness =~                                                              
    O1                    1.000                               0.624    0.557
    O2                   -1.047    0.073  -14.409    0.000   -0.653   -0.423
    O3                    1.394    0.078   17.957    0.000    0.870    0.729
    O4                    0.431    0.050    8.636    0.000    0.269    0.229
    O5                   -1.010    0.065  -15.615    0.000   -0.630   -0.474
  SuperLatent =~                                                            
    Agreeableness         1.000                               0.741    0.741
    Conscientisnss       -0.830    0.085   -9.713    0.000   -0.431   -0.431
    Extraversion          2.405    0.221   10.902    0.000    0.917    0.917
    Neuroticism           1.049    0.124    8.449    0.000    0.281    0.281
    Opennness            -0.840    0.086   -9.729    0.000   -0.464   -0.464

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .A1                1.721    0.053   32.336    0.000    1.721    0.888
   .A2                0.799    0.029   27.363    0.000    0.799    0.597
   .A3                0.744    0.033   22.280    0.000    0.744    0.448
   .A4                1.576    0.052   30.522    0.000    1.576    0.752
   .A5                0.852    0.033   25.723    0.000    0.852    0.540
   .C1                1.041    0.036   28.730    0.000    1.041    0.704
   .C2                1.117    0.041   27.370    0.000    1.117    0.650
   .C3                1.142    0.040   28.392    0.000    1.142    0.690
   .C4                0.987    0.042   23.497    0.000    0.987    0.532
   .C5                1.660    0.062   26.679    0.000    1.660    0.625
   .E1                1.802    0.060   29.922    0.000    1.802    0.689
   .E2                1.312    0.051   25.854    0.000    1.312    0.509
   .E3                1.072    0.038   28.114    0.000    1.072    0.595
   .E4                1.066    0.042   25.593    0.000    1.066    0.501
   .E5                1.209    0.041   29.843    0.000    1.209    0.684
   .N1                0.795    0.038   20.689    0.000    0.795    0.325
   .N2                0.855    0.038   22.567    0.000    0.855    0.363
   .N3                1.222    0.045   26.897    0.000    1.222    0.480
   .N4                1.648    0.054   30.637    0.000    1.648    0.677
   .N5                1.950    0.062   31.400    0.000    1.950    0.741
   .O1                0.864    0.033   26.299    0.000    0.864    0.689
   .O2                1.962    0.065   30.184    0.000    1.962    0.821
   .O3                0.666    0.040   16.480    0.000    0.666    0.468
   .O4                1.309    0.040   32.638    0.000    1.309    0.948
   .O5                1.370    0.047   29.030    0.000    1.370    0.775
   .Agreeableness     0.098    0.015    6.505    0.000    0.452    0.452
   .Conscientisnss    0.356    0.031   11.649    0.000    0.814    0.814
   .Extraversion      0.129    0.036    3.621    0.000    0.159    0.159
   .Neuroticism       1.521    0.071   21.361    0.000    0.921    0.921
   .Opennness         0.306    0.028   11.066    0.000    0.785    0.785
    SuperLatent       0.119    0.018    6.538    0.000    1.000    1.000

R-Square:
                   Estimate
    A1                0.112
    A2                0.403
    A3                0.552
    A4                0.248
    A5                0.460
    C1                0.296
    C2                0.350
    C3                0.310
    C4                0.468
    C5                0.375
    E1                0.311
    E2                0.491
    E3                0.405
    E4                0.499
    E5                0.316
    N1                0.675
    N2                0.637
    N3                0.520
    N4                0.323
    N5                0.259
    O1                0.311
    O2                0.179
    O3                0.532
    O4                0.052
    O5                0.225
    Agreeableness     0.548
    Conscientisnss    0.186
    Extraversion      0.841
    Neuroticism       0.079
    Opennness         0.215

Fourth CFA: Your turn

data(HolzingerSwineford1939)
head(HolzingerSwineford1939)
  id sex ageyr agemo  school grade       x1   x2    x3       x4   x5        x6
1  1   1    13     1 Pasteur     7 3.333333 7.75 0.375 2.333333 5.75 1.2857143
2  2   2    13     7 Pasteur     7 5.333333 5.25 2.125 1.666667 3.00 1.2857143
3  3   2    13     1 Pasteur     7 4.500000 5.25 1.875 1.000000 1.75 0.4285714
4  4   1    13     2 Pasteur     7 5.333333 7.75 3.000 2.666667 4.50 2.4285714
5  5   2    12     2 Pasteur     7 4.833333 4.75 0.875 2.666667 4.00 2.5714286
6  6   2    14     1 Pasteur     7 5.333333 5.00 2.250 1.000000 3.00 0.8571429
        x7   x8       x9
1 3.391304 5.75 6.361111
2 3.782609 6.25 7.916667
3 3.260870 3.90 4.416667
4 3.000000 5.30 4.861111
5 3.695652 6.30 5.916667
6 4.347826 6.65 7.500000

Final exampe: Your turn

data(PoliticalDemocracy)
head(PoliticalDemocracy)
     y1       y2       y3       y4       y5       y6       y7       y8       x1
1  2.50 0.000000 3.333333 0.000000 1.250000 0.000000 3.726360 3.333333 4.442651
2  1.25 0.000000 3.333333 0.000000 6.250000 1.100000 6.666666 0.736999 5.384495
3  7.50 8.800000 9.999998 9.199991 8.750000 8.094061 9.999998 8.211809 5.961005
4  8.90 8.800000 9.999998 9.199991 8.907948 8.127979 9.999998 4.615086 6.285998
5 10.00 3.333333 9.999998 6.666666 7.500000 3.333333 9.999998 6.666666 5.863631
6  7.50 3.333333 6.666666 6.666666 6.250000 1.100000 6.666666 0.368500 5.533389
        x2       x3
1 3.637586 2.557615
2 5.062595 3.568079
3 6.255750 5.224433
4 7.567863 6.267495
5 6.818924 4.573679
6 5.135798 3.892270