O Pacote lavan (latent variable analysis)

        load("~/Dropbox/Congressos/2015 IBAP SP/ibap.RData")
        # install.packages("lavaan")
        library(lavaan)
## This is lavaan 0.5-18
## lavaan is BETA software! Please report any bugs.
        library(psych)
        names(bd)
##   [1] "id"             "CD_ALUNO"       "NM_ALUNO"       "NM_ALUNO3"     
##   [5] "age_i"          "age_c"          "age_i2"         "Sexo"          
##   [9] "Sexo_G"         "serie"          "correct_grade2" "CD_ESCOL"      
##  [13] "CD_TURNO"       "NU_SEQUE"       "CD_ETAPA"       "ORDEM_CA"      
##  [17] "CD_CADER"       "NU_FCA"         "NU_LISTA"       "NM_ESCOL"      
##  [21] "CD_REDE_"       "DC_REDE_"       "CD_ENSIN"       "DC_ENSIN"      
##  [25] "DC_TURNO"       "NM_ALUNO2"      "DC_CADER"       "T1_01A1"       
##  [29] "T1_02A1"        "T1_03A1"        "T1_04A1"        "T1_05A1"       
##  [33] "T1_06A1"        "T1_07A1"        "T1_08A1"        "T1_09A1"       
##  [37] "T1_10A1"        "T1_11A1"        "T1_12A1"        "T1_13A1"       
##  [41] "T1_14N1"        "T1_15N1"        "T1_16N1"        "T1_17N1"       
##  [45] "T1_18N1"        "T1_19N1"        "T1_20N1"        "T1_21N1"       
##  [49] "T1_22N1"        "T1_23N1"        "T1_24N1"        "T1_25N1"       
##  [53] "T1_26O1"        "T1_27O1"        "T1_28O1"        "T1_29O1"       
##  [57] "T1_30O1"        "T1_31O1"        "T1_32O1"        "T1_33O1"       
##  [61] "T1_34O1"        "T1_35O1"        "T1_36O1"        "T1_37O1"       
##  [65] "T1_38O1"        "T1_39E1"        "T1_40E1"        "T1_41E1"       
##  [69] "T1_42E1"        "T1_43E1"        "T1_44E1"        "T1_45E1"       
##  [73] "T1_46E1"        "T1_47E1"        "T1_48E1"        "T1_49E1"       
##  [77] "T1_50E1"        "T1_51E1"        "T1_52E1"        "T1_53C0"       
##  [81] "T1_54C1"        "T1_55C1"        "T1_56C1"        "T1_57C1"       
##  [85] "T1_58C1"        "T1_59C1"        "T1_60C0"        "T1_61C1"       
##  [89] "T1_62C1"        "T1_63C0"        "T1_64C1"        "T1_65C1"       
##  [93] "T5_01Ac1"       "T5_02Ac1"       "T5_03Ac1"       "T5_04Ac1"      
##  [97] "T5_05Ac1"       "T5_06Ac1"       "T5_07Ac1"       "T5_08Ac1"      
## [101] "T5_09Sc1"       "T5_10Sc1"       "T5_11Sc1"       "T5_12Sc1"      
## [105] "T5_13Sc1"       "T5_14Sc1"       "T5_15Sc1"       "T5_16Sc1"      
## [109] "T5_17Em1"       "T5_18Em1"       "T5_19Em1"       "T5_20Em1"      
## [113] "T5_21Em1"       "T5_22Em1"       "T5_23Em1"       "T5_24Em1"      
## [117] "T6_01SE1"       "T6_02SE1"       "T6_03SE0"       "T6_04SE1"      
## [121] "T6_05SE0"       "T6_06SE1"       "T6_07SE1"       "T6_08SE0"      
## [125] "T6_09SE0"       "T6_10SE0"       "T8_01Gr0"       "T8_02Gr1"      
## [129] "T8_03Gr0"       "T8_04Gr1"       "T8_05Gr0"       "T8_06Gr0"      
## [133] "T8_07Gr1"       "T8_08Gr1"       "T2_01E1"        "T2_02A0"       
## [137] "T2_03C1"        "T2_04N0"        "T2_05O1"        "T2_06E0"       
## [141] "T2_07A1"        "T2_08C0"        "T2_09N1"        "T2_10O1"       
## [145] "T2_11E1"        "T2_12A0"        "T2_13C1"        "T2_14N0"       
## [149] "T2_15O1"        "T2_16E1"        "T2_17A1"        "T2_18C0"       
## [153] "T2_19N0"        "T2_20O1"        "T2_21E0"        "T2_22A1"       
## [157] "T2_23C0"        "T2_24N1"        "T2_25O1"        "T2_26E1"       
## [161] "T2_27A0"        "T2_28C1"        "T2_29N0"        "T2_30O1"       
## [165] "T2_31E0"        "T2_32A1"        "T2_33C1"        "T2_34N1"       
## [169] "T2_35O0"        "T2_36E1"        "T2_37A0"        "T2_38C1"       
## [173] "T2_39N0"        "T2_40O1"        "T2_41O0"        "T2_42A1"       
## [177] "T2_43C0"        "T2_44O1"        "T7_01SE1"       "T7_02SE0"      
## [181] "T7_03SE1"       "T7_04SE0"       "T7_05SE1"       "T7_06SE0"      
## [185] "T7_07SE1"       "T7_08SE0"       "T7_09SE1"       "T7_10SE0"      
## [189] "T7_11SE1"       "T7_12SE0"       "T3_01PS1"       "T3_02HA1"      
## [193] "T3_03ES1"       "T3_04PS1"       "T3_05CP1"       "T3_06PP1"      
## [197] "T3_07CP0"       "T3_08ES1"       "T3_09PS1"       "T3_10HA1"      
## [201] "T3_11PP0"       "T3_12CP1"       "T3_13ES1"       "T3_14PP0"      
## [205] "T3_15HA1"       "T3_16ES1"       "T3_17PS1"       "T3_18CP1"      
## [209] "T3_19PP1"       "T3_20PS1"       "T3_21HA0"       "T3_22CP1"      
## [213] "T3_23PP1"       "T3_24ES1"       "T3_25HA0"       "T4_01LC1"      
## [217] "T4_02LC1"       "T4_03LC1"       "T4_04LC0"       "T4_05LC1"      
## [221] "T4_06LC1"       "T4_07LC1"       "T4_08LC1"       "T4_09LC1"      
## [225] "T4_10LC1"       "T4_11LC1"       "T4_12LC1"       "T4_13LC0"      
## [229] "T4_14LC1"       "T4_15LC1"       "T4_16LC1"       "T4_17LC1"      
## [233] "T4_18LC1"       "T4_19LC1"       "T4_20LC1"       "T4_21LC1"      
## [237] "filter__"       "grupo"          "t1_mis"         "t5_mis"        
## [241] "t6_mis"         "t8_mis"         "t2_mis"         "t7_mis"        
## [245] "t3_mis"         "t4_mis"         "missings"       "t1_bfc"        
## [249] "t2_BFI"         "t3_sdq"         "t4_locus"       "t5_auto"       
## [253] "t6_rosemb"      "t7_core"        "t8_grit"        "testes"        
## [257] "N_BREAK"        "Agree1"         "Consc1"         "Extra1"        
## [261] "Neuro1"         "Open1"          "Agree2"         "Consc2"        
## [265] "Extra2"         "Neuro2"         "Open2"          "CndProb"       
## [269] "EmoSym"         "HypAc"          "PeerProb"       "ProSoc"        
## [273] "Locus"          "SlfAcd"         "SlfEmo"         "SlfSoc"        
## [277] "SE_rosem"       "SE_core"        "Grit"           "SE"            
## [281] "CD_ESCOLA"      "CD_TURMA"       "NM_TURMA"       "NM_ESCOLA"     
## [285] "DC_TURNO_TURMA" "RF_000_001"     "final_filter"   "miss_T2_A"     
## [289] "miss_T2_C"      "miss_T2_E"      "miss_T2_N"      "miss_T2_O"     
## [293] "bfiave"         "bfistd"         "zT2_01E1"       "zT2_02A0"      
## [297] "zT2_03C1"       "zT2_04N0"       "zT2_05O1"       "zT2_06E0"      
## [301] "zT2_07A1"       "zT2_08C0"       "zT2_09N1"       "zT2_10O1"      
## [305] "zT2_11E1"       "zT2_12A0"       "zT2_13C1"       "zT2_14N0"      
## [309] "zT2_15O1"       "zT2_16E1"       "zT2_17A1"       "zT2_18C0"      
## [313] "zT2_19N0"       "zT2_20O1"       "zT2_21E0"       "zT2_22A1"      
## [317] "zT2_23C0"       "zT2_24N1"       "zT2_25O1"       "zT2_26E1"      
## [321] "zT2_27A0"       "zT2_28C1"       "zT2_29N0"       "zT2_30O1"      
## [325] "zT2_31E0"       "zT2_32A1"       "zT2_33C1"       "zT2_34N1"      
## [329] "zT2_35O0"       "zT2_36E1"       "zT2_37A0"       "zT2_38C1"      
## [333] "zT2_39N0"       "zT2_40O1"       "zT2_41O0"       "zT2_42A1"      
## [337] "zT2_43C0"       "zT2_44O1"       "zBFI_A"         "zBFI_C"        
## [341] "zBFI_E"         "zBFI_N"         "zBFI_O"         "zBFI_Ntest"    
## [345] "BFI_A"          "BFI_C"          "BFI_E"          "BFI_N"         
## [349] "BFI_O"          "T1.A.1"         "T1.A.2"         "T1.A.3"        
## [353] "T1.C.1"         "T1.C.2"         "T1.C.3"         "T1.E.1"        
## [357] "T1.E.2"         "T1.E.3"         "T1.N.1"         "T1.N.2"        
## [361] "T1.N.3"         "T1.O.1"         "T1.O.2"         "T1.O.3"        
## [365] "T2.A.1"         "T2.A.2"         "T2.A.3"         "T2.C.1"        
## [369] "T2.C.2"         "T2.C.3"         "T2.E.1"         "T2.E.2"        
## [373] "T2.E.3"         "T2.N.1"         "T2.N.2"         "T2.N.3"        
## [377] "T2.O.1"         "T2.O.2"         "T2.O.3"         "T3.CP.1"       
## [381] "T3.CP.2"        "T3.ES.1"        "T3.ES.2"        "T3.HA.1"       
## [385] "T3.HA.2"        "T3.PP.1"        "T3.PS.1"        "T3.PS.2"       
## [389] "T4.LC.1"        "T4.LC.2"        "T4.LC.3"        "T5.Ac.1"       
## [393] "T5.Ac.2"        "T5.Ac.3"        "T5.Em.1"        "T5.Em.2"       
## [397] "T5.Em.3"        "T5.Sc.1"        "T5.Sc.2"        "T5.Sc.3"       
## [401] "T7.SE_gsc.1"    "T7.SE_lc.2"     "T7.SE_N.3"      "T7.SE_se.4"    
## [405] "T8.Gr.1"        "T8.Gr.2"        "T8.Gr.3"
        # BFI
        describe(bd[ , 365:379])
##        vars   n mean   sd median trimmed  mad  min  max range  skew
## T2.A.1    1 941 3.49 0.68   3.50    3.54 0.74 0.50 4.67  4.17 -0.63
## T2.A.2    2 942 3.39 0.75   3.33    3.42 0.99 1.00 5.00  4.00 -0.32
## T2.A.3    3 937 3.33 0.87   3.50    3.39 0.74 0.00 5.00  5.00 -0.64
## T2.C.1    4 942 2.98 0.76   3.00    2.99 0.74 0.75 4.75  4.00 -0.03
## T2.C.2    5 939 2.49 0.87   2.50    2.50 0.74 0.00 4.50  4.50 -0.07
## T2.C.3    6 941 3.28 0.78   3.33    3.30 0.99 0.00 5.00  5.00 -0.33
## T2.E.1    7 940 2.69 0.86   2.67    2.70 0.99 0.50 5.00  4.50 -0.07
## T2.E.2    8 941 2.88 0.86   3.00    2.89 0.99 0.00 5.00  5.00 -0.14
## T2.E.3    9 940 3.26 0.97   3.50    3.32 0.74 0.00 5.00  5.00 -0.45
## T2.N.1   10 941 2.84 0.87   3.00    2.88 0.99 0.33 5.00  4.67 -0.37
## T2.N.2   11 940 2.48 0.79   2.67    2.49 0.99 0.33 4.50  4.17 -0.24
## T2.N.3   12 940 3.22 0.84   3.50    3.26 0.74 0.50 5.00  4.50 -0.53
## T2.O.1   13 941 3.44 0.89   3.33    3.46 0.99 1.00 5.00  4.00 -0.11
## T2.O.2   14 934 2.87 0.82   3.00    2.87 0.99 1.00 5.00  4.00  0.06
## T2.O.3   15 940 3.19 0.84   3.00    3.19 0.99 1.00 5.00  4.00  0.07
##        kurtosis   se
## T2.A.1     0.35 0.02
## T2.A.2    -0.25 0.02
## T2.A.3     0.32 0.03
## T2.C.1    -0.24 0.02
## T2.C.2    -0.35 0.03
## T2.C.3    -0.05 0.03
## T2.E.1    -0.23 0.03
## T2.E.2    -0.31 0.03
## T2.E.3    -0.34 0.03
## T2.N.1    -0.15 0.03
## T2.N.2    -0.08 0.03
## T2.N.3     0.10 0.03
## T2.O.1    -0.63 0.03
## T2.O.2    -0.11 0.03
## T2.O.3    -0.36 0.03
        table(bd$serie)
## 
##    1    2    3    4    5 
## 1080 1080 1080  700  700

Especifique o modelo

        m <-   'A =~ T2.A.1+T2.A.2+T2.A.3
                C =~ T2.C.1+T2.C.2+T2.C.3
                E =~ T2.E.1+T2.E.2+T2.E.3
                N =~ T2.N.1+T2.N.2+T2.N.3
                O =~ T2.O.1+T2.O.2+T2.O.3'

Rode as análises com as funções cfa ou sem

         fit <- cfa(m, data = bd )

Examine os resultados

        summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-18) converged normally after  44 iterations
## 
##                                                   Used       Total
##   Number of observations                           930        4640
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              498.661
##   Degrees of freedom                                80
##   P-value (Chi-square)                           0.000
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic             3323.969
##   Degrees of freedom                               105
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    0.870
##   Tucker-Lewis Index (TLI)                       0.829
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)             -15640.706
##   Loglikelihood unrestricted model (H1)     -15391.376
## 
##   Number of free parameters                         40
##   Akaike (AIC)                               31361.412
##   Bayesian (BIC)                             31554.819
##   Sample-size adjusted Bayesian (BIC)        31427.783
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075
##   90 Percent Confidence Interval          0.069  0.081
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.074
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   A =~
##     T2.A.1            1.000                               0.409    0.611
##     T2.A.2            1.147    0.093   12.311    0.000    0.469    0.626
##     T2.A.3            1.166    0.101   11.583    0.000    0.477    0.553
##   C =~
##     T2.C.1            1.000                               0.582    0.767
##     T2.C.2            0.956    0.056   16.929    0.000    0.556    0.644
##     T2.C.3            1.001    0.054   18.606    0.000    0.582    0.755
##   E =~
##     T2.E.1            1.000                               0.531    0.623
##     T2.E.2            1.206    0.113   10.663    0.000    0.640    0.750
##     T2.E.3            0.818    0.081   10.054    0.000    0.435    0.452
##   N =~
##     T2.N.1            1.000                               0.700    0.816
##     T2.N.2            0.576    0.052   11.028    0.000    0.403    0.516
##     T2.N.3            0.570    0.054   10.563    0.000    0.399    0.478
##   O =~
##     T2.O.1            1.000                               0.586    0.662
##     T2.O.2            0.736    0.056   13.051    0.000    0.432    0.530
##     T2.O.3            1.167    0.076   15.360    0.000    0.685    0.809
## 
## Covariances:
##   A ~~
##     C                 0.127    0.014    9.225    0.000    0.535    0.535
##     E                 0.036    0.011    3.196    0.001    0.166    0.166
##     N                 0.162    0.017    9.538    0.000    0.566    0.566
##     O                 0.083    0.013    6.384    0.000    0.344    0.344
##   C ~~
##     E                 0.027    0.014    1.912    0.056    0.087    0.087
##     N                 0.136    0.019    7.172    0.000    0.333    0.333
##     O                 0.164    0.018    9.183    0.000    0.482    0.482
##   E ~~
##     N                -0.019    0.017   -1.098    0.272   -0.051   -0.051
##     O                 0.120    0.017    6.928    0.000    0.387    0.387
##   N ~~
##     O                -0.007    0.018   -0.396    0.692   -0.018   -0.018
## 
## Variances:
##     T2.A.1            0.281    0.018                      0.281    0.627
##     T2.A.2            0.343    0.022                      0.343    0.609
##     T2.A.3            0.518    0.030                      0.518    0.695
##     T2.C.1            0.236    0.018                      0.236    0.411
##     T2.C.2            0.436    0.025                      0.436    0.585
##     T2.C.3            0.256    0.019                      0.256    0.430
##     T2.E.1            0.445    0.032                      0.445    0.612
##     T2.E.2            0.320    0.038                      0.320    0.438
##     T2.E.3            0.736    0.039                      0.736    0.796
##     T2.N.1            0.246    0.038                      0.246    0.334
##     T2.N.2            0.449    0.025                      0.449    0.734
##     T2.N.3            0.537    0.028                      0.537    0.772
##     T2.O.1            0.441    0.028                      0.441    0.562
##     T2.O.2            0.477    0.025                      0.477    0.719
##     T2.O.3            0.248    0.027                      0.248    0.346
##     A                 0.168    0.020                      1.000    1.000
##     C                 0.338    0.028                      1.000    1.000
##     E                 0.282    0.036                      1.000    1.000
##     N                 0.490    0.048                      1.000    1.000
##     O                 0.344    0.036                      1.000    1.000

Examine índices de modificação

        mi <- modindices(fit)
        str(mi)
## Classes 'lavaan.data.frame' and 'data.frame':    210 obs. of  8 variables:
##  $ lhs     : chr  "A" "A" "A" "C" ...
##  $ op      : chr  "=~" "=~" "=~" "=~" ...
##  $ rhs     : chr  "T2.A.1" "T2.A.2" "T2.A.3" "T2.C.1" ...
##  $ mi      : num  NA 1.59e-09 4.89e-09 NA 2.79e-09 ...
##  $ epc     : num  NA 2.36e-06 5.01e-06 NA -2.33e-06 ...
##  $ sepc.lv : num  NA 9.68e-07 2.05e-06 NA -1.36e-06 ...
##  $ sepc.all: num  NA 1.29e-06 2.37e-06 NA -1.57e-06 ...
##  $ sepc.nox: num  NA 1.29e-06 2.37e-06 NA -1.57e-06 ...
        class(mi)
## [1] "lavaan.data.frame" "data.frame"
        head(mi)
##   lhs op    rhs mi epc sepc.lv sepc.all sepc.nox
## 1   A =~ T2.A.1 NA  NA      NA       NA       NA
## 2   A =~ T2.A.2  0   0       0        0        0
## 3   A =~ T2.A.3  0   0       0        0        0
## 4   C =~ T2.C.1 NA  NA      NA       NA       NA
## 5   C =~ T2.C.2  0   0       0        0        0
## 6   C =~ T2.C.3  0   0       0        0        0
        mi[mi$mi>20 , ]
##       lhs   op    rhs     mi    epc sepc.lv sepc.all sepc.nox
## 1    <NA> <NA>   <NA>     NA     NA      NA       NA       NA
## 2    <NA> <NA>   <NA>     NA     NA      NA       NA       NA
## 3    <NA> <NA>   <NA>     NA     NA      NA       NA       NA
## 4    <NA> <NA>   <NA>     NA     NA      NA       NA       NA
## 5    <NA> <NA>   <NA>     NA     NA      NA       NA       NA
## 6       A   =~ T2.E.1 71.459 -0.667  -0.273   -0.320   -0.320
## 7       A   =~ T2.E.3 40.000  0.568   0.232    0.242    0.242
## 8       A   =~ T2.N.3 34.880  0.658   0.269    0.323    0.323
## 9       C   =~ T2.E.1 69.167 -0.425  -0.247   -0.290   -0.290
## 10      C   =~ T2.E.3 23.748  0.284   0.165    0.172    0.172
## 11      C   =~ T2.N.3 27.513  0.292   0.170    0.203    0.203
## 12      E   =~ T2.C.3 29.461  0.261   0.139    0.180    0.180
## 13      E   =~ T2.N.1 58.553 -0.564  -0.300   -0.349   -0.349
## 14      E   =~ T2.N.3 45.069  0.387   0.205    0.246    0.246
## 15      N   =~ T2.A.2 28.802 -0.321  -0.225   -0.300   -0.300
## 16      N   =~ T2.C.2 50.385  0.315   0.220    0.255    0.255
## 17      N   =~ T2.E.1 29.354 -0.233  -0.163   -0.191   -0.191
## 18      N   =~ T2.E.3 34.764  0.292   0.204    0.213    0.213
## 19      O   =~ T2.C.2 59.108 -0.450  -0.264   -0.306   -0.306
## 20      O   =~ T2.C.3 30.155  0.289   0.169    0.220    0.220
## 21      O   =~ T2.N.3 35.584  0.295   0.173    0.207    0.207
## 22 T2.A.1   ~~ T2.E.1 22.237 -0.068  -0.068   -0.119   -0.119
## 23 T2.A.3   ~~ T2.E.3 29.945  0.124   0.124    0.150    0.150
## 24 T2.C.2   ~~ T2.E.3 24.321  0.103   0.103    0.124    0.124

SEM quanto BIG 5 explica Grit?

# Especifica o modelo
        m <-   'A =~ T2.A.1+T2.A.2+T2.A.3
                C =~ T2.C.1+T2.C.2+T2.C.3
                E =~ T2.E.1+T2.E.2+T2.E.3
                N =~ T2.N.1+T2.N.2+T2.N.3
                O =~ T2.O.1+T2.O.2+T2.O.3
                grit =~ T8.Gr.1 + T8.Gr.2 + T8.Gr.3
                grit ~ A + C + E + N + O '
# Roda as análises
                fit <- cfa(m, data = bd)
                summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-18) converged normally after  60 iterations
## 
##                                                   Used       Total
##   Number of observations                           227        4640
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              294.339
##   Degrees of freedom                               120
##   P-value (Chi-square)                           0.000
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic             1213.569
##   Degrees of freedom                               153
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    0.836
##   Tucker-Lewis Index (TLI)                       0.790
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -4527.009
##   Loglikelihood unrestricted model (H1)      -4379.839
## 
##   Number of free parameters                         51
##   Akaike (AIC)                                9156.018
##   Bayesian (BIC)                              9330.690
##   Sample-size adjusted Bayesian (BIC)         9169.057
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.080
##   90 Percent Confidence Interval          0.068  0.092
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.094
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   A =~
##     T2.A.1            1.000                               0.343    0.560
##     T2.A.2            1.110    0.236    4.710    0.000    0.381    0.494
##     T2.A.3            1.445    0.287    5.031    0.000    0.496    0.574
##   C =~
##     T2.C.1            1.000                               0.598    0.759
##     T2.C.2            0.986    0.105    9.385    0.000    0.589    0.664
##     T2.C.3            1.003    0.093   10.787    0.000    0.600    0.768
##   E =~
##     T2.E.1            1.000                               0.708    0.879
##     T2.E.2            0.568    0.140    4.069    0.000    0.402    0.488
##     T2.E.3            0.340    0.117    2.903    0.004    0.241    0.253
##   N =~
##     T2.N.1            1.000                               0.724    0.814
##     T2.N.2            0.662    0.102    6.506    0.000    0.479    0.599
##     T2.N.3            0.574    0.101    5.693    0.000    0.416    0.482
##   O =~
##     T2.O.1            1.000                               0.683    0.745
##     T2.O.2            0.606    0.088    6.876    0.000    0.414    0.526
##     T2.O.3            1.043    0.117    8.929    0.000    0.713    0.795
##   grit =~
##     T8.Gr.1           1.000                               0.553    0.718
##     T8.Gr.2           1.171    0.131    8.958    0.000    0.647    0.710
##     T8.Gr.3           0.569    0.098    5.818    0.000    0.314    0.439
## 
## Regressions:
##   grit ~
##     A                 0.099    0.227    0.436    0.663    0.061    0.061
##     C                 0.932    0.133    7.033    0.000    1.008    1.008
##     E                 0.022    0.074    0.300    0.764    0.029    0.029
##     N                -0.010    0.097   -0.099    0.921   -0.013   -0.013
##     O                -0.266    0.107   -2.494    0.013   -0.329   -0.329
## 
## Covariances:
##   A ~~
##     C                 0.086    0.024    3.602    0.000    0.419    0.419
##     E                -0.037    0.025   -1.480    0.139   -0.151   -0.151
##     N                 0.145    0.032    4.460    0.000    0.583    0.583
##     O                 0.038    0.024    1.551    0.121    0.161    0.161
##   C ~~
##     E                -0.071    0.036   -1.950    0.051   -0.167   -0.167
##     N                 0.100    0.039    2.573    0.010    0.232    0.232
##     O                 0.180    0.040    4.511    0.000    0.441    0.441
##   E ~~
##     N                -0.101    0.045   -2.227    0.026   -0.197   -0.197
##     O                 0.176    0.045    3.956    0.000    0.364    0.364
##   N ~~
##     O                -0.101    0.045   -2.260    0.024   -0.204   -0.204
## 
## Variances:
##     T2.A.1            0.257    0.033                      0.257    0.686
##     T2.A.2            0.450    0.052                      0.450    0.756
##     T2.A.3            0.500    0.065                      0.500    0.671
##     T2.C.1            0.263    0.033                      0.263    0.424
##     T2.C.2            0.439    0.048                      0.439    0.559
##     T2.C.3            0.250    0.032                      0.250    0.410
##     T2.E.1            0.147    0.111                      0.147    0.227
##     T2.E.2            0.516    0.060                      0.516    0.762
##     T2.E.3            0.847    0.081                      0.847    0.936
##     T2.N.1            0.267    0.071                      0.267    0.337
##     T2.N.2            0.411    0.050                      0.411    0.641
##     T2.N.3            0.571    0.060                      0.571    0.768
##     T2.O.1            0.375    0.056                      0.375    0.445
##     T2.O.2            0.450    0.047                      0.450    0.724
##     T2.O.3            0.296    0.054                      0.296    0.368
##     T8.Gr.1           0.286    0.038                      0.286    0.484
##     T8.Gr.2           0.412    0.053                      0.412    0.496
##     T8.Gr.3           0.414    0.041                      0.414    0.808
##     A                 0.118    0.034                      1.000    1.000
##     C                 0.357    0.057                      1.000    1.000
##     E                 0.501    0.125                      1.000    1.000
##     N                 0.525    0.097                      1.000    1.000
##     O                 0.467    0.083                      1.000    1.000
##     grit              0.044    0.029                      0.144    0.144
# R2 (quanto cada variável endógena é explicada)
                lavInspect(fit, "rsquare") 
##  T2.A.1  T2.A.2  T2.A.3  T2.C.1  T2.C.2  T2.C.3  T2.E.1  T2.E.2  T2.E.3 
##   0.314   0.244   0.329   0.576   0.441   0.590   0.773   0.238   0.064 
##  T2.N.1  T2.N.2  T2.N.3  T2.O.1  T2.O.2  T2.O.3 T8.Gr.1 T8.Gr.2 T8.Gr.3 
##   0.663   0.359   0.232   0.555   0.276   0.632   0.516   0.504   0.192 
##    grit 
##   0.856

SEM quanto BIG 5 explica do CORE Self Esteem?

# Especifica o modelo
        m <-   'A =~ T2.A.1+T2.A.2+T2.A.3
                C =~ T2.C.1+T2.C.2+T2.C.3
                E =~ T2.E.1+T2.E.2+T2.E.3
                N =~ T2.N.1+T2.N.2+T2.N.3
                O =~ T2.O.1+T2.O.2+T2.O.3
                core =~  T7.SE_gsc.1 + T7.SE_lc.2+ T7.SE_N.3    
                core ~ A + C + E + N + O '
# Roda as análises
                fit <- cfa(m, data = bd)
                summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-18) converged normally after  70 iterations
## 
##                                                   Used       Total
##   Number of observations                           135        4640
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              280.622
##   Degrees of freedom                               120
##   P-value (Chi-square)                           0.000
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic              862.918
##   Degrees of freedom                               153
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    0.774
##   Tucker-Lewis Index (TLI)                       0.712
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2507.361
##   Loglikelihood unrestricted model (H1)      -2367.050
## 
##   Number of free parameters                         51
##   Akaike (AIC)                                5116.722
##   Bayesian (BIC)                              5264.891
##   Sample-size adjusted Bayesian (BIC)         5103.560
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.100
##   90 Percent Confidence Interval          0.084  0.115
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.099
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   A =~
##     T2.A.1            1.000                               0.375    0.610
##     T2.A.2            1.180    0.241    4.895    0.000    0.442    0.636
##     T2.A.3            1.693    0.340    4.985    0.000    0.634    0.677
##   C =~
##     T2.C.1            1.000                               0.506    0.699
##     T2.C.2            1.299    0.175    7.437    0.000    0.657    0.760
##     T2.C.3            1.160    0.151    7.669    0.000    0.587    0.805
##   E =~
##     T2.E.1            1.000                               0.729    0.832
##     T2.E.2            0.847    0.133    6.365    0.000    0.618    0.709
##     T2.E.3            0.714    0.122    5.848    0.000    0.520    0.601
##   N =~
##     T2.N.1            1.000                               0.410    0.491
##     T2.N.2            1.226    0.281    4.363    0.000    0.503    0.636
##     T2.N.3            1.369    0.304    4.498    0.000    0.562    0.717
##   O =~
##     T2.O.1            1.000                               0.511    0.657
##     T2.O.2            0.617    0.133    4.632    0.000    0.315    0.472
##     T2.O.3            1.217    0.240    5.076    0.000    0.622    0.866
##   core =~
##     T7.SE_gsc.1       1.000                               0.399    0.625
##     T7.SE_lc.2        0.787    0.171    4.600    0.000    0.314    0.458
##     T7.SE_N.3         0.917    0.200    4.589    0.000    0.366    0.457
## 
## Regressions:
##   core ~
##     A                -0.205    0.192   -1.068    0.286   -0.192   -0.192
##     C                 0.578    0.123    4.717    0.000    0.732    0.732
##     E                 0.101    0.065    1.550    0.121    0.183    0.183
##     N                 0.624    0.202    3.093    0.002    0.641    0.641
##     O                -0.069    0.092   -0.751    0.453   -0.089   -0.089
## 
## Covariances:
##   A ~~
##     C                 0.078    0.026    2.985    0.003    0.410    0.410
##     E                 0.024    0.032    0.737    0.461    0.087    0.087
##     N                 0.086    0.028    3.080    0.002    0.561    0.561
##     O                 0.029    0.023    1.250    0.211    0.151    0.151
##   C ~~
##     E                 0.076    0.041    1.854    0.064    0.206    0.206
##     N                 0.053    0.027    1.982    0.047    0.256    0.256
##     O                 0.074    0.031    2.363    0.018    0.286    0.286
##   E ~~
##     N                 0.048    0.037    1.311    0.190    0.160    0.160
##     O                 0.115    0.045    2.538    0.011    0.310    0.310
##   N ~~
##     O                 0.008    0.025    0.314    0.753    0.037    0.037
## 
## Variances:
##     T2.A.1            0.237    0.038                      0.237    0.628
##     T2.A.2            0.288    0.049                      0.288    0.596
##     T2.A.3            0.474    0.089                      0.474    0.541
##     T2.C.1            0.267    0.041                      0.267    0.511
##     T2.C.2            0.315    0.055                      0.315    0.422
##     T2.C.3            0.186    0.037                      0.186    0.351
##     T2.E.1            0.236    0.075                      0.236    0.308
##     T2.E.2            0.376    0.068                      0.376    0.497
##     T2.E.3            0.478    0.069                      0.478    0.638
##     T2.N.1            0.529    0.073                      0.529    0.759
##     T2.N.2            0.373    0.061                      0.373    0.596
##     T2.N.3            0.299    0.061                      0.299    0.487
##     T2.O.1            0.344    0.062                      0.344    0.568
##     T2.O.2            0.346    0.046                      0.346    0.777
##     T2.O.3            0.128    0.068                      0.128    0.249
##     T7.SE_gsc.1       0.249    0.040                      0.249    0.610
##     T7.SE_lc.2        0.372    0.049                      0.372    0.790
##     T7.SE_N.3         0.507    0.066                      0.507    0.791
##     A                 0.140    0.044                      1.000    1.000
##     C                 0.256    0.060                      1.000    1.000
##     E                 0.531    0.112                      1.000    1.000
##     N                 0.168    0.065                      1.000    1.000
##     O                 0.261    0.076                      1.000    1.000
##     core             -0.008    0.027                     -0.052   -0.052
                lavInspect(fit, "rsquare") 
##      T2.A.1      T2.A.2      T2.A.3      T2.C.1      T2.C.2      T2.C.3 
##       0.372       0.404       0.459       0.489       0.578       0.649 
##      T2.E.1      T2.E.2      T2.E.3      T2.N.1      T2.N.2      T2.N.3 
##       0.692       0.503       0.362       0.241       0.404       0.513 
##      T2.O.1      T2.O.2      T2.O.3 T7.SE_gsc.1  T7.SE_lc.2   T7.SE_N.3 
##       0.432       0.223       0.751       0.390       0.210       0.209 
##        core 
##          NA

SEM quanto cada componente do CORE Self Esteem explica BIG 5 ?

# Especifica o modelo
        m <-   'A =~ T2.A.1+T2.A.2+T2.A.3
                C =~ T2.C.1+T2.C.2+T2.C.3
                E =~ T2.E.1+T2.E.2+T2.E.3
                N =~ T2.N.1+T2.N.2+T2.N.3
                O =~ T2.O.1+T2.O.2+T2.O.3
                A ~  T7.SE_gsc.1 + T7.SE_lc.2+ T7.SE_N.3    
                C  ~  T7.SE_gsc.1 + T7.SE_lc.2+ T7.SE_N.3
                E  ~  T7.SE_gsc.1 + T7.SE_lc.2+ T7.SE_N.3
                N  ~  T7.SE_gsc.1 + T7.SE_lc.2+ T7.SE_N.3
                O  ~  T7.SE_gsc.1 + T7.SE_lc.2+ T7.SE_N.3'
# Roda as análises
                fit <- cfa(m, data = bd)
                summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-18) converged normally after  62 iterations
## 
##                                                   Used       Total
##   Number of observations                           135        4640
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              224.821
##   Degrees of freedom                               110
##   P-value (Chi-square)                           0.000
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic              828.937
##   Degrees of freedom                               150
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    0.831
##   Tucker-Lewis Index (TLI)                       0.769
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2479.461
##   Loglikelihood unrestricted model (H1)      -2367.050
## 
##   Number of free parameters                         55
##   Akaike (AIC)                                5068.921
##   Bayesian (BIC)                              5228.711
##   Sample-size adjusted Bayesian (BIC)         5054.727
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.088
##   90 Percent Confidence Interval          0.071  0.104
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.086
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   A =~
##     T2.A.1            1.000                               0.377    0.613
##     T2.A.2            1.161    0.237    4.907    0.000    0.438    0.629
##     T2.A.3            1.691    0.336    5.028    0.000    0.637    0.680
##   C =~
##     T2.C.1            1.000                               0.504    0.696
##     T2.C.2            1.273    0.172    7.388    0.000    0.641    0.742
##     T2.C.3            1.190    0.151    7.866    0.000    0.599    0.823
##   E =~
##     T2.E.1            1.000                               0.732    0.835
##     T2.E.2            0.841    0.131    6.444    0.000    0.615    0.707
##     T2.E.3            0.709    0.121    5.886    0.000    0.519    0.600
##   N =~
##     T2.N.1            1.000                               0.418    0.501
##     T2.N.2            1.172    0.257    4.555    0.000    0.490    0.619
##     T2.N.3            1.354    0.280    4.829    0.000    0.566    0.722
##   O =~
##     T2.O.1            1.000                               0.568    0.731
##     T2.O.2            0.572    0.122    4.692    0.000    0.325    0.487
##     T2.O.3            0.985    0.171    5.754    0.000    0.560    0.780
## 
## Regressions:
##   A ~
##     T7.SE_gsc.1       0.164    0.065    2.538    0.011    0.435    0.278
##     T7.SE_lc.2       -0.023    0.061   -0.384    0.701   -0.062   -0.042
##     T7.SE_N.3         0.113    0.053    2.151    0.032    0.300    0.240
##   C ~
##     T7.SE_gsc.1       0.442    0.074    5.970    0.000    0.879    0.562
##     T7.SE_lc.2        0.215    0.065    3.324    0.001    0.427    0.293
##     T7.SE_N.3        -0.051    0.052   -0.989    0.323   -0.102   -0.081
##   E ~
##     T7.SE_gsc.1       0.132    0.112    1.179    0.238    0.180    0.115
##     T7.SE_lc.2        0.119    0.111    1.073    0.283    0.162    0.111
##     T7.SE_N.3         0.172    0.093    1.859    0.063    0.236    0.189
##   N ~
##     T7.SE_gsc.1       0.184    0.067    2.771    0.006    0.441    0.282
##     T7.SE_lc.2       -0.058    0.060   -0.971    0.332   -0.138   -0.095
##     T7.SE_N.3         0.322    0.072    4.480    0.000    0.770    0.616
##   O ~
##     T7.SE_gsc.1       0.225    0.091    2.465    0.014    0.397    0.254
##     T7.SE_lc.2        0.067    0.088    0.756    0.450    0.117    0.080
##     T7.SE_N.3        -0.183    0.076   -2.419    0.016   -0.322   -0.258
## 
## Covariances:
##   A ~~
##     C                 0.040    0.018    2.245    0.025    0.315    0.315
##     E                -0.005    0.029   -0.173    0.863   -0.021   -0.021
##     N                 0.051    0.019    2.630    0.009    0.483    0.483
##     O                 0.031    0.024    1.280    0.201    0.165    0.165
##   C ~~
##     E                 0.024    0.030    0.797    0.425    0.094    0.094
##     N                 0.008    0.016    0.477    0.634    0.069    0.069
##     O                 0.040    0.025    1.613    0.107    0.202    0.202
##   E ~~
##     N                -0.009    0.029   -0.313    0.754   -0.042   -0.042
##     O                 0.124    0.046    2.673    0.008    0.331    0.331
##   N ~~
##     O                 0.020    0.023    0.854    0.393    0.121    0.121
## 
## Variances:
##     T2.A.1            0.235    0.038                      0.235    0.624
##     T2.A.2            0.292    0.049                      0.292    0.604
##     T2.A.3            0.471    0.089                      0.471    0.537
##     T2.C.1            0.270    0.040                      0.270    0.515
##     T2.C.2            0.336    0.054                      0.336    0.450
##     T2.C.3            0.171    0.036                      0.171    0.323
##     T2.E.1            0.232    0.074                      0.232    0.302
##     T2.E.2            0.379    0.068                      0.379    0.500
##     T2.E.3            0.479    0.069                      0.479    0.640
##     T2.N.1            0.523    0.071                      0.523    0.749
##     T2.N.2            0.386    0.059                      0.386    0.616
##     T2.N.3            0.294    0.056                      0.294    0.478
##     T2.O.1            0.282    0.060                      0.282    0.466
##     T2.O.2            0.340    0.046                      0.340    0.763
##     T2.O.3            0.202    0.053                      0.202    0.392
##     A                 0.121    0.038                      0.853    0.853
##     C                 0.135    0.034                      0.533    0.533
##     E                 0.486    0.104                      0.907    0.907
##     N                 0.092    0.037                      0.526    0.526
##     O                 0.288    0.074                      0.891    0.891
                lavInspect(fit, "rsquare") 
## T2.A.1 T2.A.2 T2.A.3 T2.C.1 T2.C.2 T2.C.3 T2.E.1 T2.E.2 T2.E.3 T2.N.1 
##  0.376  0.396  0.463  0.485  0.550  0.677  0.698  0.500  0.360  0.251 
## T2.N.2 T2.N.3 T2.O.1 T2.O.2 T2.O.3      A      C      E      N      O 
##  0.384  0.522  0.534  0.237  0.608  0.147  0.467  0.093  0.474  0.109

Análise com variáveis categóricas

# Examina nomes das variáveis
        colnames(bpr_df)
##  [1] "ahv_1" "ahv_2" "ahv_3" "ahv_4" "ahv_5" "ahv_6" "ahv_7" "ahv_8"
##  [9] "ahv_9" "aha_1" "aha_2" "aha_3" "aha_4" "aha_5" "aha_6" "aha_7"
## [17] "aha_8" "aha_9" "ahe_1" "ahe_2" "ahe_3" "ahe_4" "ahe_5" "ahe_6"
## [25] "ahe_7" "ahe_8" "ahe_9"
        paste(colnames(bpr_df), collapse = "+")
## [1] "ahv_1+ahv_2+ahv_3+ahv_4+ahv_5+ahv_6+ahv_7+ahv_8+ahv_9+aha_1+aha_2+aha_3+aha_4+aha_5+aha_6+aha_7+aha_8+aha_9+ahe_1+ahe_2+ahe_3+ahe_4+ahe_5+ahe_6+ahe_7+ahe_8+ahe_9"
# Cria modelo usadno paste
        m <-  paste("g =~", paste(colnames(bpr_df), collapse = "+"), sep="")
        
# Executa a análise
        fit <- cfa(m, data = bpr_df, ordered = colnames(bpr_df))
        
# Examina os resultados
        summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-18) converged normally after  30 iterations
## 
##                                                   Used       Total
##   Number of observations                           952        3578
## 
##   Estimator                                       DWLS      Robust
##   Minimum Function Test Statistic              537.890     566.540
##   Degrees of freedom                               324         324
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.064
##   Shift parameter                                           61.203
##     for simple second-order correction (Mplus variant)
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic             2606.156    2032.940
##   Degrees of freedom                               351         351
##   P-value                                        0.000       0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    0.905       0.856
##   Tucker-Lewis Index (TLI)                       0.897       0.844
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.026       0.028
##   90 Percent Confidence Interval          0.022  0.030       0.024  0.032
##   P-value RMSEA <= 0.05                          1.000       1.000
## 
## Weighted Root Mean Square Residual:
## 
##   WRMR                                           1.193       1.193
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                           Robust.sem
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   g =~
##     ahv_1             1.000                               0.481    0.481
##     ahv_2             0.921    0.120    7.681    0.000    0.443    0.443
##     ahv_3             1.085    0.134    8.072    0.000    0.521    0.521
##     ahv_4             0.853    0.123    6.942    0.000    0.410    0.410
##     ahv_5             0.621    0.118    5.247    0.000    0.298    0.298
##     ahv_6             0.355    0.107    3.320    0.001    0.170    0.170
##     ahv_7             0.060    0.151    0.398    0.691    0.029    0.029
##     ahv_8            -0.051    0.150   -0.341    0.733   -0.025   -0.025
##     ahv_9             0.218    0.104    2.105    0.035    0.105    0.105
##     aha_1             1.229    0.144    8.523    0.000    0.590    0.590
##     aha_2             1.374    0.164    8.375    0.000    0.660    0.660
##     aha_3             1.294    0.162    7.969    0.000    0.622    0.622
##     aha_4             0.749    0.121    6.214    0.000    0.360    0.360
##     aha_5             0.566    0.112    5.038    0.000    0.272    0.272
##     aha_6             0.696    0.122    5.718    0.000    0.334    0.334
##     aha_7             1.375    0.157    8.778    0.000    0.661    0.661
##     aha_8             0.477    0.138    3.465    0.001    0.229    0.229
##     aha_9             0.071    0.140    0.511    0.610    0.034    0.034
##     ahe_1             0.504    0.110    4.569    0.000    0.242    0.242
##     ahe_2             0.343    0.101    3.406    0.001    0.165    0.165
##     ahe_3             0.306    0.115    2.657    0.008    0.147    0.147
##     ahe_4             0.671    0.115    5.837    0.000    0.322    0.322
##     ahe_5             0.689    0.126    5.481    0.000    0.331    0.331
##     ahe_6             0.530    0.118    4.493    0.000    0.255    0.255
##     ahe_7             0.682    0.120    5.678    0.000    0.328    0.328
##     ahe_8             0.364    0.130    2.800    0.005    0.175    0.175
##     ahe_9             0.344    0.120    2.872    0.004    0.165    0.165
## 
## Intercepts:
##     ahv_1             0.000                               0.000    0.000
##     ahv_2             0.000                               0.000    0.000
##     ahv_3             0.000                               0.000    0.000
##     ahv_4             0.000                               0.000    0.000
##     ahv_5             0.000                               0.000    0.000
##     ahv_6             0.000                               0.000    0.000
##     ahv_7             0.000                               0.000    0.000
##     ahv_8             0.000                               0.000    0.000
##     ahv_9             0.000                               0.000    0.000
##     aha_1             0.000                               0.000    0.000
##     aha_2             0.000                               0.000    0.000
##     aha_3             0.000                               0.000    0.000
##     aha_4             0.000                               0.000    0.000
##     aha_5             0.000                               0.000    0.000
##     aha_6             0.000                               0.000    0.000
##     aha_7             0.000                               0.000    0.000
##     aha_8             0.000                               0.000    0.000
##     aha_9             0.000                               0.000    0.000
##     ahe_1             0.000                               0.000    0.000
##     ahe_2             0.000                               0.000    0.000
##     ahe_3             0.000                               0.000    0.000
##     ahe_4             0.000                               0.000    0.000
##     ahe_5             0.000                               0.000    0.000
##     ahe_6             0.000                               0.000    0.000
##     ahe_7             0.000                               0.000    0.000
##     ahe_8             0.000                               0.000    0.000
##     ahe_9             0.000                               0.000    0.000
##     g                 0.000                               0.000    0.000
## 
## Thresholds:
##     ahv_1|t1         -0.732    0.045  -16.315    0.000   -0.732   -0.732
##     ahv_2|t1         -0.220    0.041   -5.373    0.000   -0.220   -0.220
##     ahv_3|t1          0.008    0.041    0.194    0.846    0.008    0.008
##     ahv_4|t1          0.264    0.041    6.407    0.000    0.264    0.264
##     ahv_5|t1          0.127    0.041    3.109    0.002    0.127    0.127
##     ahv_6|t1          0.403    0.042    9.626    0.000    0.403    0.403
##     ahv_7|t1          1.392    0.059   23.695    0.000    1.392    1.392
##     ahv_8|t1          1.428    0.060   23.822    0.000    1.428    1.428
##     ahv_9|t1          0.210    0.041    5.115    0.000    0.210    0.210
##     aha_1|t1         -1.036    0.050  -20.860    0.000   -1.036   -1.036
##     aha_2|t1         -0.316    0.041   -7.632    0.000   -0.316   -0.316
##     aha_3|t1          0.458    0.042   10.842    0.000    0.458    0.458
##     aha_4|t1          0.264    0.041    6.407    0.000    0.264    0.264
##     aha_5|t1          0.286    0.041    6.923    0.000    0.286    0.286
##     aha_6|t1          0.417    0.042    9.946    0.000    0.417    0.417
##     aha_7|t1         -0.137    0.041   -3.368    0.001   -0.137   -0.137
##     aha_8|t1          1.101    0.051   21.589    0.000    1.101    1.101
##     aha_9|t1          1.077    0.050   21.333    0.000    1.077    1.077
##     ahe_1|t1         -0.069    0.041   -1.684    0.092   -0.069   -0.069
##     ahe_2|t1          0.286    0.041    6.923    0.000    0.286    0.286
##     ahe_3|t1          0.832    0.046   18.011    0.000    0.832    0.832
##     ahe_4|t1          0.420    0.042   10.010    0.000    0.420    0.420
##     ahe_5|t1          0.544    0.043   12.689    0.000    0.544    0.544
##     ahe_6|t1          0.344    0.042    8.276    0.000    0.344    0.344
##     ahe_7|t1          0.409    0.042    9.754    0.000    0.409    0.409
##     ahe_8|t1          0.987    0.049   20.261    0.000    0.987    0.987
##     ahe_9|t1          0.781    0.045   17.169    0.000    0.781    0.781
## 
## Variances:
##     ahv_1             0.769                               0.769    0.769
##     ahv_2             0.804                               0.804    0.804
##     ahv_3             0.728                               0.728    0.728
##     ahv_4             0.832                               0.832    0.832
##     ahv_5             0.911                               0.911    0.911
##     ahv_6             0.971                               0.971    0.971
##     ahv_7             0.999                               0.999    0.999
##     ahv_8             0.999                               0.999    0.999
##     ahv_9             0.989                               0.989    0.989
##     aha_1             0.651                               0.651    0.651
##     aha_2             0.564                               0.564    0.564
##     aha_3             0.613                               0.613    0.613
##     aha_4             0.870                               0.870    0.870
##     aha_5             0.926                               0.926    0.926
##     aha_6             0.888                               0.888    0.888
##     aha_7             0.564                               0.564    0.564
##     aha_8             0.948                               0.948    0.948
##     aha_9             0.999                               0.999    0.999
##     ahe_1             0.941                               0.941    0.941
##     ahe_2             0.973                               0.973    0.973
##     ahe_3             0.978                               0.978    0.978
##     ahe_4             0.896                               0.896    0.896
##     ahe_5             0.890                               0.890    0.890
##     ahe_6             0.935                               0.935    0.935
##     ahe_7             0.893                               0.893    0.893
##     ahe_8             0.969                               0.969    0.969
##     ahe_9             0.973                               0.973    0.973
##     g                 0.231    0.046                      1.000    1.000
        lavInspect(fit, "rsquare") 
## ahv_1 ahv_2 ahv_3 ahv_4 ahv_5 ahv_6 ahv_7 ahv_8 ahv_9 aha_1 aha_2 aha_3 
## 0.231 0.196 0.272 0.168 0.089 0.029 0.001 0.001 0.011 0.349 0.436 0.387 
## aha_4 aha_5 aha_6 aha_7 aha_8 aha_9 ahe_1 ahe_2 ahe_3 ahe_4 ahe_5 ahe_6 
## 0.130 0.074 0.112 0.436 0.052 0.001 0.059 0.027 0.022 0.104 0.110 0.065 
## ahe_7 ahe_8 ahe_9 
## 0.107 0.031 0.027

Análise Bi-Fatorial Confirmatória

# Cria modelo usadno paste
        m <-
        'g =~ahv_1+ahv_2+ahv_3+ahv_4+ahv_5+ahv_6+ahv_7+ahv_8+ahv_9+
                aha_1+aha_2+aha_3+aha_4+aha_5+aha_6+aha_7+aha_8+aha_9 +
                ahe_1+ahe_2+ahe_3+ahe_4+ahe_5+ahe_6+ahe_7+ahe_8+ahe_9
                
        v =~ahv_1+ahv_2+ahv_3+ahv_4+ahv_5+ahv_6+ahv_7+ahv_8+ahv_9
        a =~aha_1+aha_2+aha_3+aha_4+aha_5+aha_6+aha_7+aha_8+aha_9
        e =~ahe_1+ahe_2+ahe_3+ahe_4+ahe_5+ahe_6+ahe_7+ahe_8+ahe_9
        g ~~ 0*a 
        g ~~ 0*v
        g ~~ 0*e 
        v ~~ 0*a
        v ~~ 0*e
        a ~~ 0*e'
        
        
# Executa a análise
        fit <- cfa(m, data = bpr_df, ordered = colnames(bpr_df))
        
# Examina os resultados
        summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-18) converged normally after 197 iterations
## 
##                                                   Used       Total
##   Number of observations                           952        3578
## 
##   Estimator                                       DWLS      Robust
##   Minimum Function Test Statistic              352.243     396.203
##   Degrees of freedom                               297         297
##   P-value (Chi-square)                           0.015       0.000
##   Scaling correction factor                                  1.025
##   Shift parameter                                           52.717
##     for simple second-order correction (Mplus variant)
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic             2606.156    2032.940
##   Degrees of freedom                               351         351
##   P-value                                        0.000       0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    0.976       0.941
##   Tucker-Lewis Index (TLI)                       0.971       0.930
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.014       0.019
##   90 Percent Confidence Interval          0.007  0.019       0.013  0.023
##   P-value RMSEA <= 0.05                          1.000       1.000
## 
## Weighted Root Mean Square Residual:
## 
##   WRMR                                           0.965       0.965
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                           Robust.sem
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   g =~
##     ahv_1             1.000                               0.514    0.514
##     ahv_2             0.870    0.123    7.076    0.000    0.448    0.448
##     ahv_3             1.065    0.140    7.585    0.000    0.548    0.548
##     ahv_4             0.859    0.129    6.669    0.000    0.442    0.442
##     ahv_5             0.535    0.118    4.518    0.000    0.275    0.275
##     ahv_6             0.329    0.108    3.035    0.002    0.169    0.169
##     ahv_7             0.169    0.160    1.056    0.291    0.087    0.087
##     ahv_8             0.051    0.160    0.319    0.750    0.026    0.026
##     ahv_9             0.099    0.108    0.911    0.362    0.051    0.051
##     aha_1             0.909    0.152    5.968    0.000    0.468    0.468
##     aha_2             0.941    0.157    5.980    0.000    0.484    0.484
##     aha_3             1.061    0.163    6.525    0.000    0.546    0.546
##     aha_4             0.709    0.132    5.362    0.000    0.364    0.364
##     aha_5             0.521    0.122    4.275    0.000    0.268    0.268
##     aha_6             0.492    0.130    3.791    0.000    0.253    0.253
##     aha_7             1.152    0.162    7.108    0.000    0.593    0.593
##     aha_8             0.317    0.142    2.228    0.026    0.163    0.163
##     aha_9             0.184    0.147    1.252    0.210    0.094    0.094
##     ahe_1             0.370    0.111    3.340    0.001    0.190    0.190
##     ahe_2             0.243    0.102    2.375    0.018    0.125    0.125
##     ahe_3             0.301    0.118    2.539    0.011    0.155    0.155
##     ahe_4             0.618    0.118    5.234    0.000    0.318    0.318
##     ahe_5             0.682    0.129    5.283    0.000    0.351    0.351
##     ahe_6             0.482    0.121    3.983    0.000    0.248    0.248
##     ahe_7             0.691    0.127    5.458    0.000    0.355    0.355
##     ahe_8             0.403    0.134    3.000    0.003    0.207    0.207
##     ahe_9             0.291    0.123    2.373    0.018    0.150    0.150
##   v =~
##     ahv_1             1.000                               0.100    0.100
##     ahv_2             2.917    2.484    1.174    0.240    0.292    0.292
##     ahv_3             1.835    1.655    1.109    0.268    0.184    0.184
##     ahv_4             0.742    0.966    0.769    0.442    0.074    0.074
##     ahv_5             3.747    3.377    1.110    0.267    0.375    0.375
##     ahv_6             0.731    1.023    0.715    0.475    0.073    0.073
##     ahv_7            -3.913    3.716   -1.053    0.292   -0.391   -0.391
##     ahv_8            -3.702    3.740   -0.990    0.322   -0.370   -0.370
##     ahv_9             4.043    3.742    1.080    0.280    0.404    0.404
##   a =~
##     aha_1             1.000                               0.426    0.426
##     aha_2             1.655    0.450    3.680    0.000    0.705    0.705
##     aha_3             0.751    0.198    3.792    0.000    0.320    0.320
##     aha_4             0.168    0.166    1.016    0.310    0.072    0.072
##     aha_5             0.175    0.169    1.039    0.299    0.075    0.075
##     aha_6             0.661    0.194    3.412    0.001    0.282    0.282
##     aha_7             0.715    0.187    3.831    0.000    0.304    0.304
##     aha_8             0.514    0.218    2.359    0.018    0.219    0.219
##     aha_9            -0.348    0.210   -1.656    0.098   -0.148   -0.148
##   e =~
##     ahe_1             1.000                               0.640    0.640
##     ahe_2             0.752    0.242    3.107    0.002    0.482    0.482
##     ahe_3             0.037    0.123    0.299    0.765    0.024    0.024
##     ahe_4             0.418    0.140    2.995    0.003    0.268    0.268
##     ahe_5             0.146    0.111    1.312    0.190    0.093    0.093
##     ahe_6             0.315    0.125    2.530    0.011    0.202    0.202
##     ahe_7             0.076    0.109    0.701    0.483    0.049    0.049
##     ahe_8            -0.133    0.125   -1.069    0.285   -0.085   -0.085
##     ahe_9             0.367    0.144    2.558    0.011    0.235    0.235
## 
## Covariances:
##   g ~~
##     a                 0.000                               0.000    0.000
##     v                 0.000                               0.000    0.000
##     e                 0.000                               0.000    0.000
##   v ~~
##     a                 0.000                               0.000    0.000
##     e                 0.000                               0.000    0.000
##   a ~~
##     e                 0.000                               0.000    0.000
## 
## Intercepts:
##     ahv_1             0.000                               0.000    0.000
##     ahv_2             0.000                               0.000    0.000
##     ahv_3             0.000                               0.000    0.000
##     ahv_4             0.000                               0.000    0.000
##     ahv_5             0.000                               0.000    0.000
##     ahv_6             0.000                               0.000    0.000
##     ahv_7             0.000                               0.000    0.000
##     ahv_8             0.000                               0.000    0.000
##     ahv_9             0.000                               0.000    0.000
##     aha_1             0.000                               0.000    0.000
##     aha_2             0.000                               0.000    0.000
##     aha_3             0.000                               0.000    0.000
##     aha_4             0.000                               0.000    0.000
##     aha_5             0.000                               0.000    0.000
##     aha_6             0.000                               0.000    0.000
##     aha_7             0.000                               0.000    0.000
##     aha_8             0.000                               0.000    0.000
##     aha_9             0.000                               0.000    0.000
##     ahe_1             0.000                               0.000    0.000
##     ahe_2             0.000                               0.000    0.000
##     ahe_3             0.000                               0.000    0.000
##     ahe_4             0.000                               0.000    0.000
##     ahe_5             0.000                               0.000    0.000
##     ahe_6             0.000                               0.000    0.000
##     ahe_7             0.000                               0.000    0.000
##     ahe_8             0.000                               0.000    0.000
##     ahe_9             0.000                               0.000    0.000
##     g                 0.000                               0.000    0.000
##     v                 0.000                               0.000    0.000
##     a                 0.000                               0.000    0.000
##     e                 0.000                               0.000    0.000
## 
## Thresholds:
##     ahv_1|t1         -0.732    0.045  -16.315    0.000   -0.732   -0.732
##     ahv_2|t1         -0.220    0.041   -5.373    0.000   -0.220   -0.220
##     ahv_3|t1          0.008    0.041    0.194    0.846    0.008    0.008
##     ahv_4|t1          0.264    0.041    6.407    0.000    0.264    0.264
##     ahv_5|t1          0.127    0.041    3.109    0.002    0.127    0.127
##     ahv_6|t1          0.403    0.042    9.626    0.000    0.403    0.403
##     ahv_7|t1          1.392    0.059   23.695    0.000    1.392    1.392
##     ahv_8|t1          1.428    0.060   23.822    0.000    1.428    1.428
##     ahv_9|t1          0.210    0.041    5.115    0.000    0.210    0.210
##     aha_1|t1         -1.036    0.050  -20.860    0.000   -1.036   -1.036
##     aha_2|t1         -0.316    0.041   -7.632    0.000   -0.316   -0.316
##     aha_3|t1          0.458    0.042   10.842    0.000    0.458    0.458
##     aha_4|t1          0.264    0.041    6.407    0.000    0.264    0.264
##     aha_5|t1          0.286    0.041    6.923    0.000    0.286    0.286
##     aha_6|t1          0.417    0.042    9.946    0.000    0.417    0.417
##     aha_7|t1         -0.137    0.041   -3.368    0.001   -0.137   -0.137
##     aha_8|t1          1.101    0.051   21.589    0.000    1.101    1.101
##     aha_9|t1          1.077    0.050   21.333    0.000    1.077    1.077
##     ahe_1|t1         -0.069    0.041   -1.684    0.092   -0.069   -0.069
##     ahe_2|t1          0.286    0.041    6.923    0.000    0.286    0.286
##     ahe_3|t1          0.832    0.046   18.011    0.000    0.832    0.832
##     ahe_4|t1          0.420    0.042   10.010    0.000    0.420    0.420
##     ahe_5|t1          0.544    0.043   12.689    0.000    0.544    0.544
##     ahe_6|t1          0.344    0.042    8.276    0.000    0.344    0.344
##     ahe_7|t1          0.409    0.042    9.754    0.000    0.409    0.409
##     ahe_8|t1          0.987    0.049   20.261    0.000    0.987    0.987
##     ahe_9|t1          0.781    0.045   17.169    0.000    0.781    0.781
## 
## Variances:
##     ahv_1             0.726                               0.726    0.726
##     ahv_2             0.715                               0.715    0.715
##     ahv_3             0.666                               0.666    0.666
##     ahv_4             0.799                               0.799    0.799
##     ahv_5             0.784                               0.784    0.784
##     ahv_6             0.966                               0.966    0.966
##     ahv_7             0.839                               0.839    0.839
##     ahv_8             0.862                               0.862    0.862
##     ahv_9             0.834                               0.834    0.834
##     aha_1             0.600                               0.600    0.600
##     aha_2             0.269                               0.269    0.269
##     aha_3             0.600                               0.600    0.600
##     aha_4             0.862                               0.862    0.862
##     aha_5             0.923                               0.923    0.923
##     aha_6             0.857                               0.857    0.857
##     aha_7             0.556                               0.556    0.556
##     aha_8             0.926                               0.926    0.926
##     aha_9             0.969                               0.969    0.969
##     ahe_1             0.554                               0.554    0.554
##     ahe_2             0.752                               0.752    0.752
##     ahe_3             0.976                               0.976    0.976
##     ahe_4             0.827                               0.827    0.827
##     ahe_5             0.868                               0.868    0.868
##     ahe_6             0.898                               0.898    0.898
##     ahe_7             0.871                               0.871    0.871
##     ahe_8             0.950                               0.950    0.950
##     ahe_9             0.922                               0.922    0.922
##     g                 0.264    0.057                      1.000    1.000
##     v                 0.010    0.018                      1.000    1.000
##     a                 0.181    0.070                      1.000    1.000
##     e                 0.410    0.139                      1.000    1.000
        lavInspect(fit, "rsquare") 
## ahv_1 ahv_2 ahv_3 ahv_4 ahv_5 ahv_6 ahv_7 ahv_8 ahv_9 aha_1 aha_2 aha_3 
## 0.274 0.285 0.334 0.201 0.216 0.034 0.161 0.138 0.166 0.400 0.731 0.400 
## aha_4 aha_5 aha_6 aha_7 aha_8 aha_9 ahe_1 ahe_2 ahe_3 ahe_4 ahe_5 ahe_6 
## 0.138 0.077 0.143 0.444 0.074 0.031 0.446 0.248 0.024 0.173 0.132 0.102 
## ahe_7 ahe_8 ahe_9 
## 0.129 0.050 0.078