About

This is the R notebook for the paper:

Initial code

Load packages, set options, load data.

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

d = read.csv("data.csv", header = TRUE, row.names=1) #load data

Analyses

#G factor
c = d[c(1:3,5)] #cognitive data
(c.fa = fa(c))
## Factor Analysis using method =  minres
## Call: fa(r = c)
## Standardized loadings (pattern matrix) based upon correlation matrix
##              MR1   h2    u2 com
## Vernon.navy 0.93 0.87 0.131   1
## Vernon.army 0.73 0.53 0.470   1
## Douglas     0.96 0.92 0.075   1
## Davis       0.74 0.55 0.454   1
## 
##                 MR1
## SS loadings    2.87
## Proportion Var 0.72
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  6  and the objective function was  3.4 with Chi Square of  34
## The degrees of freedom for the model are 2  and the objective function was  0.25 
## 
## The root mean square of the residuals (RMSR) is  0.07 
## The df corrected root mean square of the residuals is  0.11 
## 
## The harmonic number of observations is  11 with the empirical chi square  0.57  with prob <  0.75 
## The total number of observations was  13  with Likelihood Chi Square =  2.3  with prob <  0.32 
## 
## Tucker Lewis Index of factoring reliability =  0.97
## RMSEA index =  0.011  and the 90 % confidence intervals are  NA 0.57
## BIC =  -2.9
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 MR1
## Correlation of scores with factors             0.98
## Multiple R square of scores with factors       0.95
## Minimum correlation of possible factor scores  0.90
#Transform to IQ scale
(c.desc = describe(c))
##             vars  n  mean  sd median trimmed  mad  min   max range  skew
## Vernon.navy    1 11 100.0 1.6  100.0   100.0 2.22 97.3 102.1  4.80 -0.16
## Vernon.army    2 11 100.0 2.2  101.2   100.0 2.37 96.6 103.0  6.40 -0.27
## Douglas        3 11 100.0 1.3  100.3   100.1 1.78 98.1 101.5  3.40 -0.20
## Davis          4 11   7.1 0.2    7.1     7.2 0.19  6.7   7.4  0.65 -0.47
##             kurtosis   se
## Vernon.navy    -1.61 0.50
## Vernon.army    -1.66 0.66
## Douglas        -1.74 0.39
## Davis          -0.87 0.06
inter.region.sd = c.desc$sd[1:3]

#Move to DF and correlate
c$G = as.numeric(c.fa$scores)*mean(c.desc$sd[1:3])+c.desc$mean[1:3]
## Warning in .Primitive("+")(x, y): longer object length is not a multiple of
## shorter object length
c[12,"G"] = d$Other[12]
c[13,"G"] = d$Other[13]
c$Lynn.mean = d$Mean
d$G = c$G

# S factor
s = d[7:13]
s.fa = fa(s)
s.fa
## Factor Analysis using method =  minres
## Call: fa(r = s)
## Standardized loadings (pattern matrix) based upon correlation matrix
##                    MR1   h2    u2 com
## Fellows.RS        0.91 0.83 0.170   1
## First.class       0.55 0.30 0.701   1
## Income            0.98 0.95 0.049   1
## Unemployment     -0.84 0.70 0.300   1
## Infant.mortality -0.67 0.45 0.551   1
## Crime             0.82 0.67 0.332   1
## Urbanization      0.86 0.75 0.253   1
## 
##                 MR1
## SS loadings    4.64
## Proportion Var 0.66
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  21  and the objective function was  8.8 with Chi Square of  78
## The degrees of freedom for the model are 14  and the objective function was  3 
## 
## The root mean square of the residuals (RMSR) is  0.13 
## The df corrected root mean square of the residuals is  0.16 
## 
## The harmonic number of observations is  13 with the empirical chi square  9.2  with prob <  0.81 
## The total number of observations was  13  with Likelihood Chi Square =  24  with prob <  0.042 
## 
## Tucker Lewis Index of factoring reliability =  0.7
## RMSEA index =  0.061  and the 90 % confidence intervals are  0.045 0.39
## BIC =  -12
## Fit based upon off diagonal values = 0.96
## Measures of factor score adequacy             
##                                                 MR1
## Correlation of scores with factors             0.99
## Multiple R square of scores with factors       0.97
## Minimum correlation of possible factor scores  0.94
s$S = as.numeric(s.fa$scores)

#G x S
s$G = c$G
(cors = wtd.cors(s))
##                  Fellows.RS First.class Income Unemployment
## Fellows.RS             1.00        0.58   0.87        -0.87
## First.class            0.58        1.00   0.54        -0.39
## Income                 0.87        0.54   1.00        -0.79
## Unemployment          -0.87       -0.39  -0.79         1.00
## Infant.mortality      -0.76       -0.68  -0.62         0.77
## Crime                  0.64        0.35   0.82        -0.68
## Urbanization           0.75        0.29   0.87        -0.65
## S                      0.92        0.55   0.99        -0.85
## G                      0.92        0.58   0.72        -0.78
##                  Infant.mortality Crime Urbanization     S     G
## Fellows.RS                  -0.76  0.64         0.75  0.92  0.92
## First.class                 -0.68  0.35         0.29  0.55  0.58
## Income                      -0.62  0.82         0.87  0.99  0.72
## Unemployment                 0.77 -0.68        -0.65 -0.85 -0.78
## Infant.mortality             1.00 -0.39        -0.34 -0.68 -0.69
## Crime                       -0.39  1.00         0.86  0.83  0.52
## Urbanization                -0.34  0.86         1.00  0.88  0.64
## S                           -0.68  0.83         0.88  1.00  0.79
## G                           -0.69  0.52         0.64  0.79  1.00
#plot
GG_scatter(s, "G", "S", case_names_vector = NA) +
  xlim(95, 103) +
  xlab("General intelligence") +
  ylab("General socioeconomic status")

silence(ggsave("G_S.png"))
  
#MCV
c$S = s$S
fa_Jensens_method(s.fa, s, "G", loading_reversing = T)
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("MCV.png"))