About

This is an R notebook for the study:

The paper was rewritten in March 2017, but without changing any analysis or any data. The reason for rewriting it was to make it more readable.

Initialize

Load packages, data.

#packages
library(pacman)
p_load(kirkegaard, VIM)
options(digits=2)

#data
cog = read.csv("Lynn_table1.csv",skip=2,header=TRUE,row.names = 1) #load cog data
socio = read.csv("Lynn_table2.csv",skip=2,header=TRUE,row.names = 1) #load socio data

#compare rownames
cbind(rownames(cog),rownames(socio))
##       [,1]                [,2]               
##  [1,] "Andhra Pradesh"    "Andhra Pradesh"   
##  [2,] "Arunachal Pradesh" "Arunachal Pradesh"
##  [3,] "Bihar"             "Bihar"            
##  [4,] "Chattisgarh"       "Chattisgarh"      
##  [5,] "Goa"               "Goa"              
##  [6,] "Gujarat"           "Gujarat"          
##  [7,] "Haryana"           "Haryana"          
##  [8,] "Himanchal Pradesh" "Himanchal Pradesh"
##  [9,] "Jammu Kashmir"     "Jammu & Kashmir"  
## [10,] "Jharkhand"         "Jharkhand"        
## [11,] "Karnataka"         "Karnataka"        
## [12,] "Kerala"            "Kerala"           
## [13,] "Madhya Pradesh"    "Madhya Pradesh"   
## [14,] "Maharashtra"       "Maharashtra"      
## [15,] "Manipur"           "Manipur"          
## [16,] "Meghalaya"         "Meghalaya"        
## [17,] "Mizoram"           "Mizoram"          
## [18,] "Nagaland"          "Nagaland"         
## [19,] "Odisha"            "Odisha"           
## [20,] "Punjab"            "Punjab"           
## [21,] "Rajashthan"        "Rajasthan"        
## [22,] "Sikkim"            "Sikkim"           
## [23,] "Tamil Nadu"        "TamilNadu"        
## [24,] "Tripura"           "Tripura"          
## [25,] "Uttarkhand"        "Uttarkhand"       
## [26,] "Uttar Pradesh"     "Uttar Pradesh"    
## [27,] "West Bengal"       "West Bengal"      
## [28,] "A & N Islands"     "A & N Islands"    
## [29,] "Chandigarh"        "Chandigarh"       
## [30,] "D & N Haveli"      "D & N Haveli"     
## [31,] "Daman & Diu"       "Daman & Diu"      
## [32,] "Delhi"             "Delhi"            
## [33,] "Puducherry"        "Puducherry"
#all match, but differ in exact spelling, rename
rownames(cog) = rownames(socio) #use rownames from socio for cog

Missing data

Analyze missing data, impute, merge.

#examine missing data
miss_by_case(socio)
##    Andhra Pradesh Arunachal Pradesh             Bihar       Chattisgarh 
##                 0                 0                 0                 0 
##               Goa           Gujarat           Haryana Himanchal Pradesh 
##                 0                 0                 0                 0 
##   Jammu & Kashmir         Jharkhand         Karnataka            Kerala 
##                 0                 0                 0                 0 
##    Madhya Pradesh       Maharashtra           Manipur         Meghalaya 
##                 0                 0                 0                 0 
##           Mizoram          Nagaland            Odisha            Punjab 
##                 0                 0                 0                 0 
##         Rajasthan            Sikkim         TamilNadu           Tripura 
##                 0                 0                 0                 0 
##        Uttarkhand     Uttar Pradesh       West Bengal     A & N Islands 
##                 0                 0                 0                 2 
##        Chandigarh      D & N Haveli       Daman & Diu             Delhi 
##                 1                 2                 2                 1 
##        Puducherry 
##                 2
miss_amount(socio)
## cases with missing data  vars with missing data cells with missing data 
##                   0.180                   0.180                   0.028
miss_by_case(cog)
##    Andhra Pradesh Arunachal Pradesh             Bihar       Chattisgarh 
##                 0                 0                 0                 0 
##               Goa           Gujarat           Haryana Himanchal Pradesh 
##                 0                 0                 0                 0 
##   Jammu & Kashmir         Jharkhand         Karnataka            Kerala 
##                 0                 0                 0                 0 
##    Madhya Pradesh       Maharashtra           Manipur         Meghalaya 
##                 0                 0                 0                 0 
##           Mizoram          Nagaland            Odisha            Punjab 
##                 0                 0                 0                 0 
##         Rajasthan            Sikkim         TamilNadu           Tripura 
##                 0                 0                 0                 0 
##        Uttarkhand     Uttar Pradesh       West Bengal     A & N Islands 
##                 0                 0                 0                 0 
##        Chandigarh      D & N Haveli       Daman & Diu             Delhi 
##                 0                 0                 0                 0 
##        Puducherry 
##                 0
table(miss_by_case(socio))
## 
##  0  1  2 
## 27  2  4
matrixplot(socio)

#impute data
socio2 = irmi(socio, noise.factor = 0) #no noise
rownames(socio2) = rownames(socio)

#compare desc stats
describe(socio)
##     vars  n    mean      sd  median trimmed     mad     min     max
## Lit    1 33 7.8e+01 8.0e+00 7.9e+01 7.8e+01 1.0e+01 6.4e+01 9.4e+01
## II     2 33 6.3e-01 1.4e-01 6.6e-01 6.5e-01 1.2e-01 2.1e-01 8.4e-01
## TI     3 33 7.3e-01 1.8e-01 7.8e-01 7.5e-01 2.1e-01 2.6e-01 9.9e-01
## GDP    4 27 2.5e+04 1.1e+04 2.3e+04 2.4e+04 1.0e+04 1.0e+04 6.0e+04
## IMR    5 33 4.4e+01 1.6e+01 4.2e+01 4.4e+01 1.4e+01 1.5e+01 7.3e+01
## CMR    6 29 1.5e+01 8.7e+00 1.2e+01 1.5e+01 9.3e+00 1.0e+00 2.9e+01
## FER    7 33 2.1e+00 5.1e-01 2.0e+00 2.1e+00 3.0e-01 1.7e+00 3.5e+00
## LE     8 33 7.0e+01 1.2e+01 7.2e+01 7.2e+01 3.1e+00 7.3e+00 7.9e+01
## LAT    9 33 2.3e+01 6.4e+00 2.3e+01 2.3e+01 5.5e+00 8.5e+00 3.3e+01
## CL    10 33 6.4e-01 4.9e-01 1.0e+00 6.7e-01 0.0e+00 0.0e+00 1.0e+00
## MS    11 33 9.8e+00 1.2e+01 7.8e+00 7.7e+00 5.9e+00 1.1e+00 6.7e+01
##       range  skew kurtosis      se
## Lit 3.0e+01 -0.03    -1.08    1.38
## II  6.3e-01 -0.97     0.80    0.02
## TI  7.2e-01 -0.69    -0.34    0.03
## GDP 5.0e+04  1.21     1.95 2072.72
## IMR 5.7e+01  0.21    -0.84    2.74
## CMR 2.8e+01  0.31    -1.49    1.62
## FER 1.8e+00  1.32     0.46    0.09
## LE  7.2e+01 -4.52    21.27    2.06
## LAT 2.5e+01 -0.49    -0.69    1.12
## CL  1.0e+00 -0.54    -1.76    0.09
## MS  6.6e+01  3.60    14.86    2.03
describe(socio2)
##     vars  n    mean      sd  median trimmed     mad     min     max
## Lit    1 33 7.8e+01 8.0e+00 7.9e+01 7.8e+01 1.0e+01 6.4e+01 9.4e+01
## II     2 33 6.3e-01 1.4e-01 6.6e-01 6.5e-01 1.2e-01 2.1e-01 8.4e-01
## TI     3 33 7.3e-01 1.8e-01 7.8e-01 7.5e-01 2.1e-01 2.6e-01 9.9e-01
## GDP    4 33 2.7e+04 1.1e+04 2.6e+04 2.6e+04 1.2e+04 1.0e+04 6.0e+04
## IMR    5 33 4.4e+01 1.6e+01 4.2e+01 4.4e+01 1.4e+01 1.5e+01 7.3e+01
## CMR    6 33 1.4e+01 8.7e+00 1.1e+01 1.4e+01 8.2e+00 1.0e+00 2.9e+01
## FER    7 33 2.1e+00 5.1e-01 2.0e+00 2.1e+00 3.0e-01 1.7e+00 3.5e+00
## LE     8 33 7.0e+01 1.2e+01 7.2e+01 7.2e+01 3.1e+00 7.3e+00 7.9e+01
## LAT    9 33 2.3e+01 6.4e+00 2.3e+01 2.3e+01 5.5e+00 8.5e+00 3.3e+01
## CL    10 33 6.4e-01 4.9e-01 1.0e+00 6.7e-01 0.0e+00 0.0e+00 1.0e+00
## MS    11 33 9.8e+00 1.2e+01 7.8e+00 7.7e+00 5.9e+00 1.1e+00 6.7e+01
##       range  skew kurtosis      se
## Lit 3.0e+01 -0.03    -1.08    1.38
## II  6.3e-01 -0.97     0.80    0.02
## TI  7.2e-01 -0.69    -0.34    0.03
## GDP 5.0e+04  0.74     0.84 1850.19
## IMR 5.7e+01  0.21    -0.84    2.74
## CMR 2.8e+01  0.44    -1.35    1.51
## FER 1.8e+00  1.32     0.46    0.09
## LE  7.2e+01 -4.52    21.27    2.06
## LAT 2.5e+01 -0.49    -0.69    1.12
## CL  1.0e+00 -0.54    -1.76    0.09
## MS  6.6e+01  3.60    14.86    2.03
describe(socio) - describe(socio2) #discrepancy values, rounded
##     vars  n     mean      sd  median trimmed     mad min max range  skew
## Lit    0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## II     0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## TI     0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## GDP    0 -6 -1822.67 141.659 -3247.1 -2321.5 -1970.5   0   0     0  0.46
## IMR    0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## CMR    0 -4     0.92   0.054     0.8     1.2     1.2   0   0     0 -0.13
## FER    0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## LE     0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## LAT    0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## CL     0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
## MS     0  0     0.00   0.000     0.0     0.0     0.0   0   0     0  0.00
##     kurtosis     se
## Lit     0.00   0.00
## II      0.00   0.00
## TI      0.00   0.00
## GDP     1.10 222.53
## IMR     0.00   0.00
## CMR    -0.14   0.11
## FER     0.00   0.00
## LE      0.00   0.00
## LAT     0.00   0.00
## CL      0.00   0.00
## MS      0.00   0.00
#merge data
data = merge_datasets(cog, socio2) # merge above

Main analyses

Main analyses.

#cognitive data
fa = fa(data[1:5])
fa
## Factor Analysis using method =  minres
## Call: fa(r = data[1:5])
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1     h2   u2 com
## T1 0.40 0.1568 0.84   1
## T2 0.10 0.0096 0.99   1
## T3 0.46 0.2077 0.79   1
## T4 0.93 0.8621 0.14   1
## T5 0.92 0.8399 0.16   1
## 
##                 MR1
## SS loadings    2.08
## Proportion Var 0.42
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  10  and the objective function was  2.9 with Chi Square of  86
## The degrees of freedom for the model are 5  and the objective function was  1.1 
## 
## The root mean square of the residuals (RMSR) is  0.21 
## The df corrected root mean square of the residuals is  0.29 
## 
## The harmonic number of observations is  33 with the empirical chi square  28  with prob <  3.3e-05 
## The total number of observations was  33  with Likelihood Chi Square =  33  with prob <  3.4e-06 
## 
## Tucker Lewis Index of factoring reliability =  0.23
## RMSEA index =  0.18  and the 90 % confidence intervals are  0.18 0.55
## BIC =  16
## Fit based upon off diagonal values = 0.78
## Measures of factor score adequacy             
##                                                 MR1
## Correlation of scores with factors             0.96
## Multiple R square of scores with factors       0.92
## Minimum correlation of possible factor scores  0.83
data["G"] = as.numeric(fa$scores)

#S data
fa2 = fa(data[7:14])
fa2
## Factor Analysis using method =  minres
## Call: fa(r = data[7:14])
## Standardized loadings (pattern matrix) based upon correlation matrix
##       MR1    h2   u2 com
## Lit  0.79 0.626 0.37   1
## II   0.36 0.130 0.87   1
## TI   0.89 0.799 0.20   1
## GDP  0.76 0.578 0.42   1
## IMR -0.92 0.850 0.15   1
## CMR -0.85 0.721 0.28   1
## FER -0.84 0.699 0.30   1
## LE   0.14 0.019 0.98   1
## 
##                 MR1
## SS loadings    4.42
## Proportion Var 0.55
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  28  and the objective function was  6.2 with Chi Square of  177
## The degrees of freedom for the model are 20  and the objective function was  1.2 
## 
## The root mean square of the residuals (RMSR) is  0.09 
## The df corrected root mean square of the residuals is  0.1 
## 
## The harmonic number of observations is  33 with the empirical chi square  13  with prob <  0.86 
## The total number of observations was  33  with Likelihood Chi Square =  33  with prob <  0.038 
## 
## Tucker Lewis Index of factoring reliability =  0.88
## RMSEA index =  0.02  and the 90 % confidence intervals are  0.02 0.22
## BIC =  -37
## Fit based upon off diagonal values = 0.98
## Measures of factor score adequacy             
##                                                 MR1
## Correlation of scores with factors             0.97
## Multiple R square of scores with factors       0.95
## Minimum correlation of possible factor scores  0.89
data["S"] = as.numeric(fa2$scores)

#Pearson results
(data_cors = wtd.cors(data))
##         T1     T2     T3     T4     T5    CA   Lit     II     TI    GDP
## T1   1.000  0.049  0.411  0.352  0.344  0.65  0.51  0.525  0.276  0.503
## T2   0.049  1.000  0.640 -0.028  0.146  0.42 -0.19  0.092 -0.491 -0.365
## T3   0.411  0.640  1.000  0.411  0.376  0.73  0.29  0.242  0.023  0.195
## T4   0.352 -0.028  0.411  1.000  0.871  0.80  0.71  0.356  0.442  0.425
## T5   0.344  0.146  0.376  0.871  1.000  0.80  0.53  0.480  0.398  0.316
## CA   0.654  0.422  0.728  0.796  0.804  1.00  0.56  0.524  0.172  0.332
## Lit  0.507 -0.193  0.288  0.713  0.534  0.56  1.00  0.326  0.615  0.539
## II   0.525  0.092  0.242  0.356  0.480  0.52  0.33  1.000  0.277  0.422
## TI   0.276 -0.491  0.023  0.442  0.398  0.17  0.62  0.277  1.000  0.717
## GDP  0.503 -0.365  0.195  0.425  0.316  0.33  0.54  0.422  0.717  1.000
## IMR -0.359  0.337 -0.179 -0.638 -0.530 -0.40 -0.81 -0.277 -0.810 -0.719
## CMR -0.436  0.160 -0.270 -0.520 -0.511 -0.41 -0.66 -0.541 -0.786 -0.661
## FER -0.277  0.362 -0.093 -0.594 -0.513 -0.31 -0.69 -0.118 -0.798 -0.549
## LE  -0.190 -0.044  0.066  0.021  0.011 -0.03  0.13 -0.147  0.154  0.037
## LAT -0.266  0.143 -0.142 -0.548 -0.478 -0.44 -0.31 -0.289 -0.308 -0.335
## CL  -0.404  0.169 -0.224 -0.612 -0.600 -0.50 -0.33 -0.428 -0.497 -0.594
## MS  -0.335  0.246  0.037 -0.282 -0.175 -0.33 -0.28 -0.264 -0.031 -0.230
## G    0.414  0.102  0.476  0.970  0.957  0.87  0.66  0.446  0.425  0.401
## S    0.421 -0.371  0.183  0.632  0.543  0.40  0.81  0.370  0.919  0.781
##       IMR    CMR    FER     LE    LAT     CL     MS      G      S
## T1  -0.36 -0.436 -0.277 -0.190 -0.266 -0.404 -0.335  0.414  0.421
## T2   0.34  0.160  0.362 -0.044  0.143  0.169  0.246  0.102 -0.371
## T3  -0.18 -0.270 -0.093  0.066 -0.142 -0.224  0.037  0.476  0.183
## T4  -0.64 -0.520 -0.594  0.021 -0.548 -0.612 -0.282  0.970  0.632
## T5  -0.53 -0.511 -0.513  0.011 -0.478 -0.600 -0.175  0.957  0.543
## CA  -0.40 -0.412 -0.315 -0.030 -0.436 -0.502 -0.325  0.867  0.402
## Lit -0.81 -0.657 -0.690  0.128 -0.309 -0.329 -0.282  0.661  0.813
## II  -0.28 -0.541 -0.118 -0.147 -0.289 -0.428 -0.264  0.446  0.370
## TI  -0.81 -0.786 -0.798  0.154 -0.308 -0.497 -0.031  0.425  0.919
## GDP -0.72 -0.661 -0.549  0.037 -0.335 -0.594 -0.230  0.401  0.781
## IMR  1.00  0.744  0.761 -0.176  0.342  0.473  0.118 -0.604 -0.947
## CMR  0.74  1.000  0.718 -0.074  0.287  0.542 -0.146 -0.543 -0.872
## FER  0.76  0.718  1.000 -0.059  0.227  0.425  0.016 -0.564 -0.859
## LE  -0.18 -0.074 -0.059  1.000  0.036  0.154 -0.070  0.012  0.142
## LAT  0.34  0.287  0.227  0.036  1.000  0.785  0.198 -0.528 -0.348
## CL   0.47  0.542  0.425  0.154  0.785  1.000  0.009 -0.628 -0.541
## MS   0.12 -0.146  0.016 -0.070  0.198  0.009  1.000 -0.240 -0.086
## G   -0.60 -0.543 -0.564  0.012 -0.528 -0.628 -0.240  1.000  0.610
## S   -0.95 -0.872 -0.859  0.142 -0.348 -0.541 -0.086  0.610  1.000
(data_cors_spearman = cor_matrix(data, rank_order = T))
##         T1     T2     T3     T4    T5     CA   Lit      II     TI   GDP
## T1   1.000  0.049  0.411  0.352  0.34  0.592  0.50  0.5158  0.309  0.53
## T2   0.049  1.000  0.640 -0.028  0.15  0.474 -0.16 -0.0239 -0.365 -0.38
## T3   0.411  0.640  1.000  0.411  0.38  0.719  0.31  0.1517  0.079  0.17
## T4   0.352 -0.028  0.411  1.000  0.87  0.788  0.73  0.3501  0.429  0.43
## T5   0.344  0.146  0.376  0.871  1.00  0.795  0.55  0.4686  0.438  0.39
## CA   0.592  0.474  0.719  0.788  0.80  1.000  0.55  0.3998  0.179  0.27
## Lit  0.500 -0.157  0.311  0.726  0.55  0.552  1.00  0.3570  0.561  0.53
## II   0.516 -0.024  0.152  0.350  0.47  0.400  0.36  1.0000  0.452  0.54
## TI   0.309 -0.365  0.079  0.429  0.44  0.179  0.56  0.4515  1.000  0.75
## GDP  0.527 -0.382  0.166  0.429  0.39  0.271  0.53  0.5404  0.754  1.00
## IMR -0.381  0.271 -0.243 -0.633 -0.54 -0.427 -0.79 -0.3934 -0.725 -0.69
## CMR -0.452  0.140 -0.288 -0.519 -0.51 -0.419 -0.68 -0.5650 -0.789 -0.68
## FER -0.409  0.223 -0.068 -0.528 -0.50 -0.382 -0.62 -0.2734 -0.693 -0.54
## LE   0.171 -0.203  0.169  0.476  0.38  0.274  0.70  0.1034  0.542  0.38
## LAT -0.251  0.077 -0.193 -0.523 -0.43 -0.429 -0.25 -0.2228 -0.246 -0.27
## CL  -0.404  0.169 -0.224 -0.612 -0.60 -0.493 -0.33 -0.4400 -0.539 -0.62
## MS  -0.033  0.227 -0.071 -0.217 -0.11 -0.038 -0.23 -0.0029 -0.097 -0.23
## G    0.380  0.069  0.444  0.971  0.94  0.840  0.67  0.4080  0.413  0.42
## S    0.486 -0.301  0.227  0.600  0.54  0.401  0.80  0.5511  0.875  0.81
##       IMR    CMR    FER     LE    LAT    CL      MS      G     S
## T1  -0.38 -0.452 -0.409  0.171 -0.251 -0.40 -0.0330  0.380  0.49
## T2   0.27  0.140  0.223 -0.203  0.077  0.17  0.2272  0.069 -0.30
## T3  -0.24 -0.288 -0.068  0.169 -0.193 -0.22 -0.0711  0.444  0.23
## T4  -0.63 -0.519 -0.528  0.476 -0.523 -0.61 -0.2172  0.971  0.60
## T5  -0.54 -0.507 -0.503  0.376 -0.435 -0.60 -0.1062  0.937  0.54
## CA  -0.43 -0.419 -0.382  0.274 -0.429 -0.49 -0.0383  0.840  0.40
## Lit -0.79 -0.682 -0.619  0.700 -0.248 -0.33 -0.2276  0.675  0.80
## II  -0.39 -0.565 -0.273  0.103 -0.223 -0.44 -0.0029  0.408  0.55
## TI  -0.73 -0.789 -0.693  0.542 -0.246 -0.54 -0.0968  0.413  0.88
## GDP -0.69 -0.676 -0.535  0.383 -0.274 -0.62 -0.2285  0.420  0.81
## IMR  1.00  0.704  0.612 -0.762  0.248  0.43  0.2949 -0.611 -0.90
## CMR  0.70  1.000  0.735 -0.481  0.249  0.54 -0.0881 -0.533 -0.88
## FER  0.61  0.735  1.000 -0.423  0.188  0.47 -0.0070 -0.509 -0.74
## LE  -0.76 -0.481 -0.423  1.000 -0.034 -0.10 -0.3038  0.425  0.67
## LAT  0.25  0.249  0.188 -0.034  1.000  0.79 -0.1384 -0.546 -0.25
## CL   0.43  0.543  0.467 -0.103  0.787  1.00 -0.2018 -0.635 -0.50
## MS   0.29 -0.088 -0.007 -0.304 -0.138 -0.20  1.0000 -0.158 -0.20
## G   -0.61 -0.533 -0.509  0.425 -0.546 -0.64 -0.1579  1.000  0.58
## S   -0.90 -0.883 -0.743  0.669 -0.249 -0.50 -0.2009  0.584  1.00
#discrepancies
(r_disc = data_cors - data_cors_spearman)
##           T1       T2       T3       T4       T5       CA      Lit
## T1   1.7e-14  0.0e+00  0.0e+00  0.0e+00  0.0e+00  6.2e-02  7.1e-03
## T2   4.6e-14  1.3e-15  0.0e+00  0.0e+00  0.0e+00 -5.2e-02 -3.7e-02
## T3   4.9e-14  0.0e+00 -4.4e-14  0.0e+00  0.0e+00  9.0e-03 -2.3e-02
## T4   0.0e+00  0.0e+00 -7.2e-14  1.2e-14  0.0e+00  7.8e-03 -1.3e-02
## T5   4.6e-14  0.0e+00  0.0e+00  0.0e+00 -6.5e-14  8.5e-03 -1.2e-02
## CA   6.2e-02 -5.2e-02  9.0e-03  7.8e-03  8.5e-03  2.8e-14  1.1e-02
## Lit  7.1e-03 -3.7e-02 -2.3e-02 -1.3e-02 -1.2e-02  1.1e-02 -3.5e-14
## II   9.1e-03  1.2e-01  9.1e-02  6.2e-03  1.2e-02  1.2e-01 -3.1e-02
## TI  -3.3e-02 -1.3e-01 -5.6e-02  1.3e-02 -4.0e-02 -7.2e-03  5.4e-02
## GDP -2.4e-02  1.7e-02  2.9e-02 -4.8e-03 -7.3e-02  6.1e-02  1.0e-02
## IMR  2.1e-02  6.6e-02  6.4e-02 -4.8e-03  8.5e-03  2.8e-02 -1.7e-02
## CMR  1.6e-02  2.0e-02  1.8e-02 -4.2e-04 -3.6e-03  7.3e-03  2.5e-02
## FER  1.3e-01  1.4e-01 -2.6e-02 -6.6e-02 -9.9e-03  6.7e-02 -7.1e-02
## LE  -3.6e-01  1.6e-01 -1.0e-01 -4.6e-01 -3.6e-01 -3.0e-01 -5.7e-01
## LAT -1.5e-02  6.6e-02  5.1e-02 -2.6e-02 -4.3e-02 -6.7e-03 -6.1e-02
## CL   0.0e+00  0.0e+00  0.0e+00  0.0e+00  0.0e+00 -9.0e-03  1.7e-03
## MS  -3.0e-01  1.8e-02  1.1e-01 -6.5e-02 -6.8e-02 -2.9e-01 -5.4e-02
## G    3.3e-02  3.3e-02  3.2e-02 -1.5e-03  2.1e-02  2.7e-02 -1.3e-02
## S   -6.5e-02 -7.1e-02 -4.4e-02  3.3e-02  5.3e-03  1.8e-03  1.3e-02
##           II       TI      GDP      IMR      CMR      FER       LE
## T1   9.1e-03 -3.3e-02 -2.4e-02  2.1e-02  1.6e-02  1.3e-01 -3.6e-01
## T2   1.2e-01 -1.3e-01  1.7e-02  6.6e-02  2.0e-02  1.4e-01  1.6e-01
## T3   9.1e-02 -5.6e-02  2.9e-02  6.4e-02  1.8e-02 -2.6e-02 -1.0e-01
## T4   6.2e-03  1.3e-02 -4.8e-03 -4.8e-03 -4.2e-04 -6.6e-02 -4.6e-01
## T5   1.2e-02 -4.0e-02 -7.3e-02  8.5e-03 -3.6e-03 -9.9e-03 -3.6e-01
## CA   1.2e-01 -7.2e-03  6.1e-02  2.8e-02  7.3e-03  6.7e-02 -3.0e-01
## Lit -3.1e-02  5.4e-02  1.0e-02 -1.7e-02  2.5e-02 -7.1e-02 -5.7e-01
## II   2.2e-16 -1.7e-01 -1.2e-01  1.2e-01  2.4e-02  1.5e-01 -2.5e-01
## TI  -1.7e-01 -5.1e-15 -3.6e-02 -8.5e-02  2.7e-03 -1.0e-01 -3.9e-01
## GDP -1.2e-01 -3.6e-02 -5.6e-16 -2.5e-02  1.5e-02 -1.3e-02 -3.5e-01
## IMR  1.2e-01 -8.5e-02 -2.5e-02 -2.7e-15  4.1e-02  1.5e-01  5.9e-01
## CMR  2.4e-02  2.7e-03  1.5e-02  4.1e-02  6.7e-16 -1.7e-02  4.1e-01
## FER  1.5e-01 -1.0e-01 -1.3e-02  1.5e-01 -1.7e-02  5.6e-15  3.6e-01
## LE  -2.5e-01 -3.9e-01 -3.5e-01  5.9e-01  4.1e-01  3.6e-01 -1.2e-14
## LAT -6.6e-02 -6.2e-02 -6.1e-02  9.4e-02  3.8e-02  3.9e-02  7.0e-02
## CL   1.2e-02  4.3e-02  2.4e-02  4.3e-02 -5.7e-04 -4.3e-02  2.6e-01
## MS  -2.6e-01  6.6e-02 -1.4e-03 -1.8e-01 -5.8e-02  2.3e-02  2.3e-01
## G    3.8e-02  1.2e-02 -1.9e-02  6.9e-03 -9.6e-03 -5.5e-02 -4.1e-01
## S   -1.8e-01  4.3e-02 -3.2e-02 -4.5e-02  1.1e-02 -1.2e-01 -5.3e-01
##          LAT       CL       MS        G       S
## T1  -1.5e-02  0.0e+00 -3.0e-01  3.3e-02 -0.0648
## T2   6.6e-02  0.0e+00  1.8e-02  3.3e-02 -0.0707
## T3   5.1e-02  0.0e+00  1.1e-01  3.2e-02 -0.0438
## T4  -2.6e-02  0.0e+00 -6.5e-02 -1.5e-03  0.0325
## T5  -4.3e-02  0.0e+00 -6.8e-02  2.1e-02  0.0053
## CA  -6.7e-03 -9.0e-03 -2.9e-01  2.7e-02  0.0018
## Lit -6.1e-02  1.7e-03 -5.4e-02 -1.3e-02  0.0134
## II  -6.6e-02  1.2e-02 -2.6e-01  3.8e-02 -0.1809
## TI  -6.2e-02  4.3e-02  6.6e-02  1.2e-02  0.0433
## GDP -6.1e-02  2.4e-02 -1.4e-03 -1.9e-02 -0.0323
## IMR  9.4e-02  4.3e-02 -1.8e-01  6.9e-03 -0.0446
## CMR  3.8e-02 -5.7e-04 -5.8e-02 -9.6e-03  0.0107
## FER  3.9e-02 -4.3e-02  2.3e-02 -5.5e-02 -0.1161
## LE   7.0e-02  2.6e-01  2.3e-01 -4.1e-01 -0.5268
## LAT  2.2e-15 -2.1e-03  3.4e-01  1.7e-02 -0.0987
## CL  -2.1e-03  4.4e-16  2.1e-01  7.1e-03 -0.0378
## MS   3.4e-01  2.1e-01  6.7e-16 -8.2e-02  0.1147
## G    1.7e-02  7.1e-03 -8.2e-02  2.2e-16  0.0258
## S   -9.9e-02 -3.8e-02  1.1e-01  2.6e-02  0.0000
## MCV
#MCV on G
fa_Jensens_method(fa, data, criterion = "S", loading_reversing = F)
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("MCV_G.png"))

#MCV on S
fa_Jensens_method(fa2, data, criterion = "G", loading_reversing = F)
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("MCV_S.png"))

#Double MCV
#cor(results$r[1:14, 18], results$r[1:14, 19])
data_frame(
  G_cors = data_cors[1:14, 18],
  S_cors = data_cors[1:14, 19],
  var = names(data)[1:14]
) %>% 
  GG_scatter("G_cors", "S_cors", case_names_vector = "var") +
  xlab("G x variable correlation") +
  ylab("S x variable correlation")

silence(ggsave("double_MCV.png"))


#Plots
GG_scatter(data, "G", "S") +
  xlab("G, extracted from 5 indicators") +
  ylab("S, extracted from 11 indicates") +
  xlim(-2, 2)
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_text).

silence(ggsave("G_S.png"))