O Pacote lavan (latent variable analysis)

        setwd("~/Dropbox/R Stat")        
        load("sem.RData")
        # install.packages("lavaan")
        library(lavaan)
## This is lavaan 0.5-20
## lavaan is BETA software! Please report any bugs.
        library(psych)
        library(semPlot)

 

        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[ , 57:115])
##          vars    n mean   sd median trimmed  mad min max range  skew
## T1_30O1     1  914 3.30 1.07      3    3.32 1.48   1   5     4 -0.15
## T1_31O1     2  914 3.01 0.93      3    2.96 1.48   1   5     4  0.26
## T1_32O1     3  909 3.65 1.06      4    3.72 1.48   1   5     4 -0.44
## T1_33O1     4  908 3.49 1.02      3    3.52 1.48   1   5     4 -0.22
## T1_34O1     5  909 3.20 1.02      3    3.18 1.48   1   5     4 -0.02
## T1_35O1     6  910 3.05 1.24      3    3.07 1.48   1   5     4 -0.01
## T1_36O1     7  899 2.86 1.14      3    2.83 1.48   1   5     4  0.32
## T1_37O1     8  912 2.94 1.02      3    2.91 1.48   1   5     4  0.17
## T1_38O1     9  909 3.54 1.06      4    3.58 1.48   1   5     4 -0.24
## T1_39E1    10  905 3.70 1.17      4    3.81 1.48   1   5     4 -0.58
## T1_40E1    11  902 2.79 1.38      3    2.74 1.48   1   5     4  0.18
## T1_41E1    12  911 3.44 1.27      3    3.52 1.48   1   5     4 -0.26
## T1_42E1    13  909 3.83 1.16      4    3.97 1.48   1   5     4 -0.73
## T1_43E1    14  912 3.13 1.26      3    3.17 1.48   1   5     4 -0.05
## T1_44E1    15  902 3.58 1.07      4    3.63 1.48   1   5     4 -0.29
## T1_45E1    16  917 3.37 1.22      3    3.43 1.48   1   5     4 -0.25
## T1_46E1    17  911 4.09 1.02      4    4.25 1.48   1   5     4 -0.97
## T1_47E1    18  912 3.04 1.06      3    3.02 1.48   1   5     4  0.07
## T1_48E1    19  900 2.85 1.34      3    2.82 1.48   1   5     4  0.19
## T1_49E1    20  915 3.74 1.23      4    3.87 1.48   1   5     4 -0.63
## T1_50E1    21  909 3.85 1.15      4    3.98 1.48   1   5     4 -0.68
## T1_51E1    22  917 4.11 1.18      5    4.32 0.00   1   5     4 -1.19
## T1_52E1    23  910 4.07 1.03      4    4.22 1.48   1   5     4 -0.94
## T1_53C0    24  897 3.20 1.25      3    3.25 1.48   1   5     4 -0.12
## T1_54C1    25  906 3.12 1.35      3    3.16 1.48   1   5     4  0.00
## T1_55C1    26  907 2.68 1.26      3    2.60 1.48   1   5     4  0.35
## T1_56C1    27  905 3.59 1.13      4    3.65 1.48   1   5     4 -0.35
## T1_57C1    28  912 2.84 1.34      3    2.80 1.48   1   5     4  0.17
## T1_58C1    29  909 3.20 1.29      3    3.25 1.48   1   5     4 -0.14
## T1_59C1    30  909 3.37 1.29      3    3.46 1.48   1   5     4 -0.30
## T1_60C0    31  905 3.31 1.23      3    3.36 1.48   1   5     4 -0.12
## T1_61C1    32  912 3.45 1.24      3    3.54 1.48   1   5     4 -0.33
## T1_62C1    33  912 3.62 1.17      4    3.70 1.48   1   5     4 -0.40
## T1_63C0    34  900 2.69 1.03      3    2.66 1.48   1   5     4  0.24
## T1_64C1    35  910 4.18 0.93      4    4.31 1.48   1   5     4 -1.04
## T1_65C1    36  917 3.21 1.35      3    3.26 1.48   1   5     4 -0.11
## T5_01Ac1   37 1008 2.96 0.99      3    2.91 1.48   1   5     4  0.27
## T5_02Ac1   38 1011 3.04 1.02      3    3.03 1.48   1   5     4  0.00
## T5_03Ac1   39 1008 3.50 1.03      4    3.53 1.48   1   5     4 -0.36
## T5_04Ac1   40 1005 3.68 1.04      4    3.76 1.48   1   5     4 -0.39
## T5_05Ac1   41  996 3.86 0.90      4    3.92 1.48   1   5     4 -0.52
## T5_06Ac1   42  998 3.92 1.16      4    4.08 1.48   1   5     4 -0.85
## T5_07Ac1   43 1010 3.76 1.03      4    3.86 1.48   1   5     4 -0.62
## T5_08Ac1   44 1004 3.46 0.81      3    3.46 1.48   1   5     4 -0.14
## T5_09Sc1   45 1004 3.33 1.15      3    3.36 1.48   1   5     4 -0.18
## T5_10Sc1   46 1006 4.03 1.03      4    4.17 1.48   1   5     4 -0.91
## T5_11Sc1   47 1002 2.92 1.30      3    2.90 1.48   1   5     4  0.06
## T5_12Sc1   48 1007 3.78 1.04      4    3.88 1.48   1   5     4 -0.70
## T5_13Sc1   49 1012 3.47 1.24      4    3.55 1.48   1   5     4 -0.33
## T5_14Sc1   50 1003 3.67 1.18      4    3.78 1.48   1   5     4 -0.59
## T5_15Sc1   51 1000 4.05 0.98      4    4.19 1.48   1   5     4 -0.98
## T5_16Sc1   52  989 3.33 1.27      3    3.40 1.48   1   5     4 -0.27
## T5_17Em1   53  996 3.23 1.16      3    3.25 1.48   1   5     4 -0.09
## T5_18Em1   54 1001 3.20 1.07      3    3.20 1.48   1   5     4 -0.10
## T5_19Em1   55 1001 3.09 1.25      3    3.11 1.48   1   5     4 -0.08
## T5_20Em1   56 1000 3.23 1.25      3    3.29 1.48   1   5     4 -0.21
## T5_21Em1   57 1004 3.35 1.24      3    3.42 1.48   1   5     4 -0.25
## T5_22Em1   58  990 3.46 1.22      4    3.54 1.48   1   5     4 -0.35
## T5_23Em1   59 1004 3.18 1.23      3    3.23 1.48   1   5     4 -0.12
##          kurtosis   se
## T1_30O1     -0.44 0.04
## T1_31O1      0.03 0.03
## T1_32O1     -0.44 0.04
## T1_33O1     -0.47 0.03
## T1_34O1     -0.39 0.03
## T1_35O1     -0.95 0.04
## T1_36O1     -0.66 0.04
## T1_37O1     -0.21 0.03
## T1_38O1     -0.65 0.04
## T1_39E1     -0.60 0.04
## T1_40E1     -1.20 0.05
## T1_41E1     -1.05 0.04
## T1_42E1     -0.41 0.04
## T1_43E1     -0.96 0.04
## T1_44E1     -0.58 0.04
## T1_45E1     -0.85 0.04
## T1_46E1      0.20 0.03
## T1_47E1     -0.42 0.03
## T1_48E1     -1.07 0.04
## T1_49E1     -0.66 0.04
## T1_50E1     -0.52 0.04
## T1_51E1      0.35 0.04
## T1_52E1      0.12 0.03
## T1_53C0     -0.90 0.04
## T1_54C1     -1.20 0.04
## T1_55C1     -0.86 0.04
## T1_56C1     -0.78 0.04
## T1_57C1     -1.13 0.04
## T1_58C1     -1.06 0.04
## T1_59C1     -0.96 0.04
## T1_60C0     -0.91 0.04
## T1_61C1     -0.86 0.04
## T1_62C1     -0.82 0.04
## T1_63C0     -0.21 0.03
## T1_64C1      0.60 0.03
## T1_65C1     -1.13 0.04
## T5_01Ac1    -0.17 0.03
## T5_02Ac1    -0.49 0.03
## T5_03Ac1    -0.49 0.03
## T5_04Ac1    -0.57 0.03
## T5_05Ac1    -0.03 0.03
## T5_06Ac1    -0.20 0.04
## T5_07Ac1    -0.16 0.03
## T5_08Ac1     0.16 0.03
## T5_09Sc1    -0.85 0.04
## T5_10Sc1     0.13 0.03
## T5_11Sc1    -1.08 0.04
## T5_12Sc1    -0.03 0.03
## T5_13Sc1    -0.94 0.04
## T5_14Sc1    -0.58 0.04
## T5_15Sc1     0.45 0.03
## T5_16Sc1    -1.00 0.04
## T5_17Em1    -0.83 0.04
## T5_18Em1    -0.56 0.03
## T5_19Em1    -1.03 0.04
## T5_20Em1    -0.96 0.04
## T5_21Em1    -0.94 0.04
## T5_22Em1    -0.92 0.04
## T5_23Em1    -0.97 0.04
        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 )
## Found more than one class "Model" in cache; using the first, from namespace 'lavaan'
        # desenha o modelo
        semPaths(fit)

Examine os resultados

        summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan (0.5-20) 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
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   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:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   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:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     T2.A.1            0.281    0.018   15.828    0.000    0.281    0.627
##     T2.A.2            0.343    0.022   15.365    0.000    0.343    0.609
##     T2.A.3            0.518    0.030   17.382    0.000    0.518    0.695
##     T2.C.1            0.236    0.018   13.034    0.000    0.236    0.411
##     T2.C.2            0.436    0.025   17.479    0.000    0.436    0.585
##     T2.C.3            0.256    0.019   13.620    0.000    0.256    0.430
##     T2.E.1            0.445    0.032   13.826    0.000    0.445    0.612
##     T2.E.2            0.320    0.038    8.366    0.000    0.320    0.438
##     T2.E.3            0.736    0.039   18.930    0.000    0.736    0.796
##     T2.N.1            0.246    0.038    6.493    0.000    0.246    0.334
##     T2.N.2            0.449    0.025   18.162    0.000    0.449    0.734
##     T2.N.3            0.537    0.028   18.912    0.000    0.537    0.772
##     T2.O.1            0.441    0.028   15.733    0.000    0.441    0.562
##     T2.O.2            0.477    0.025   18.924    0.000    0.477    0.719
##     T2.O.3            0.248    0.027    9.056    0.000    0.248    0.346
##     A                 0.168    0.020    8.290    0.000    1.000    1.000
##     C                 0.338    0.028   11.975    0.000    1.000    1.000
##     E                 0.282    0.036    7.754    0.000    1.000    1.000
##     N                 0.490    0.048   10.130    0.000    1.000    1.000
##     O                 0.344    0.036    9.628    0.000    1.000    1.000

Examine índices de modificação

        mi <- modindices(fit)
        str(mi)
## Classes 'lavaan.data.frame' and 'data.frame':    165 obs. of  8 variables:
##  $ lhs     : chr  "A" "A" "A" "A" ...
##  $ op      : chr  "=~" "=~" "=~" "=~" ...
##  $ rhs     : chr  "T2.C.1" "T2.C.2" "T2.C.3" "T2.E.1" ...
##  $ mi      : num  1.799 5.112 0.394 71.459 13.131 ...
##  $ epc     : num  -0.1192 0.2211 -0.0563 -0.6668 0.32 ...
##  $ sepc.lv : num  -0.0488 0.0905 -0.023 -0.2729 0.131 ...
##  $ sepc.all: num  -0.0644 0.1049 -0.0299 -0.32 0.1533 ...
##  $ sepc.nox: num  -0.0644 0.1049 -0.0299 -0.32 0.1533 ...
        class(mi)
## [1] "lavaan.data.frame" "data.frame"
        head(mi)
##    lhs op    rhs     mi    epc sepc.lv sepc.all sepc.nox
## 46   A =~ T2.C.1  1.799 -0.119  -0.049   -0.064   -0.064
## 47   A =~ T2.C.2  5.112  0.221   0.091    0.105    0.105
## 48   A =~ T2.C.3  0.394 -0.056  -0.023   -0.030   -0.030
## 49   A =~ T2.E.1 71.459 -0.667  -0.273   -0.320   -0.320
## 50   A =~ T2.E.2 13.131  0.320   0.131    0.153    0.153
## 51   A =~ T2.E.3 40.000  0.568   0.232    0.242    0.242
        mi[mi$mi>20 , ]
##        lhs op    rhs     mi    epc sepc.lv sepc.all sepc.nox
## 49       A =~ T2.E.1 71.459 -0.667  -0.273   -0.320   -0.320
## 51       A =~ T2.E.3 40.000  0.568   0.232    0.242    0.242
## 54       A =~ T2.N.3 34.880  0.658   0.269    0.323    0.323
## 61       C =~ T2.E.1 69.167 -0.425  -0.247   -0.290   -0.290
## 63       C =~ T2.E.3 23.748  0.284   0.165    0.172    0.172
## 66       C =~ T2.N.3 27.513  0.292   0.170    0.203    0.203
## 75       E =~ T2.C.3 29.461  0.261   0.139    0.180    0.180
## 76       E =~ T2.N.1 58.553 -0.564  -0.300   -0.349   -0.349
## 78       E =~ T2.N.3 45.069  0.387   0.205    0.246    0.246
## 83       N =~ T2.A.2 28.802 -0.321  -0.225   -0.300   -0.300
## 86       N =~ T2.C.2 50.385  0.315   0.220    0.255    0.255
## 88       N =~ T2.E.1 29.354 -0.233  -0.163   -0.191   -0.191
## 90       N =~ T2.E.3 34.764  0.292   0.204    0.213    0.213
## 98       O =~ T2.C.2 59.108 -0.450  -0.264   -0.306   -0.306
## 99       O =~ T2.C.3 30.155  0.289   0.169    0.220    0.220
## 105      O =~ T2.N.3 35.584  0.295   0.173    0.207    0.207
## 111 T2.A.1 ~~ T2.E.1 22.237 -0.068  -0.068   -0.119   -0.119
## 138 T2.A.3 ~~ T2.E.3 29.945  0.124   0.124    0.150    0.150
## 159 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-20) 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
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   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:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   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:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   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:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     T2.A.1            0.257    0.033    7.862    0.000    0.257    0.686
##     T2.A.2            0.450    0.052    8.713    0.000    0.450    0.756
##     T2.A.3            0.500    0.065    7.650    0.000    0.500    0.671
##     T2.C.1            0.263    0.033    7.893    0.000    0.263    0.424
##     T2.C.2            0.439    0.048    9.087    0.000    0.439    0.559
##     T2.C.3            0.250    0.032    7.717    0.000    0.250    0.410
##     T2.E.1            0.147    0.111    1.330    0.183    0.147    0.227
##     T2.E.2            0.516    0.060    8.541    0.000    0.516    0.762
##     T2.E.3            0.847    0.081   10.403    0.000    0.847    0.936
##     T2.N.1            0.267    0.071    3.754    0.000    0.267    0.337
##     T2.N.2            0.411    0.050    8.288    0.000    0.411    0.641
##     T2.N.3            0.571    0.060    9.511    0.000    0.571    0.768
##     T2.O.1            0.375    0.056    6.743    0.000    0.375    0.445
##     T2.O.2            0.450    0.047    9.575    0.000    0.450    0.724
##     T2.O.3            0.296    0.054    5.508    0.000    0.296    0.368
##     T8.Gr.1           0.286    0.038    7.632    0.000    0.286    0.484
##     T8.Gr.2           0.412    0.053    7.795    0.000    0.412    0.496
##     T8.Gr.3           0.414    0.041   10.037    0.000    0.414    0.808
##     A                 0.118    0.034    3.482    0.000    1.000    1.000
##     C                 0.357    0.057    6.234    0.000    1.000    1.000
##     E                 0.501    0.125    4.014    0.000    1.000    1.000
##     N                 0.525    0.097    5.436    0.000    1.000    1.000
##     O                 0.467    0.083    5.638    0.000    1.000    1.000
##     grit              0.044    0.029    1.515    0.130    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
# desenha o modelo
        semPaths(fit)