data <- read.csv("C:/Users/LENOVO/OneDrive/Documents/tugas kelompok bu guru/tugas kelompok buguru/WVS_Cross-National_Wave_7_csv_v6_0.csv")
str(data)
## 'data.frame':    97220 obs. of  613 variables:
##  $ version                   : chr  "6-0-0 (2024-04-30)" "6-0-0 (2024-04-30)" "6-0-0 (2024-04-30)" "6-0-0 (2024-04-30)" ...
##  $ doi                       : chr  "doi.org/10.14281/18241.24" "doi.org/10.14281/18241.24" "doi.org/10.14281/18241.24" "doi.org/10.14281/18241.24" ...
##  $ A_WAVE                    : int  7 7 7 7 7 7 7 7 7 7 ...
##  $ A_YEAR                    : int  2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 ...
##  $ A_STUDY                   : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ B_COUNTRY                 : int  20 20 20 20 20 20 20 20 20 20 ...
##  $ B_COUNTRY_ALPHA           : chr  "AND" "AND" "AND" "AND" ...
##  $ C_COW_NUM                 : int  232 232 232 232 232 232 232 232 232 232 ...
##  $ C_COW_ALPHA               : chr  "AND" "AND" "AND" "AND" ...
##  $ D_INTERVIEW               : int  20070001 20070002 20070003 20070004 20070005 20070006 20070007 20070008 20070009 20070010 ...
##  $ S007                      : int  20720001 20720002 20720003 20720004 20720005 20720006 20720007 20720008 20720009 20720010 ...
##  $ J_INTDATE                 : int  20180704 20180714 20180704 20180702 20180708 20180724 20180721 20180703 20180703 20180703 ...
##  $ FW_START                  : int  201807 201807 201807 201807 201807 201807 201807 201807 201807 201807 ...
##  $ FW_END                    : int  201809 201809 201809 201809 201809 201809 201809 201809 201809 201809 ...
##  $ K_TIME_START              : num  18.2 9.35 10.15 17.05 10.2 ...
##  $ K_TIME_END                : num  19.5 11 10.4 18.2 11.5 ...
##  $ K_DURATION                : int  88 85 30 75 89 45 44 60 74 41 ...
##  $ Q_MODE                    : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ N_REGION_ISO              : int  20007 20003 20003 20003 20003 20006 20006 20008 20008 20008 ...
##  $ N_REGION_WVS              : int  20005 20002 20002 20002 20002 20006 20006 20007 20007 20007 ...
##  $ N_REGION_NUTS2            : int  -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 ...
##  $ N_REG_NUTS1               : int  -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 ...
##  $ N_TOWN                    : int  20005 20002 20002 20002 20002 20006 20006 20007 20007 20007 ...
##  $ G_TOWNSIZE                : int  5 3 3 3 3 3 3 4 4 4 ...
##  $ G_TOWNSIZE2               : int  3 2 2 2 2 2 2 2 2 2 ...
##  $ H_SETTLEMENT              : int  1 2 2 2 2 2 2 2 2 2 ...
##  $ H_URBRURAL                : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ I_PSU                     : int  -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 ...
##  $ O1_LONGITUDE              : num  1.52 1.53 1.58 1.58 1.58 1.52 1.49 1.54 1.54 1.73 ...
##  $ O2_LATITUDE               : num  42.5 42.5 42.5 42.5 42.5 ...
##  $ L_INTERVIEWER_NUMBER      : int  -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 ...
##  $ S_INTLANGUAGE             : int  810 810 810 810 810 1270 1270 810 810 810 ...
##  $ LNGE_ISO                  : chr  "ca" "ca" "ca" "ca" ...
##  $ E_RESPINT                 : int  1 1 1 2 2 1 1 1 1 1 ...
##  $ F_INTPRIVACY              : int  1 1 1 1 1 1 1 2 2 2 ...
##  $ E1_LITERACY               : int  -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 ...
##  $ W_WEIGHT                  : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ S018                      : num  0.996 0.996 0.996 0.996 0.996 ...
##  $ PWGHT                     : num  0.00684 0.00684 0.00684 0.00684 0.00684 ...
##  $ S025                      : int  202018 202018 202018 202018 202018 202018 202018 202018 202018 202018 ...
##  $ Q1                        : int  1 1 1 1 1 1 1 1 2 1 ...
##  $ Q2                        : int  1 1 2 1 1 3 2 1 2 1 ...
##  $ Q3                        : int  1 1 2 1 1 1 1 1 1 2 ...
##  $ Q4                        : int  3 4 2 4 3 4 4 1 1 4 ...
##  $ Q5                        : int  1 1 3 2 1 1 1 1 2 2 ...
##  $ Q6                        : int  4 4 3 4 3 3 2 3 1 2 ...
##  $ Q7                        : int  1 1 2 1 1 1 1 1 1 1 ...
##  $ Q8                        : int  1 2 1 2 2 2 2 2 2 1 ...
##  $ Q9                        : int  2 1 2 2 1 2 2 1 2 2 ...
##  $ Q10                       : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ Q11                       : int  1 2 1 2 2 2 2 2 2 1 ...
##  $ Q12                       : int  2 1 1 1 1 1 1 2 1 1 ...
##  $ Q13                       : int  2 2 2 2 2 1 1 1 2 2 ...
##  $ Q14                       : int  2 2 1 1 1 2 2 2 1 2 ...
##  $ Q15                       : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ Q16                       : int  2 2 2 2 2 1 1 2 1 2 ...
##  $ Q17                       : int  1 1 2 1 2 2 2 1 2 2 ...
##  $ Q18                       : int  1 1 1 1 1 1 2 2 1 1 ...
##  $ Q19                       : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ Q20                       : int  1 2 2 2 2 2 2 2 1 2 ...
##  $ Q21                       : int  2 2 2 2 2 2 2 1 2 2 ...
##  $ Q22                       : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ Q23                       : int  2 2 2 2 2 2 2 1 2 2 ...
##  $ Q24                       : int  1 2 1 2 1 1 2 1 2 1 ...
##  $ Q25                       : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ Q26                       : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ Q27                       : int  3 3 3 3 3 1 1 2 2 1 ...
##  $ Q28                       : int  3 3 3 3 3 1 1 3 3 1 ...
##  $ Q29                       : int  3 3 3 4 3 2 4 4 4 3 ...
##  $ Q30                       : int  3 3 3 4 3 4 4 4 4 3 ...
##  $ Q31                       : int  3 3 3 4 3 4 2 4 4 3 ...
##  $ Q32                       : int  3 3 -2 4 2 4 1 4 3 3 ...
##  $ Q33                       : int  4 4 4 4 4 5 5 5 5 4 ...
##  $ Q33_3                     : int  2 2 2 2 2 2 2 2 2 2 ...
##  $ Q34                       : int  2 2 4 2 4 5 5 1 1 4 ...
##  $ Q34_3                     : int  1 1 2 1 2 2 2 1 1 2 ...
##  $ Q35                       : int  3 4 2 4 4 5 5 1 4 5 ...
##  $ Q35_3                     : int  3 2 1 2 2 2 2 1 2 2 ...
##  $ Q36                       : int  3 2 4 3 3 1 1 3 3 1 ...
##  $ Q37                       : int  4 4 4 4 3 1 5 5 5 3 ...
##  $ Q38                       : int  3 2 3 4 3 1 3 5 3 3 ...
##  $ Q39                       : int  2 2 2 2 3 1 3 -2 3 1 ...
##  $ Q40                       : int  3 2 4 4 3 1 1 1 2 4 ...
##  $ Q41                       : int  3 2 4 4 4 1 5 3 5 5 ...
##  $ Q42                       : int  2 2 2 1 1 2 2 2 2 2 ...
##  $ Q43                       : int  2 2 1 1 1 1 1 2 1 1 ...
##  $ Q44                       : int  3 1 2 1 1 3 2 1 2 1 ...
##  $ Q45                       : int  1 1 1 2 2 1 1 2 2 2 ...
##  $ Q46                       : int  1 1 2 2 2 1 2 2 1 1 ...
##  $ Q47                       : int  3 1 1 2 2 1 1 2 2 1 ...
##  $ Q48                       : int  10 9 9 9 8 10 10 8 8 10 ...
##  $ Q49                       : int  10 9 9 8 7 10 5 8 8 10 ...
##  $ Q50                       : int  5 9 8 6 7 6 4 9 6 10 ...
##  $ Q51                       : int  4 4 4 4 4 4 2 4 4 4 ...
##  $ Q52                       : int  4 4 4 4 4 4 3 4 4 4 ...
##  $ Q53                       : int  4 4 4 4 4 4 4 4 4 4 ...
##  $ Q54                       : int  4 4 3 4 4 4 2 4 3 4 ...
##  $ Q55                       : int  4 4 4 4 4 4 2 4 4 4 ...
##  $ Q56                       : int  1 1 2 3 -2 3 1 -2 3 2 ...
##   [list output truncated]
## Seleksi variabel (lebih banyak tapi aman)
data_sem <- data[, c(
  "Q46","Q47","Q48",      # WellBeing
  "Q57","Q58","Q59",      # Trust
  "Q164","Q165","Q166",   # Religion
  "Q108","Q109"           # Freedom
)]

# Rename
colnames(data_sem) <- c(
  "Happy","LifeSat","Health",
  "Trust1","Trust2","Trust3",
  "Rel1","Rel2","Rel3",
  "Freedom1","Freedom2"
)
head(data_sem)
##   Happy LifeSat Health Trust1 Trust2 Trust3 Rel1 Rel2 Rel3 Freedom1 Freedom2
## 1     1       3     10      2      1      2    7    1    1        2       10
## 2     1       1      9      2      1      2    1    2    2        2        2
## 3     2       1      9      2      1      3    8    1    1        5        2
## 4     2       2      9      2      1      2    1    2    2        5        4
## 5     2       2      8      2      1      2    4    2    2        7        2
## 6     1       1     10      2      2      2    3    1    1        1       10
data_sem[data_sem < 0] <- NA

data_sem <- na.omit(data_sem)

sum(is.na(data_sem))
## [1] 0
par(mfrow = c(1, 4))

for (col in colnames(data_sem)) {
  hist(data_sem[[col]],
       main = col,
       col = "lightblue",
       border = "black")
}

par(mfrow = c(1,1))

data_z <- as.data.frame(scale(data_sem))

summary(data_z)
##      Happy            LifeSat            Health            Trust1       
##  Min.   :-1.2023   Min.   :-1.3478   Min.   :-2.7901   Min.   :-1.7489  
##  1st Qu.:-1.2023   1st Qu.:-0.1979   1st Qu.:-0.5605   1st Qu.: 0.5718  
##  Median : 0.2239   Median :-0.1979   Median : 0.3313   Median : 0.5718  
##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 0.2239   3rd Qu.: 0.9521   3rd Qu.: 0.7773   3rd Qu.: 0.5718  
##  Max.   : 3.0761   Max.   : 3.2520   Max.   : 1.2232   Max.   : 0.5718  
##      Trust2            Trust3            Rel1              Rel2        
##  Min.   :-0.4901   Min.   :-1.502   Min.   :-1.9675   Min.   :-0.5007  
##  1st Qu.:-0.4901   1st Qu.:-0.243   1st Qu.:-0.7324   1st Qu.:-0.5007  
##  Median :-0.4901   Median :-0.243   Median : 0.5027   Median :-0.5007  
##  Mean   : 0.0000   Mean   : 0.000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.:-0.4901   3rd Qu.: 1.016   3rd Qu.: 0.8115   3rd Qu.:-0.5007  
##  Max.   : 4.7711   Max.   : 2.274   Max.   : 0.8115   Max.   : 1.9970  
##       Rel3            Freedom1           Freedom2       
##  Min.   :-0.7482   Min.   :-1.35475   Min.   :-1.11935  
##  1st Qu.:-0.7482   1st Qu.:-1.01997   1st Qu.:-1.11935  
##  Median :-0.7482   Median :-0.01562   Median :-0.01004  
##  Mean   : 0.0000   Mean   : 0.00000   Mean   : 0.00000  
##  3rd Qu.: 1.3364   3rd Qu.: 0.65394   3rd Qu.: 0.72950  
##  Max.   : 1.3364   Max.   : 1.65829   Max.   : 2.20859
summary(data_sem)
##      Happy          LifeSat          Health           Trust1     
##  Min.   :1.000   Min.   :1.000   Min.   : 1.000   Min.   :1.000  
##  1st Qu.:1.000   1st Qu.:2.000   1st Qu.: 6.000   1st Qu.:2.000  
##  Median :2.000   Median :2.000   Median : 8.000   Median :2.000  
##  Mean   :1.843   Mean   :2.172   Mean   : 7.257   Mean   :1.754  
##  3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.: 9.000   3rd Qu.:2.000  
##  Max.   :4.000   Max.   :5.000   Max.   :10.000   Max.   :2.000  
##      Trust2          Trust3           Rel1             Rel2          Rel3      
##  Min.   :1.000   Min.   :1.000   Min.   : 1.000   Min.   :1.0   Min.   :1.000  
##  1st Qu.:1.000   1st Qu.:2.000   1st Qu.: 5.000   1st Qu.:1.0   1st Qu.:1.000  
##  Median :1.000   Median :2.000   Median : 9.000   Median :1.0   Median :1.000  
##  Mean   :1.279   Mean   :2.193   Mean   : 7.372   Mean   :1.2   Mean   :1.359  
##  3rd Qu.:1.000   3rd Qu.:3.000   3rd Qu.:10.000   3rd Qu.:1.0   3rd Qu.:2.000  
##  Max.   :4.000   Max.   :4.000   Max.   :10.000   Max.   :2.0   Max.   :2.000  
##     Freedom1         Freedom2     
##  Min.   : 1.000   Min.   : 1.000  
##  1st Qu.: 2.000   1st Qu.: 1.000  
##  Median : 5.000   Median : 4.000  
##  Mean   : 5.047   Mean   : 4.027  
##  3rd Qu.: 7.000   3rd Qu.: 6.000  
##  Max.   :10.000   Max.   :10.000
describe(data_sem)
##          vars     n mean   sd median trimmed  mad min max range  skew kurtosis
## Happy       1 83948 1.84 0.70      2    1.78 0.00   1   4     3  0.58     0.35
## LifeSat     2 83948 2.17 0.87      2    2.13 1.48   1   5     4  0.49     0.12
## Health      3 83948 7.26 2.24      8    7.48 2.97   1  10     9 -0.68     0.02
## Trust1      4 83948 1.75 0.43      2    1.82 0.00   1   2     1 -1.18    -0.61
## Trust2      5 83948 1.28 0.57      1    1.16 0.00   1   4     3  2.22     5.10
## Trust3      6 83948 2.19 0.79      2    2.15 0.00   1   4     3  0.48    -0.04
## Rel1        7 83948 7.37 3.24      9    7.84 1.48   1  10     9 -0.90    -0.67
## Rel2        8 83948 1.20 0.40      1    1.13 0.00   1   2     1  1.50     0.24
## Rel3        9 83948 1.36 0.48      1    1.32 0.00   1   2     1  0.59    -1.65
## Freedom1   10 83948 5.05 2.99      5    4.93 4.45   1  10     9  0.15    -1.15
## Freedom2   11 83948 4.03 2.70      4    3.73 2.97   1  10     9  0.63    -0.53
##            se
## Happy    0.00
## LifeSat  0.00
## Health   0.01
## Trust1   0.00
## Trust2   0.00
## Trust3   0.00
## Rel1     0.01
## Rel2     0.00
## Rel3     0.00
## Freedom1 0.01
## Freedom2 0.01
# karena menggunakan semua kardia maka harus dibutuhkan 60 Gb sehingga terlalu berat solusinya adalah dengan mengambil smple saja
data_z_sample <- data_z[sample(nrow(data_z), 500), ]

mardia(data_z_sample)

## Call: mardia(x = data_z_sample)
## 
## Mardia tests of multivariate skew and kurtosis
## Use describe(x) the to get univariate tests
## n.obs = 500   num.vars =  11 
## b1p =  15.04   skew =  1253.6  with probability  <=  4.5e-121
##  small sample skew =  1262.38  with probability <=  1.5e-122
## b2p =  153.96   kurtosis =  7.25  with probability <=  4.2e-13
model_vif <- lm(Happy ~ LifeSat + Trust1 + Trust2 + Trust3 + Rel1 + Rel2 + Rel3 + Freedom1 + Freedom2,
                data = data_z)

vif(model_vif)
##  LifeSat   Trust1   Trust2   Trust3     Rel1     Rel2     Rel3 Freedom1 
## 1.026105 1.133169 1.125227 1.167758 2.191392 2.276172 1.352579 1.022354 
## Freedom2 
## 1.024749
KMO(cor(data_z))
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = cor(data_z))
## Overall MSA =  0.65
## MSA for each item = 
##    Happy  LifeSat   Health   Trust1   Trust2   Trust3     Rel1     Rel2 
##     0.62     0.63     0.66     0.75     0.60     0.58     0.64     0.63 
##     Rel3 Freedom1 Freedom2 
##     0.82     0.57     0.56
model_cfa <- '
WellBeing =~ Happy + LifeSat + Health
Trust =~ Trust1 + Trust2 + Trust3
Religion =~ Rel1 + Rel2 + Rel3
Freedom =~ Freedom1 + Freedom2
'

fit_cfa <- cfa(model_cfa, data = data_z, std.lv = TRUE)
## Warning: lavaan->lav_model_vcov():  
##    Could not compute standard errors! The information matrix could not be 
##    inverted. This may be a symptom that the model is not identified.
## Warning: lavaan->lav_object_post_check():  
##    some estimated ov variances are negative
summary(fit_cfa, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-21 ended normally after 7585 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
## 
##   Number of observations                         83948
## 
## Model Test User Model:
##                                                       
##   Test statistic                              9156.102
##   Degrees of freedom                                38
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                            133105.281
##   Degrees of freedom                                55
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.931
##   Tucker-Lewis Index (TLI)                       0.901
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)           -1248307.482
##   Loglikelihood unrestricted model (H1)   -1243729.432
##                                                       
##   Akaike (AIC)                             2496670.965
##   Bayesian (BIC)                           2496932.428
##   Sample-size adjusted Bayesian (SABIC)    2496843.443
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.053
##   90 Percent confidence interval - lower         0.053
##   90 Percent confidence interval - upper         0.054
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.046
## 
## 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
##   WellBeing =~                                                          
##     Happy             0.658       NA                      0.658    0.658
##     LifeSat           0.552       NA                      0.552    0.552
##     Health           -0.374       NA                     -0.374   -0.374
##   Trust =~                                                              
##     Trust1            0.343       NA                      0.343    0.343
##     Trust2            0.448       NA                      0.448    0.448
##     Trust3            0.652       NA                      0.652    0.652
##   Religion =~                                                           
##     Rel1              0.814       NA                      0.814    0.814
##     Rel2             -0.889       NA                     -0.889   -0.889
##     Rel3             -0.550       NA                     -0.550   -0.550
##   Freedom =~                                                            
##     Freedom1         27.547       NA                     27.547   27.533
##     Freedom2          0.005       NA                      0.005    0.005
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   WellBeing ~~                                                          
##     Trust             0.278       NA                      0.278    0.278
##     Religion         -0.080       NA                     -0.080   -0.080
##     Freedom          -0.005       NA                     -0.005   -0.005
##   Trust ~~                                                              
##     Religion          0.160       NA                      0.160    0.160
##     Freedom          -0.000       NA                     -0.000   -0.000
##   Religion ~~                                                           
##     Freedom          -0.001       NA                     -0.001   -0.001
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Happy             0.567       NA                      0.567    0.567
##    .LifeSat           0.695       NA                      0.695    0.695
##    .Health            0.860       NA                      0.860    0.860
##    .Trust1            0.882       NA                      0.882    0.882
##    .Trust2            0.799       NA                      0.799    0.799
##    .Trust3            0.575       NA                      0.575    0.575
##    .Rel1              0.337       NA                      0.337    0.337
##    .Rel2              0.210       NA                      0.210    0.210
##    .Rel3              0.698       NA                      0.698    0.698
##    .Freedom1       -757.817       NA                   -757.817 -757.058
##    .Freedom2          1.000       NA                      1.000    1.000
##     WellBeing         1.000                               1.000    1.000
##     Trust             1.000                               1.000    1.000
##     Religion          1.000                               1.000    1.000
##     Freedom           1.000                               1.000    1.000
semPaths(
  fit_cfa,
  what = "path",
  whatLabels = "std",
  style = "ram",
  layout = "tree",
  rotation = 2,
  sizeMan = 6,
  sizeLat = 7
)

data.frame(
  CFI = fitMeasures(fit_cfa, "cfi"),
  RMSEA = fitMeasures(fit_cfa, "rmsea"),
  SRMR = fitMeasures(fit_cfa, "srmr"),
  TLI = fitMeasures(fit_cfa, "tli")
)
##           CFI      RMSEA       SRMR     TLI
## cfi 0.9314688 0.05346324 0.04594048 0.90081
hitung_CR <- function(fit) {
  std <- standardizedSolution(fit)
  lambda <- std$est[std$op == "=~"]
  theta <- 1 - lambda^2
  sum(lambda)^2 / (sum(lambda)^2 + sum(theta))
}

hitung_CR(fit_cfa)
## Warning: lavaan->lav_model_vcov():  
##    Could not compute standard errors! The information matrix could not be 
##    inverted. This may be a symptom that the model is not identified.
## [1] 8.374382
model_sem <- '
WellBeing =~ Happy + LifeSat + Health
Trust =~ Trust1 + Trust2 + Trust3
Religion =~ Rel1 + Rel2 + Rel3
Freedom =~ Freedom1 + Freedom2

WellBeing ~ Trust + Religion + Freedom
'

fit_sem <- sem(model_sem, data = data_z, std.lv = TRUE)
## Warning: lavaan->lav_lavaan_step11_estoptim():  
##    the optimizer warns that a solution has NOT been found!
summary(fit_sem, fit.measures = TRUE, standardized = TRUE)
## Warning: lavaan->lav_object_summary():  
##    fit measures not available if model did not converge
## lavaan 0.6-21 did NOT end normally after 8876 iterations
## ** WARNING ** Estimates below are most likely unreliable
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
## 
##   Number of observations                         83948
## 
## 
## 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
##   WellBeing =~                                                          
##     Happy             0.627       NA                      0.658    0.658
##     LifeSat           0.526       NA                      0.552    0.552
##     Health           -0.356       NA                     -0.374   -0.374
##   Trust =~                                                              
##     Trust1            0.343       NA                      0.343    0.343
##     Trust2            0.448       NA                      0.448    0.448
##     Trust3            0.652       NA                      0.652    0.652
##   Religion =~                                                           
##     Rel1             -0.814       NA                     -0.814   -0.814
##     Rel2              0.889       NA                      0.889    0.889
##     Rel3              0.550       NA                      0.550    0.550
##   Freedom =~                                                            
##     Freedom1         29.792       NA                     29.792   29.777
##     Freedom2          0.004       NA                      0.004    0.004
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   WellBeing ~                                                           
##     Trust             0.313       NA                      0.298    0.298
##     Religion          0.134       NA                      0.128    0.128
##     Freedom          -0.005       NA                     -0.004   -0.004
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Trust ~~                                                              
##     Religion         -0.160       NA                     -0.160   -0.160
##     Freedom          -0.000       NA                     -0.000   -0.000
##   Religion ~~                                                           
##     Freedom           0.001       NA                      0.001    0.001
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Happy             0.567       NA                      0.567    0.567
##    .LifeSat           0.695       NA                      0.695    0.695
##    .Health            0.860       NA                      0.860    0.860
##    .Trust1            0.882       NA                      0.882    0.882
##    .Trust2            0.799       NA                      0.799    0.799
##    .Trust3            0.575       NA                      0.575    0.575
##    .Rel1              0.337       NA                      0.337    0.337
##    .Rel2              0.210       NA                      0.210    0.210
##    .Rel3              0.698       NA                      0.698    0.698
##    .Freedom1       -886.573       NA                   -886.573 -885.691
##    .Freedom2          1.000       NA                      1.000    1.000
##    .WellBeing         1.000                               0.907    0.907
##     Trust             1.000                               1.000    1.000
##     Religion          1.000                               1.000    1.000
##     Freedom           1.000                               1.000    1.000
semPaths(
  fit_sem,
  what = "path",
  whatLabels = "std",
  style = "ram",
  layout = "tree",
  rotation = 2,
  sizeMan = 7,
  sizeLat = 7
)