Análise fatorial exploratória de escalas (variáveis contínuas)
Explorando as correlações com visualizações do d3heatmap e corrr
load("~/Dropbox/R Stat/bd2.RData")

names(bd2)[84:85] <- c("notas_port", "notas_mat")
bd2$notas_port <- ave(bd2$notas_port, bd2$serie, FUN=scale)
bd2$notas_mat <- ave(bd2$notas_mat, bd2$serie, FUN=scale)

library(corrr)
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
d <- correlate(bd2[ , 60:85], use="pair")
d %>% shave() %>% fashion()
##       rowname  A_0  C_0  E_0  N_0  O_0  A_1  C_1  E_1  N_1  O_1 insmot
## 1         A_0                                                         
## 2         C_0  .35                                                    
## 3         E_0  .31  .21                                               
## 4         N_0  .20  .09  .18                                          
## 5         O_0  .43  .28  .32  .13                                     
## 6         A_1  .47  .12  .32  .06  .33                                
## 7         C_1  .45  .74  .26  .11  .44  .52                           
## 8         E_1  .16  .16  .26 -.12  .41  .41  .31                      
## 9         N_1  .25  .20  .10  .57  .25  .27  .36  .23                 
## 10        O_1  .36  .39  .25  .21  .49  .49  .57  .43  .41            
## 11     insmot  .25  .21 -.06 -.02  .24  .12  .32  .19  .08  .19       
## 12     cstrat  .37  .48  .22 -.09  .29  .24  .49  .18  .13  .35    .36
## 13      memor  .21  .50  .19  .09  .21  .28  .49  .15  .20  .40    .35
## 14       elab  .25  .47  .21  .00  .37  .22  .47  .26  .25  .37    .47
## 15     effper  .38  .52  .17  .02  .36  .34  .63  .32  .25  .40    .47
## 16     selfef  .29  .45  .24  .03  .39  .24  .55  .15  .22  .33    .48
## 17       cexp  .36  .32  .24  .07  .28  .32  .44  .23  .28  .30    .41
## 18     intrea  .40  .42  .29 -.03  .42  .27  .45  .19  .14  .34    .09
## 19     intmat  .24  .49  .17  .09  .15  .24  .56  .03  .25  .25    .34
## 20     comlrn -.15  .13  .04 -.14  .01  .22  .23  .15  .04  .19   -.11
## 21     coplrn  .25  .23  .26 -.11  .28  .27  .28  .18 -.09  .22    .23
## 22     scverb  .21  .45  .21  .16  .23  .18  .37  .05  .13  .40    .13
## 23     scmath  .18  .43  .18  .00  .11  .07  .47 -.06  .03  .08    .37
## 24     scacad  .23  .52  .18  .00  .14  .13  .45  .13  .13  .36    .40
## 25 notas_port -.01  .19  .30  .17  .19 -.06  .18  .12  .04  .03    .17
## 26  notas_mat  .25  .30  .30  .08  .32  .20  .28  .08  .12  .25    .20
##    cstrat memor elab effper selfef cexp intrea intmat comlrn coplrn scverb
## 1                                                                         
## 2                                                                         
## 3                                                                         
## 4                                                                         
## 5                                                                         
## 6                                                                         
## 7                                                                         
## 8                                                                         
## 9                                                                         
## 10                                                                        
## 11                                                                        
## 12                                                                        
## 13    .58                                                                 
## 14    .65   .67                                                           
## 15    .65   .51  .60                                                      
## 16    .58   .57  .46    .67                                               
## 17    .52   .56  .52    .55    .64                                        
## 18    .48   .34  .31    .33    .44  .35                                   
## 19    .36   .49  .39    .53    .56  .36    .31                            
## 20    .19   .07  .15    .06    .16  .01    .16    .22                     
## 21    .17   .35  .27    .35    .36  .31    .31    .39    .01              
## 22    .32   .35  .18    .26    .44  .39    .36    .24    .07    .20       
## 23    .33   .42  .35    .46    .52  .35    .14    .73    .09    .22    .15
## 24    .47   .48  .42    .52    .59  .49    .39    .57   -.01    .43    .43
## 25    .15   .23  .09    .29    .34  .17    .02    .29   -.20    .04    .20
## 26    .20   .16  .14    .22    .34  .30    .23    .22   -.15    .13    .46
##    scmath scacad notas_port notas_mat
## 1                                    
## 2                                    
## 3                                    
## 4                                    
## 5                                    
## 6                                    
## 7                                    
## 8                                    
## 9                                    
## 10                                   
## 11                                   
## 12                                   
## 13                                   
## 14                                   
## 15                                   
## 16                                   
## 17                                   
## 18                                   
## 19                                   
## 20                                   
## 21                                   
## 22                                   
## 23                                   
## 24    .40                            
## 25    .57    .26                     
## 26    .29    .44        .48
network_plot(d, min_cor = .30)

library(d3heatmap)


d3heatmap(cor(bd2[ , 60:85], use="pair"), 
          symn= TRUE,  symm = TRUE, 
          k_row = 5, k_col = 5)
Análise fatorial exploratória
library(psych)

# Análise paralela

fa.parallel(bd2[ , 60:85], n.iter=20, SMC=TRUE)

## Parallel analysis suggests that the number of factors =  3  and the number of components =  3
m5v <- fa(bd2[ , 60:85], fm="minres", nfactors = 5, rotate = "varimax")

m5o <- fa(bd2[ , 60:85], fm="minres", nfactors = 5, rotate = "oblimin")
## Loading required namespace: GPArotation
print.psych(m5v, cut = .30)
## Factor Analysis using method =  minres
## Call: fa(r = bd2[, 60:85], nfactors = 5, rotate = "varimax", fm = "minres")
## Standardized loadings (pattern matrix) based upon correlation matrix
##              MR1   MR2   MR5   MR4   MR3   h2   u2 com
## A_0               0.50                   0.33 0.67 1.7
## C_0         0.37  0.45  0.43             0.53 0.47 3.0
## E_0               0.39        0.31       0.26 0.74 2.1
## N_0                                 0.72 0.56 0.44 1.2
## O_0               0.57                   0.41 0.59 1.6
## A_1               0.60                   0.41 0.59 1.3
## C_1         0.36  0.63  0.52             0.81 0.19 2.7
## E_1               0.48                   0.25 0.75 1.3
## N_1                                 0.74 0.66 0.34 1.4
## O_1               0.67                   0.56 0.44 1.5
## insmot      0.57                         0.35 0.65 1.2
## cstrat      0.70  0.32                   0.61 0.39 1.5
## memor       0.68                         0.56 0.44 1.4
## elab        0.74                         0.62 0.38 1.3
## effper      0.67  0.33                   0.64 0.36 1.9
## selfef      0.66                         0.65 0.35 2.1
## cexp        0.66                         0.56 0.44 1.5
## intrea      0.30  0.53                   0.40 0.60 1.8
## intmat      0.44        0.68             0.69 0.31 1.9
## comlrn                       -0.37       0.25 0.75 2.5
## coplrn      0.31                         0.26 0.74 3.4
## scverb            0.43        0.32       0.35 0.65 2.5
## scmath      0.41        0.76  0.31       0.85 0.15 1.9
## scacad      0.55                         0.50 0.50 2.4
## notas_port              0.33  0.70       0.63 0.37 1.6
## notas_mat         0.33        0.65       0.56 0.44 1.6
## 
##                        MR1  MR2  MR5  MR4  MR3
## SS loadings           4.57 3.72 2.05 1.63 1.30
## Proportion Var        0.18 0.14 0.08 0.06 0.05
## Cumulative Var        0.18 0.32 0.40 0.46 0.51
## Proportion Explained  0.34 0.28 0.15 0.12 0.10
## Cumulative Proportion 0.34 0.62 0.78 0.90 1.00
## 
## Mean item complexity =  1.9
## Test of the hypothesis that 5 factors are sufficient.
## 
## The degrees of freedom for the null model are  325  and the objective function was  16.29 with Chi Square of  1067.14
## The degrees of freedom for the model are 205  and the objective function was  4.76 
## 
## The root mean square of the residuals (RMSR) is  0.06 
## The df corrected root mean square of the residuals is  0.07 
## 
## The harmonic number of observations is  76 with the empirical chi square  165.44  with prob <  0.98 
## The total number of observations was  76  with MLE Chi Square =  295.73  with prob <  3.4e-05 
## 
## Tucker Lewis Index of factoring reliability =  0.791
## RMSEA index =  0.099  and the 90 % confidence intervals are  0.056 NA
## BIC =  -592.07
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy             
##                                                 MR1  MR2  MR5  MR4  MR3
## Correlation of scores with factors             0.91 0.91 0.90 0.87 0.86
## Multiple R square of scores with factors       0.83 0.83 0.81 0.76 0.73
## Minimum correlation of possible factor scores  0.65 0.66 0.62 0.52 0.47
print.psych(m5o, cut = .30)
## Factor Analysis using method =  minres
## Call: fa(r = bd2[, 60:85], nfactors = 5, rotate = "oblimin", fm = "minres")
## Standardized loadings (pattern matrix) based upon correlation matrix
##              MR1   MR5   MR2   MR4   MR3   h2   u2 com
## A_0               0.42                   0.33 0.67 1.7
## C_0               0.47  0.31             0.53 0.47 2.0
## E_0               0.33        0.37       0.26 0.74 2.0
## N_0                                 0.74 0.56 0.44 1.1
## O_0               0.44                   0.41 0.59 2.5
## A_1               0.63                   0.41 0.59 1.1
## C_1               0.70  0.35             0.81 0.19 1.6
## E_1               0.40                   0.25 0.75 2.1
## N_1                                 0.75 0.66 0.34 1.1
## O_1               0.58                   0.56 0.44 1.6
## insmot      0.62                         0.35 0.65 1.2
## cstrat      0.76                         0.61 0.39 1.1
## memor       0.69                         0.56 0.44 1.1
## elab        0.82                         0.62 0.38 1.1
## effper      0.61                         0.64 0.36 1.3
## selfef      0.60                         0.65 0.35 1.4
## cexp        0.73                         0.56 0.44 1.1
## intrea            0.47                   0.40 0.60 2.0
## intmat                  0.68             0.69 0.31 1.3
## comlrn            0.39       -0.36       0.25 0.75 2.9
## coplrn                                   0.26 0.74 3.3
## scverb                        0.38       0.35 0.65 2.5
## scmath                  0.85             0.85 0.15 1.1
## scacad      0.50                         0.50 0.50 1.7
## notas_port              0.41  0.60       0.63 0.37 2.1
## notas_mat                     0.70       0.56 0.44 1.1
## 
##                        MR1  MR5  MR2  MR4  MR3
## SS loadings           4.69 3.31 2.11 1.76 1.41
## Proportion Var        0.18 0.13 0.08 0.07 0.05
## Cumulative Var        0.18 0.31 0.39 0.46 0.51
## Proportion Explained  0.35 0.25 0.16 0.13 0.11
## Cumulative Proportion 0.35 0.60 0.76 0.89 1.00
## 
##  With factor correlations of 
##      MR1  MR5  MR2  MR4  MR3
## MR1 1.00 0.56 0.44 0.25 0.14
## MR5 0.56 1.00 0.16 0.13 0.22
## MR2 0.44 0.16 1.00 0.25 0.05
## MR4 0.25 0.13 0.25 1.00 0.13
## MR3 0.14 0.22 0.05 0.13 1.00
## 
## Mean item complexity =  1.6
## Test of the hypothesis that 5 factors are sufficient.
## 
## The degrees of freedom for the null model are  325  and the objective function was  16.29 with Chi Square of  1067.14
## The degrees of freedom for the model are 205  and the objective function was  4.76 
## 
## The root mean square of the residuals (RMSR) is  0.06 
## The df corrected root mean square of the residuals is  0.07 
## 
## The harmonic number of observations is  76 with the empirical chi square  165.44  with prob <  0.98 
## The total number of observations was  76  with MLE Chi Square =  295.73  with prob <  3.4e-05 
## 
## Tucker Lewis Index of factoring reliability =  0.791
## RMSEA index =  0.099  and the 90 % confidence intervals are  0.056 NA
## BIC =  -592.07
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy             
##                                                 MR1  MR5  MR2  MR4  MR3
## Correlation of scores with factors             0.95 0.93 0.94 0.88 0.87
## Multiple R square of scores with factors       0.91 0.87 0.89 0.77 0.76
## Minimum correlation of possible factor scores  0.82 0.75 0.78 0.54 0.52
Análise bi-fatorial exploratória
m5o <- omega(bd2[ , 58:83], nfactors = 5)

print.psych(m5o)
## Omega 
## Call: omega(m = bd2[, 58:83], nfactors = 5)
## Alpha:                 0.91 
## G.6:                   0.95 
## Omega Hierarchical:    0.71 
## Omega H asymptotic:    0.76 
## Omega Total            0.94 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##                 g   F1*   F2*   F3*   F4*   F5*   h2   u2   p2
## A.M. Port.   0.39              0.62             0.59 0.41 0.26
## A.M. Mat.    0.33              0.34  0.52       0.58 0.42 0.18
## A_0          0.41        0.30                   0.32 0.68 0.54
## C_0          0.59        0.32        0.23       0.52 0.48 0.66
## E_0          0.27        0.21  0.33             0.24 0.76 0.30
## N_0                                        0.77 0.61 0.39 0.01
## O_0          0.42        0.34                   0.36 0.64 0.48
## A_1          0.36        0.53                   0.43 0.57 0.31
## C_1          0.67        0.56        0.27       0.80 0.20 0.56
## E_1          0.28        0.37                   0.28 0.72 0.28
## N_1          0.29                          0.72 0.65 0.35 0.13
## O_1          0.48        0.45              0.20 0.56 0.44 0.42
## insmot       0.49  0.30                         0.36 0.64 0.67
## cstrat       0.67  0.35                         0.60 0.40 0.76
## memor        0.66  0.32                         0.55 0.45 0.79
## elab         0.67  0.37                         0.61 0.39 0.73
## effper       0.72  0.29                         0.65 0.35 0.80
## selfef       0.72  0.29                         0.66 0.34 0.77
## cexp         0.65  0.35                         0.56 0.44 0.76
## intrea       0.47        0.30  0.24             0.40 0.60 0.55
## intmat       0.58                    0.56       0.66 0.34 0.51
## comlrn                   0.35 -0.22             0.20 0.80 0.08
## coplrn       0.39                         -0.24 0.25 0.75 0.59
## scverb       0.41              0.50             0.44 0.56 0.38
## scmath       0.50                    0.80       0.90 0.10 0.28
## scacad       0.61  0.25        0.33             0.56 0.44 0.67
## 
## With eigenvalues of:
##    g  F1*  F2*  F3*  F4*  F5* 
## 6.53 0.88 1.63 1.30 1.55 1.34 
## 
## general/max  4.01   max/min =   1.84
## mean percent general =  0.48    with sd =  0.24 and cv of  0.5 
## Explained Common Variance of the general factor =  0.49 
## 
## The degrees of freedom are 205  and the fit is  4.61 
## The number of observations was  76  with Chi Square =  286.63  with prob <  0.00014
## The root mean square of the residuals is  0.06 
## The df corrected root mean square of the residuals is  0.07
## RMSEA index =  0.096  and the 90 % confidence intervals are  0.051 NA
## BIC =  -601.17
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 299  and the fit is  8.55 
## The number of observations was  76  with Chi Square =  554.29  with prob <  1.6e-17
## The root mean square of the residuals is  0.13 
## The df corrected root mean square of the residuals is  0.13 
## 
## RMSEA index =  0.124  and the 90 % confidence intervals are  0.092 NA
## BIC =  -740.6 
## 
## Measures of factor score adequacy             
##                                                  g   F1*  F2*  F3*  F4*
## Correlation of scores with factors            0.88  0.55 0.83 0.83 0.92
## Multiple R square of scores with factors      0.77  0.30 0.69 0.70 0.84
## Minimum correlation of factor score estimates 0.54 -0.40 0.37 0.39 0.69
##                                                F5*
## Correlation of scores with factors            0.88
## Multiple R square of scores with factors      0.77
## Minimum correlation of factor score estimates 0.54
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1*  F2*  F3*  F4*
## Omega total for total scores and subscales    0.94 0.89 0.83 0.73 0.85
## Omega general for total scores and subscales  0.71 0.71 0.45 0.34 0.30
## Omega group for total scores and subscales    0.12 0.17 0.38 0.39 0.54
##                                                F5*
## Omega total for total scores and subscales    0.56
## Omega general for total scores and subscales  0.14
## Omega group for total scores and subscales    0.42
Análise fatorial controlando idade
r <- partial.r(bd2[, c(60:85, 4)], x=1:26, y=27)
attr(r, "class") <- NULL
m5v2 <- fa(r, fm="minres", nfactors = 5)
print.psych(m5v2, cut = .30)
## Factor Analysis using method =  minres
## Call: fa(r = r, nfactors = 5, fm = "minres")
## Standardized loadings (pattern matrix) based upon correlation matrix
##              MR2   MR5   MR1   MR4   MR3   h2    u2 com
## A_0               0.46                   0.30 0.697 1.2
## C_0                                      0.41 0.592 3.7
## E_0               0.35                   0.22 0.781 2.5
## N_0                                 0.80 0.64 0.358 1.1
## O_0               0.58                   0.48 0.518 1.2
## A_1               0.74                   0.49 0.512 1.0
## C_1               0.65                   0.69 0.310 1.4
## E_1               0.57                   0.35 0.650 1.2
## N_1                                 0.73 0.64 0.360 1.3
## O_1               0.60                   0.52 0.484 1.4
## insmot      0.57                         0.38 0.622 1.2
## cstrat      0.73                         0.58 0.416 1.1
## memor       0.71                         0.53 0.469 1.0
## elab        0.78                         0.59 0.406 1.1
## effper      0.61                         0.63 0.373 1.4
## selfef      0.60                         0.63 0.371 1.4
## cexp        0.66                         0.54 0.458 1.1
## intrea            0.37                   0.36 0.635 3.2
## intmat                  0.61             0.58 0.422 1.3
## comlrn            0.32                   0.16 0.838 2.9
## coplrn                                   0.24 0.761 3.7
## scverb                        0.56       0.44 0.556 1.5
## scmath                  0.99             1.00 0.005 1.0
## scacad      0.56              0.41       0.56 0.444 1.9
## notas_port              0.56  0.37       0.54 0.459 2.0
## notas_mat                     0.67       0.57 0.431 1.2
## 
##                        MR2  MR5  MR1  MR4  MR3
## SS loadings           4.39 3.24 2.21 1.81 1.42
## Proportion Var        0.17 0.12 0.08 0.07 0.05
## Cumulative Var        0.17 0.29 0.38 0.45 0.50
## Proportion Explained  0.34 0.25 0.17 0.14 0.11
## Cumulative Proportion 0.34 0.58 0.75 0.89 1.00
## 
##  With factor correlations of 
##      MR2  MR5  MR1  MR4  MR3
## MR2 1.00 0.52 0.41 0.27 0.04
## MR5 0.52 1.00 0.12 0.20 0.19
## MR1 0.41 0.12 1.00 0.26 0.01
## MR4 0.27 0.20 0.26 1.00 0.12
## MR3 0.04 0.19 0.01 0.12 1.00
## 
## Mean item complexity =  1.7
## Test of the hypothesis that 5 factors are sufficient.
## 
## The degrees of freedom for the null model are  325  and the objective function was  15.42
## The degrees of freedom for the model are 205  and the objective function was  4.61 
## 
## The root mean square of the residuals (RMSR) is  0.06 
## The df corrected root mean square of the residuals is  0.07 
## 
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy             
##                                                 MR2  MR5  MR1  MR4  MR3
## Correlation of scores with factors             0.95 0.93 1.00 0.87 0.89
## Multiple R square of scores with factors       0.90 0.86 0.99 0.76 0.79
## Minimum correlation of possible factor scores  0.80 0.72 0.99 0.52 0.57