About

This is the R notebook for the study:

Purpose A few old studies attempted to find the biological bases of cognitive ability. One plausible candidate – nerve conduction velocity – was examined in two small studies, with ‘conflicting’ results. Conflicting in the sense that one study found p < alpha and the other did not, which is not a real sign of incongruency of results. In the present study, we attempt to resolve the question about whether nerve conduction velocity is related to cognitive ability. The present study is about 100 times larger than the previous two studies.

Setup

First load the data and decide on settings.

library(pacman)
p_load(kirkegaard, readr, dplyr, haven, lavaan, rms)
options(digits = 2)

#load data
d = read_rds("data/VES_dataset.rds")

#rename variables
d %<>% rename(
  #NCV
  MED_MOTOR_NCV = NC01012,
  MED_SENSORY_DL_NCV = NC01018,
  MED_SENSORY_PL_NCV = NC01019,
  ULN_SENSORY_NCV = NC01023,
  PER_MOTOR_NCV = NC01028,
  SUR_SENSORY_NCV = NC01032,
  
  #temperature
  TEMP_ULIMB_SIDE_TEST = NC01033,
  TEMP_ULIMB_PALM = NC01034,
  TEMP_ULIMB_FOREARM = NC01035,
  TEMP_LLIMB_SIDE_TEST = NC01036,
  TEMP_LLIMB_FOOT = NC01037,
  TEMP_LLIMB_UPPER_CALF = NC01038,
  
  #fix WAIS-Inf name
  WAIS_Inf = WAIS_GI
)

#variable collections
g_tests = c("WRAT", "CVLT", "WCST", "WAIS_BD", "WAIS_Inf", "copy_direct", "copy_immediate", "copy_delayed", "PASAT", "GPT_left", "GPT_right", "WLGT", "ACB_verbal_early", "ACB_verbal_later", "ACB_arithmetic_early", "ACB_arithmetic_later", "PA", "GIT", "AFQT")
g_tests_noGPT = c("WRAT", "CVLT", "WCST", "WAIS_BD", "WAIS_Inf", "copy_direct", "copy_immediate", "copy_delayed", "PASAT", "WLGT", "ACB_verbal_early", "ACB_verbal_later", "ACB_arithmetic_early", "ACB_arithmetic_later", "PA", "GIT", "AFQT")
g_tests_early = c("ACB_verbal_early", "ACB_arithmetic_early", "AFQT", "GIT", "PA")
g_tests_later = setdiff(g_tests, g_tests_early)
ncv_tests = names(d) %>% str_filter("_NCV$")
temp_vars = names(d) %>% str_subset("TEMP_")

exploratory_vars = c("education", "income", "unemployment_3yrs", "height", "weight", "BMI")

#collect control variables
control_vars = c(temp_vars, "race", "AGE", "test_time")
control_vars_noSIRE = c(temp_vars, "AGE", "test_time")

#assert variables present
setdiff(c(g_tests, ncv_tests, exploratory_vars, control_vars), names(d))
## character(0)
#subset data
d_orig = d
d = d[c(g_tests,
        ncv_tests,
        exploratory_vars,
        control_vars
        )]

Missing data

There may be some missing data. If so, this has to be dealt with.

#amount
miss_amount(d)
## cases with missing data  vars with missing data cells with missing data 
##                  0.1000                  0.6800                  0.0044
miss_plot(d, reverse = F)

miss_plot(d, reverse = T)

#impute
d = silence(miss_impute(d)) %>% as_tibble()

#assert
assertthat::noNA(d)
## [1] TRUE

Descriptive

Description of the data.

#SIRE
table2(d$race) %>% write_clipboard()
##      Group   Count Percent
## 1    White 3654.00   81.89
## 2    Black  525.00   11.77
## 3 Hispanic  200.00    4.48
## 4   Native   49.00    1.10
## 5    Asian   34.00    0.76
## 6             0.00    0.00
#age
GG_denhist(d, "AGE")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

describe(d$AGE)
##    vars    n mean  sd median trimmed mad min max range skew kurtosis   se
## X1    1 4462   38 2.5     38      38   3  31  49    18 0.14    -0.01 0.04

Adjust variables for test context variables

Relationships between variables of interest may be obscured by confounders. Here we adjust for some possible confounders.

#function to adjust with
do_adjust = function(df, vars=NULL, control_vars=NULL, keep_mean = F, std_resid = T) {
  df
  
  #if no vars or no control vars, return df as is
  if (is.null(vars) | is.null(control_vars)) return(df)
  
  #variables not in data frame
  for (v in c(vars, control_vars)) {
    if (!v %in% names(df)) {
      stop(sprintf("Variable not found: `v`"))
    }
  }
  
  #overlap in variables
  if (length(intersect(vars, control_vars)) != 0) {
    stop("Cannot control a variable for itself")
  }

  #loop over vars
  for (v in vars) {
    #subset data
    df_sub = df[c(v, control_vars)]

    #regress
    fit = lm(sprintf("%s ~ .", v), data = df_sub, na.action = na.exclude)
    
    #save resid
    if (std_resid) {
      df[[v]] = resid(fit) %>% standardize
    } else {
      #keep mean
      if (keep_mean) {
        df[[v]] = resid(fit) + wtd_mean(df[[v]] %>% as.vector)
      } else {
        df[[v]] = resid(fit)
      }
    }
  }
  
  df
}

#before adjusting, we examine the zero-order correlations between variables of interest
wtd.cors(d[c(g_tests, ncv_tests, control_vars)])
## Warning in wtd.cors(d[c(g_tests, ncv_tests, control_vars)]): NAs introduced
## by coercion

## Warning in wtd.cors(d[c(g_tests, ncv_tests, control_vars)]): NAs introduced
## by coercion
##                          WRAT    CVLT    WCST WAIS_BD WAIS_Inf copy_direct
## WRAT                   1.0000  0.3101  0.2925  0.3830   0.6520      0.2700
## CVLT                   0.3101  1.0000  0.1921  0.2685   0.3293      0.2052
## WCST                   0.2925  0.1921  1.0000  0.3564   0.3302      0.2906
## WAIS_BD                0.3830  0.2685  0.3564  1.0000   0.4526      0.3980
## WAIS_Inf               0.6520  0.3293  0.3302  0.4526   1.0000      0.2783
## copy_direct            0.2700  0.2052  0.2906  0.3980   0.2783      1.0000
## copy_immediate         0.2695  0.3178  0.2678  0.4902   0.3431      0.4746
## copy_delayed           0.2715  0.3271  0.2679  0.4916   0.3446      0.4829
## PASAT                  0.4195  0.2902  0.2867  0.3892   0.3671      0.2501
## GPT_left               0.2048  0.1153  0.1960  0.3082   0.1853      0.2252
## GPT_right              0.1971  0.1182  0.1865  0.3027   0.1733      0.2230
## WLGT                   0.5041  0.2776  0.2091  0.2805   0.4136      0.1757
## ACB_verbal_early       0.7476  0.3133  0.3288  0.4360   0.7266      0.2914
## ACB_verbal_later       0.7659  0.3334  0.3613  0.4527   0.7193      0.3260
## ACB_arithmetic_early   0.5906  0.3285  0.3618  0.5025   0.6372      0.3344
## ACB_arithmetic_later   0.5852  0.3556  0.3956  0.5318   0.6216      0.3847
## PA                     0.4134  0.2614  0.3334  0.6367   0.4832      0.3812
## GIT                    0.5191  0.2475  0.2844  0.4197   0.5845      0.2563
## AFQT                   0.5751  0.3159  0.3691  0.6291   0.6275      0.3713
## MED_MOTOR_NCV         -0.0043  0.0032  0.0018 -0.0198  -0.0090     -0.0100
## MED_SENSORY_DL_NCV     0.0848  0.0299  0.0463  0.0492   0.1042      0.0533
## MED_SENSORY_PL_NCV     0.0221  0.0343  0.0390  0.0379   0.0410      0.0274
## ULN_SENSORY_NCV        0.1130  0.0474  0.0911  0.1116   0.1268      0.0728
## PER_MOTOR_NCV          0.0152  0.0040  0.0339  0.0021   0.0025      0.0121
## SUR_SENSORY_NCV        0.0267 -0.0077  0.0076  0.0190   0.0287      0.0247
## TEMP_ULIMB_SIDE_TEST  -0.0134 -0.0041 -0.0223 -0.0209  -0.0171     -0.0165
## TEMP_ULIMB_PALM        0.0260  0.0132 -0.0082  0.0104   0.0176      0.0164
## TEMP_ULIMB_FOREARM     0.0264  0.0187 -0.0038  0.0040   0.0134      0.0087
## TEMP_LLIMB_SIDE_TEST  -0.0042 -0.0141 -0.0385 -0.0220  -0.0033     -0.0179
## TEMP_LLIMB_FOOT        0.0183  0.0157 -0.0243 -0.0115  -0.0044      0.0291
## TEMP_LLIMB_UPPER_CALF  0.0191  0.0029 -0.0098  0.0023   0.0041      0.0131
## race                      NaN     NaN     NaN     NaN      NaN         NaN
## AGE                    0.0395 -0.0509 -0.0081  0.0228   0.1490     -0.0256
## test_time              0.0055  0.0212  0.0029 -0.0087  -0.0016     -0.0273
##                       copy_immediate copy_delayed    PASAT GPT_left
## WRAT                          0.2695      0.27147  0.41951   0.2048
## CVLT                          0.3178      0.32709  0.29025   0.1153
## WCST                          0.2678      0.26794  0.28665   0.1960
## WAIS_BD                       0.4902      0.49161  0.38922   0.3082
## WAIS_Inf                      0.3431      0.34460  0.36715   0.1853
## copy_direct                   0.4746      0.48289  0.25008   0.2252
## copy_immediate                1.0000      0.91544  0.28403   0.2280
## copy_delayed                  0.9154      1.00000  0.28293   0.2276
## PASAT                         0.2840      0.28293  1.00000   0.2187
## GPT_left                      0.2280      0.22762  0.21873   1.0000
## GPT_right                     0.1941      0.19976  0.22836   0.6367
## WLGT                          0.2134      0.21640  0.35772   0.1565
## ACB_verbal_early              0.3043      0.30254  0.41005   0.2046
## ACB_verbal_later              0.3158      0.31520  0.44174   0.2260
## ACB_arithmetic_early          0.3365      0.33975  0.52330   0.2087
## ACB_arithmetic_later          0.3866      0.38524  0.56373   0.2370
## PA                            0.4592      0.45586  0.37183   0.2617
## GIT                           0.3130      0.31094  0.36827   0.1897
## AFQT                          0.4507      0.44996  0.43338   0.2674
## MED_MOTOR_NCV                -0.0026     -0.00628 -0.01003   0.0043
## MED_SENSORY_DL_NCV            0.0073      0.00250  0.06461   0.0550
## MED_SENSORY_PL_NCV            0.0222      0.01971  0.06115   0.0743
## ULN_SENSORY_NCV               0.0698      0.06356  0.10203   0.0927
## PER_MOTOR_NCV                -0.0055     -0.00954  0.02193   0.0541
## SUR_SENSORY_NCV               0.0244      0.01926  0.02110   0.0320
## TEMP_ULIMB_SIDE_TEST         -0.0150     -0.02165 -0.00059   0.0449
## TEMP_ULIMB_PALM               0.0015     -0.00498  0.00901  -0.0021
## TEMP_ULIMB_FOREARM           -0.0042     -0.00720  0.00989   0.0065
## TEMP_LLIMB_SIDE_TEST         -0.0232     -0.02644 -0.00858   0.0345
## TEMP_LLIMB_FOOT               0.0015      0.00163 -0.00936  -0.0038
## TEMP_LLIMB_UPPER_CALF         0.0082      0.00653  0.00283   0.0157
## race                             NaN          NaN      NaN      NaN
## AGE                          -0.0367     -0.03912  0.01614  -0.0524
## test_time                     0.0010      0.00035 -0.01545   0.0080
##                       GPT_right     WLGT ACB_verbal_early ACB_verbal_later
## WRAT                     0.1971  0.50407           0.7476           0.7659
## CVLT                     0.1182  0.27761           0.3133           0.3334
## WCST                     0.1865  0.20913           0.3288           0.3613
## WAIS_BD                  0.3027  0.28054           0.4360           0.4527
## WAIS_Inf                 0.1733  0.41360           0.7266           0.7193
## copy_direct              0.2230  0.17573           0.2914           0.3260
## copy_immediate           0.1941  0.21338           0.3043           0.3158
## copy_delayed             0.1998  0.21640           0.3025           0.3152
## PASAT                    0.2284  0.35772           0.4101           0.4417
## GPT_left                 0.6367  0.15654           0.2046           0.2260
## GPT_right                1.0000  0.17061           0.1991           0.2220
## WLGT                     0.1706  1.00000           0.4415           0.4631
## ACB_verbal_early         0.1991  0.44148           1.0000           0.8256
## ACB_verbal_later         0.2220  0.46309           0.8256           1.0000
## ACB_arithmetic_early     0.1957  0.36769           0.7014           0.6591
## ACB_arithmetic_later     0.2408  0.36536           0.6427           0.6907
## PA                       0.2596  0.28846           0.5172           0.4855
## GIT                      0.1725  0.30889           0.6619           0.6224
## AFQT                     0.2521  0.35960           0.7165           0.6710
## MED_MOTOR_NCV           -0.0037 -0.00597          -0.0034          -0.0174
## MED_SENSORY_DL_NCV       0.0647  0.06384           0.1072           0.1012
## MED_SENSORY_PL_NCV       0.0655  0.01060           0.0363           0.0400
## ULN_SENSORY_NCV          0.0656  0.07556           0.1302           0.1359
## PER_MOTOR_NCV            0.0554 -0.00026           0.0156           0.0232
## SUR_SENSORY_NCV          0.0374  0.01349           0.0286           0.0197
## TEMP_ULIMB_SIDE_TEST    -0.0540 -0.01001           0.0110          -0.0080
## TEMP_ULIMB_PALM         -0.0059  0.01665           0.0176           0.0254
## TEMP_ULIMB_FOREARM       0.0086  0.02004           0.0147           0.0160
## TEMP_LLIMB_SIDE_TEST    -0.0393  0.00236           0.0240           0.0167
## TEMP_LLIMB_FOOT         -0.0176  0.02024          -0.0148           0.0091
## TEMP_LLIMB_UPPER_CALF    0.0074  0.03731          -0.0066           0.0047
## race                        NaN      NaN              NaN              NaN
## AGE                     -0.0585  0.01884           0.1245           0.0552
## test_time               -0.0136 -0.00385          -0.0049           0.0008
##                       ACB_arithmetic_early ACB_arithmetic_later       PA
## WRAT                                0.5906               0.5852  0.41337
## CVLT                                0.3285               0.3556  0.26142
## WCST                                0.3618               0.3956  0.33342
## WAIS_BD                             0.5025               0.5318  0.63672
## WAIS_Inf                            0.6372               0.6216  0.48317
## copy_direct                         0.3344               0.3847  0.38117
## copy_immediate                      0.3365               0.3866  0.45921
## copy_delayed                        0.3398               0.3852  0.45586
## PASAT                               0.5233               0.5637  0.37183
## GPT_left                            0.2087               0.2370  0.26165
## GPT_right                           0.1957               0.2408  0.25958
## WLGT                                0.3677               0.3654  0.28846
## ACB_verbal_early                    0.7014               0.6427  0.51723
## ACB_verbal_later                    0.6591               0.6907  0.48547
## ACB_arithmetic_early                1.0000               0.7867  0.57833
## ACB_arithmetic_later                0.7867               1.0000  0.54644
## PA                                  0.5783               0.5464  1.00000
## GIT                                 0.5925               0.5508  0.47000
## AFQT                                0.7400               0.6892  0.73184
## MED_MOTOR_NCV                      -0.0050              -0.0063 -0.01163
## MED_SENSORY_DL_NCV                  0.0953               0.1029  0.04759
## MED_SENSORY_PL_NCV                  0.0464               0.0554  0.04737
## ULN_SENSORY_NCV                     0.1106               0.1317  0.08268
## PER_MOTOR_NCV                       0.0082               0.0180  0.01299
## SUR_SENSORY_NCV                     0.0292               0.0213  0.01567
## TEMP_ULIMB_SIDE_TEST               -0.0129              -0.0168 -0.01261
## TEMP_ULIMB_PALM                     0.0166               0.0302  0.01565
## TEMP_ULIMB_FOREARM                  0.0136               0.0243  0.01320
## TEMP_LLIMB_SIDE_TEST                0.0104               0.0038 -0.00020
## TEMP_LLIMB_FOOT                    -0.0152              -0.0028 -0.00834
## TEMP_LLIMB_UPPER_CALF              -0.0071               0.0037  0.00016
## race                                   NaN                  NaN      NaN
## AGE                                 0.1258               0.0596  0.05648
## test_time                           0.0019               0.0061  0.00095
##                           GIT    AFQT MED_MOTOR_NCV MED_SENSORY_DL_NCV
## WRAT                   0.5191  0.5751       -0.0043             0.0848
## CVLT                   0.2475  0.3159        0.0032             0.0299
## WCST                   0.2844  0.3691        0.0018             0.0463
## WAIS_BD                0.4197  0.6291       -0.0198             0.0492
## WAIS_Inf               0.5845  0.6275       -0.0090             0.1042
## copy_direct            0.2563  0.3713       -0.0100             0.0533
## copy_immediate         0.3130  0.4507       -0.0026             0.0073
## copy_delayed           0.3109  0.4500       -0.0063             0.0025
## PASAT                  0.3683  0.4334       -0.0100             0.0646
## GPT_left               0.1897  0.2674        0.0043             0.0550
## GPT_right              0.1725  0.2521       -0.0037             0.0647
## WLGT                   0.3089  0.3596       -0.0060             0.0638
## ACB_verbal_early       0.6619  0.7165       -0.0034             0.1072
## ACB_verbal_later       0.6224  0.6710       -0.0174             0.1012
## ACB_arithmetic_early   0.5925  0.7400       -0.0050             0.0953
## ACB_arithmetic_later   0.5508  0.6892       -0.0063             0.1029
## PA                     0.4700  0.7318       -0.0116             0.0476
## GIT                    1.0000  0.6487       -0.0241             0.0517
## AFQT                   0.6487  1.0000       -0.0017             0.0508
## MED_MOTOR_NCV         -0.0241 -0.0017        1.0000             0.0507
## MED_SENSORY_DL_NCV     0.0517  0.0508        0.0507             1.0000
## MED_SENSORY_PL_NCV     0.0206  0.0443        0.0402            -0.0020
## ULN_SENSORY_NCV        0.0994  0.0991        0.0417             0.3507
## PER_MOTOR_NCV         -0.0028  0.0124        0.0014             0.0625
## SUR_SENSORY_NCV        0.0115  0.0197        0.0131             0.1622
## TEMP_ULIMB_SIDE_TEST   0.0229 -0.0078        0.0025             0.0835
## TEMP_ULIMB_PALM        0.0047  0.0107        0.0072             0.1387
## TEMP_ULIMB_FOREARM     0.0045  0.0126        0.0105             0.1350
## TEMP_LLIMB_SIDE_TEST   0.0347  0.0082       -0.0095             0.0305
## TEMP_LLIMB_FOOT       -0.0183 -0.0120        0.0214             0.1021
## TEMP_LLIMB_UPPER_CALF -0.0142 -0.0012       -0.0037             0.0872
## race                      NaN     NaN           NaN                NaN
## AGE                    0.1369  0.1162        0.0072            -0.0169
## test_time             -0.0139 -0.0035        0.0400             0.0705
##                       MED_SENSORY_PL_NCV ULN_SENSORY_NCV PER_MOTOR_NCV
## WRAT                               0.022          0.1130       0.01521
## CVLT                               0.034          0.0474       0.00404
## WCST                               0.039          0.0911       0.03385
## WAIS_BD                            0.038          0.1116       0.00213
## WAIS_Inf                           0.041          0.1268       0.00248
## copy_direct                        0.027          0.0728       0.01214
## copy_immediate                     0.022          0.0698      -0.00547
## copy_delayed                       0.020          0.0636      -0.00954
## PASAT                              0.061          0.1020       0.02193
## GPT_left                           0.074          0.0927       0.05407
## GPT_right                          0.066          0.0656       0.05535
## WLGT                               0.011          0.0756      -0.00026
## ACB_verbal_early                   0.036          0.1302       0.01555
## ACB_verbal_later                   0.040          0.1359       0.02318
## ACB_arithmetic_early               0.046          0.1106       0.00818
## ACB_arithmetic_later               0.055          0.1317       0.01800
## PA                                 0.047          0.0827       0.01299
## GIT                                0.021          0.0994      -0.00282
## AFQT                               0.044          0.0991       0.01237
## MED_MOTOR_NCV                      0.040          0.0417       0.00142
## MED_SENSORY_DL_NCV                -0.002          0.3507       0.06251
## MED_SENSORY_PL_NCV                 1.000          0.2134       0.07123
## ULN_SENSORY_NCV                    0.213          1.0000       0.12007
## PER_MOTOR_NCV                      0.071          0.1201       1.00000
## SUR_SENSORY_NCV                    0.153          0.2325       0.12516
## TEMP_ULIMB_SIDE_TEST               0.022          0.0213      -0.02479
## TEMP_ULIMB_PALM                    0.038          0.1765       0.00915
## TEMP_ULIMB_FOREARM                 0.031          0.1687       0.00634
## TEMP_LLIMB_SIDE_TEST               0.021          0.0027      -0.02761
## TEMP_LLIMB_FOOT                    0.030          0.1199       0.02898
## TEMP_LLIMB_UPPER_CALF              0.017          0.0851       0.02353
## race                                 NaN             NaN           NaN
## AGE                               -0.065         -0.0211      -0.03743
## test_time                          0.039          0.0897       0.01766
##                       SUR_SENSORY_NCV TEMP_ULIMB_SIDE_TEST TEMP_ULIMB_PALM
## WRAT                           0.0267             -0.01337         0.02595
## CVLT                          -0.0077             -0.00408         0.01317
## WCST                           0.0076             -0.02226        -0.00818
## WAIS_BD                        0.0190             -0.02095         0.01043
## WAIS_Inf                       0.0287             -0.01705         0.01761
## copy_direct                    0.0247             -0.01650         0.01638
## copy_immediate                 0.0244             -0.01502         0.00155
## copy_delayed                   0.0193             -0.02165        -0.00498
## PASAT                          0.0211             -0.00059         0.00901
## GPT_left                       0.0320              0.04487        -0.00208
## GPT_right                      0.0374             -0.05398        -0.00588
## WLGT                           0.0135             -0.01001         0.01665
## ACB_verbal_early               0.0286              0.01099         0.01760
## ACB_verbal_later               0.0197             -0.00803         0.02542
## ACB_arithmetic_early           0.0292             -0.01286         0.01664
## ACB_arithmetic_later           0.0213             -0.01680         0.03016
## PA                             0.0157             -0.01261         0.01565
## GIT                            0.0115              0.02286         0.00467
## AFQT                           0.0197             -0.00778         0.01066
## MED_MOTOR_NCV                  0.0131              0.00251         0.00723
## MED_SENSORY_DL_NCV             0.1622              0.08351         0.13866
## MED_SENSORY_PL_NCV             0.1529              0.02179         0.03843
## ULN_SENSORY_NCV                0.2325              0.02129         0.17651
## PER_MOTOR_NCV                  0.1252             -0.02479         0.00915
## SUR_SENSORY_NCV                1.0000             -0.00854         0.05507
## TEMP_ULIMB_SIDE_TEST          -0.0085              1.00000         0.04846
## TEMP_ULIMB_PALM                0.0551              0.04846         1.00000
## TEMP_ULIMB_FOREARM             0.0545              0.02923         0.91602
## TEMP_LLIMB_SIDE_TEST          -0.0291              0.61499         0.03422
## TEMP_LLIMB_FOOT                0.1470              0.03813         0.65816
## TEMP_LLIMB_UPPER_CALF          0.0839              0.04792         0.69984
## race                              NaN                  NaN             NaN
## AGE                           -0.0097              0.00215        -0.00085
## test_time                     -0.0013              0.00126         0.08080
##                       TEMP_ULIMB_FOREARM TEMP_LLIMB_SIDE_TEST
## WRAT                              0.0264              -0.0042
## CVLT                              0.0187              -0.0141
## WCST                             -0.0038              -0.0385
## WAIS_BD                           0.0040              -0.0220
## WAIS_Inf                          0.0134              -0.0033
## copy_direct                       0.0087              -0.0179
## copy_immediate                   -0.0042              -0.0232
## copy_delayed                     -0.0072              -0.0264
## PASAT                             0.0099              -0.0086
## GPT_left                          0.0065               0.0345
## GPT_right                         0.0086              -0.0393
## WLGT                              0.0200               0.0024
## ACB_verbal_early                  0.0147               0.0240
## ACB_verbal_later                  0.0160               0.0167
## ACB_arithmetic_early              0.0136               0.0104
## ACB_arithmetic_later              0.0243               0.0038
## PA                                0.0132              -0.0002
## GIT                               0.0045               0.0347
## AFQT                              0.0126               0.0082
## MED_MOTOR_NCV                     0.0105              -0.0095
## MED_SENSORY_DL_NCV                0.1350               0.0305
## MED_SENSORY_PL_NCV                0.0313               0.0207
## ULN_SENSORY_NCV                   0.1687               0.0027
## PER_MOTOR_NCV                     0.0063              -0.0276
## SUR_SENSORY_NCV                   0.0545              -0.0291
## TEMP_ULIMB_SIDE_TEST              0.0292               0.6150
## TEMP_ULIMB_PALM                   0.9160               0.0342
## TEMP_ULIMB_FOREARM                1.0000               0.0231
## TEMP_LLIMB_SIDE_TEST              0.0231               1.0000
## TEMP_LLIMB_FOOT                   0.6620               0.0403
## TEMP_LLIMB_UPPER_CALF             0.7393               0.0523
## race                                 NaN                  NaN
## AGE                               0.0112               0.0032
## test_time                         0.0823               0.0022
##                       TEMP_LLIMB_FOOT TEMP_LLIMB_UPPER_CALF race      AGE
## WRAT                           0.0183               0.01914  NaN  0.03953
## CVLT                           0.0157               0.00287  NaN -0.05091
## WCST                          -0.0243              -0.00984  NaN -0.00814
## WAIS_BD                       -0.0115               0.00231  NaN  0.02279
## WAIS_Inf                      -0.0044               0.00409  NaN  0.14902
## copy_direct                    0.0291               0.01309  NaN -0.02564
## copy_immediate                 0.0015               0.00816  NaN -0.03669
## copy_delayed                   0.0016               0.00653  NaN -0.03912
## PASAT                         -0.0094               0.00283  NaN  0.01614
## GPT_left                      -0.0038               0.01570  NaN -0.05237
## GPT_right                     -0.0176               0.00740  NaN -0.05849
## WLGT                           0.0202               0.03731  NaN  0.01884
## ACB_verbal_early              -0.0148              -0.00662  NaN  0.12448
## ACB_verbal_later               0.0091               0.00467  NaN  0.05516
## ACB_arithmetic_early          -0.0152              -0.00705  NaN  0.12577
## ACB_arithmetic_later          -0.0028               0.00366  NaN  0.05965
## PA                            -0.0083               0.00016  NaN  0.05648
## GIT                           -0.0183              -0.01424  NaN  0.13693
## AFQT                          -0.0120              -0.00120  NaN  0.11622
## MED_MOTOR_NCV                  0.0214              -0.00374  NaN  0.00723
## MED_SENSORY_DL_NCV             0.1021               0.08719  NaN -0.01685
## MED_SENSORY_PL_NCV             0.0301               0.01741  NaN -0.06474
## ULN_SENSORY_NCV                0.1199               0.08506  NaN -0.02106
## PER_MOTOR_NCV                  0.0290               0.02353  NaN -0.03743
## SUR_SENSORY_NCV                0.1470               0.08387  NaN -0.00968
## TEMP_ULIMB_SIDE_TEST           0.0381               0.04792  NaN  0.00215
## TEMP_ULIMB_PALM                0.6582               0.69984  NaN -0.00085
## TEMP_ULIMB_FOREARM             0.6620               0.73933  NaN  0.01125
## TEMP_LLIMB_SIDE_TEST           0.0403               0.05233  NaN  0.00319
## TEMP_LLIMB_FOOT                1.0000               0.75383  NaN -0.01064
## TEMP_LLIMB_UPPER_CALF          0.7538               1.00000  NaN  0.02621
## race                              NaN                   NaN  NaN      NaN
## AGE                           -0.0106               0.02621  NaN  1.00000
## test_time                      0.0800               0.05461  NaN -0.02981
##                       test_time
## WRAT                    0.00547
## CVLT                    0.02119
## WCST                    0.00290
## WAIS_BD                -0.00869
## WAIS_Inf               -0.00164
## copy_direct            -0.02733
## copy_immediate          0.00101
## copy_delayed            0.00035
## PASAT                  -0.01545
## GPT_left                0.00802
## GPT_right              -0.01357
## WLGT                   -0.00385
## ACB_verbal_early       -0.00494
## ACB_verbal_later        0.00080
## ACB_arithmetic_early    0.00192
## ACB_arithmetic_later    0.00612
## PA                      0.00095
## GIT                    -0.01389
## AFQT                   -0.00351
## MED_MOTOR_NCV           0.04002
## MED_SENSORY_DL_NCV      0.07048
## MED_SENSORY_PL_NCV      0.03901
## ULN_SENSORY_NCV         0.08973
## PER_MOTOR_NCV           0.01766
## SUR_SENSORY_NCV        -0.00131
## TEMP_ULIMB_SIDE_TEST    0.00126
## TEMP_ULIMB_PALM         0.08080
## TEMP_ULIMB_FOREARM      0.08234
## TEMP_LLIMB_SIDE_TEST    0.00217
## TEMP_LLIMB_FOOT         0.07995
## TEMP_LLIMB_UPPER_CALF   0.05461
## race                        NaN
## AGE                    -0.02981
## test_time               1.00000
#adjust
d_adj = do_adjust(d, vars = c(g_tests, ncv_tests), control_vars = control_vars)

Exploratory factor analysis: 1 factor

We use exploratory factor analysis to extract the g factor, as well as a general NCV factor.

#GCA
(fa_g = fa(d_adj[g_tests]))
## Factor Analysis using method =  minres
## Call: fa(r = d_adj[g_tests])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                       MR1    h2   u2 com
## WRAT                 0.72 0.517 0.48   1
## CVLT                 0.41 0.171 0.83   1
## WCST                 0.42 0.180 0.82   1
## WAIS_BD              0.62 0.387 0.61   1
## WAIS_Inf             0.75 0.561 0.44   1
## copy_direct          0.44 0.194 0.81   1
## copy_immediate       0.52 0.272 0.73   1
## copy_delayed         0.52 0.275 0.73   1
## PASAT                0.53 0.282 0.72   1
## GPT_left             0.31 0.098 0.90   1
## GPT_right            0.31 0.098 0.90   1
## WLGT                 0.51 0.257 0.74   1
## ACB_verbal_early     0.80 0.633 0.37   1
## ACB_verbal_later     0.80 0.639 0.36   1
## ACB_arithmetic_early 0.78 0.613 0.39   1
## ACB_arithmetic_later 0.79 0.617 0.38   1
## PA                   0.67 0.450 0.55   1
## GIT                  0.63 0.403 0.60   1
## AFQT                 0.83 0.682 0.32   1
## 
##                 MR1
## SS loadings    7.33
## Proportion Var 0.39
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  171  and the objective function was  11 with Chi Square of  50769
## The degrees of freedom for the model are 152  and the objective function was  3.8 
## 
## The root mean square of the residuals (RMSR) is  0.1 
## The df corrected root mean square of the residuals is  0.1 
## 
## The harmonic number of observations is  4462 with the empirical chi square  14178  with prob <  0 
## The total number of observations was  4462  with Likelihood Chi Square =  17030  with prob <  0 
## 
## Tucker Lewis Index of factoring reliability =  0.62
## RMSEA index =  0.16  and the 90 % confidence intervals are  0.16 0.16
## BIC =  15752
## Fit based upon off diagonal values = 0.94
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.97
## Multiple R square of scores with factors          0.94
## Minimum correlation of possible factor scores     0.88
d_adj$g = fa_g$scores %>% as.vector %>% standardize
fa_g$loadings %>% as.vector %>% describe
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis
## X1    1 19  0.6 0.17   0.62     0.6 0.24 0.31 0.83  0.51 -0.2     -1.4
##      se
## X1 0.04
GG_denhist(d_adj$g)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

describe(d_adj$g)
##    vars    n mean sd median trimmed mad  min max range  skew kurtosis   se
## X1    1 4462    0  1   0.04    0.03 1.1 -3.3 3.1   6.4 -0.23    -0.34 0.01
#factor method variance
fa_all_methods(d_adj[g_tests], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##       1.00       1.00       1.00       1.00       1.00       1.00 
##   midrange 
##       0.99
#PNCV
(fa_ncv = fa(d_adj[ncv_tests]))
## Factor Analysis using method =  minres
## Call: fa(r = d_adj[ncv_tests])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                     MR1     h2   u2 com
## MED_MOTOR_NCV      0.07 0.0046 1.00   1
## MED_SENSORY_DL_NCV 0.40 0.1627 0.84   1
## MED_SENSORY_PL_NCV 0.24 0.0561 0.94   1
## ULN_SENSORY_NCV    0.73 0.5340 0.47   1
## PER_MOTOR_NCV      0.19 0.0374 0.96   1
## SUR_SENSORY_NCV    0.35 0.1230 0.88   1
## 
##                 MR1
## SS loadings    0.92
## Proportion Var 0.15
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  15  and the objective function was  0.26 with Chi Square of  1157
## The degrees of freedom for the model are 9  and the objective function was  0.04 
## 
## The root mean square of the residuals (RMSR) is  0.04 
## The df corrected root mean square of the residuals is  0.05 
## 
## The harmonic number of observations is  4462 with the empirical chi square  220  with prob <  2.1e-42 
## The total number of observations was  4462  with Likelihood Chi Square =  157  with prob <  3.8e-29 
## 
## Tucker Lewis Index of factoring reliability =  0.78
## RMSEA index =  0.061  and the 90 % confidence intervals are  0.053 0.069
## BIC =  81
## Fit based upon off diagonal values = 0.91
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.78
## Multiple R square of scores with factors          0.61
## Minimum correlation of possible factor scores     0.23
d_adj$ncv = fa_ncv$scores %>% as.vector %>% standardize
fa_ncv$loadings %>% as.vector %>% describe
##    vars n mean   sd median trimmed  mad  min  max range skew kurtosis   se
## X1    1 6 0.33 0.23   0.29    0.33 0.16 0.07 0.73  0.66  0.6     -1.1 0.09
GG_denhist(d_adj$ncv)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

describe(d_adj$ncv)
##    vars    n mean sd median trimmed  mad  min max range  skew kurtosis
## X1    1 4462    0  1   0.01    0.02 0.92 -7.8 8.3    16 -0.26      3.2
##      se
## X1 0.01
#factor method variance
fa_all_methods(d_adj[ncv_tests], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##       0.66       0.44       0.25       1.00       0.95       0.68 
##   midrange 
##       0.54

Relationships if we use the scores from exploratory analyses

Then we analyze the relationships between NCV, g and education.

#cors
wtd.cors(d_adj[c("education", "g", "ncv")])
##           education    g  ncv
## education      1.00 0.57 0.12
## g              0.57 1.00 0.10
## ncv            0.12 0.10 1.00
#plot
GG_scatter(d_adj, "ncv", "g", case_names = F) +
  geom_smooth() +
  xlab("Peripheral nerve conduction velocity\n(factor score from 6 indicators)") +
  ylab("General cognitive abiliy\n(factor score from 19 indicators)")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'

silence(ggsave("figures/ncv_g.png"))

#Jensen's method based on EFAs
fa_Jensens_method(fa_g, d_adj, criterion = "ncv", loading_reversing = F, indicator_criterion_method = "pearson", text_pos = "tl") +
  xlim(NA, .90)
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("figures/Jensen_method_g_ncv.png"))

fa_Jensens_method(fa_ncv, d_adj, criterion = "g", loading_reversing = F, indicator_criterion_method = "pearson", text_pos = "br") +
  xlim(0, .8)
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("figures/Jensen_method_ncv_g.png"))

Without GPT tests

#extract g
(fa_g_noGPT = fa(d_adj[g_tests_noGPT]))
## Factor Analysis using method =  minres
## Call: fa(r = d_adj[g_tests_noGPT])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                       MR1   h2   u2 com
## WRAT                 0.72 0.53 0.47   1
## CVLT                 0.41 0.17 0.83   1
## WCST                 0.42 0.18 0.82   1
## WAIS_BD              0.61 0.37 0.63   1
## WAIS_Inf             0.76 0.57 0.43   1
## copy_direct          0.43 0.19 0.81   1
## copy_immediate       0.52 0.27 0.73   1
## copy_delayed         0.52 0.27 0.73   1
## PASAT                0.53 0.28 0.72   1
## WLGT                 0.51 0.26 0.74   1
## ACB_verbal_early     0.80 0.64 0.36   1
## ACB_verbal_later     0.80 0.65 0.35   1
## ACB_arithmetic_early 0.79 0.62 0.38   1
## ACB_arithmetic_later 0.79 0.62 0.38   1
## PA                   0.67 0.44 0.56   1
## GIT                  0.64 0.41 0.59   1
## AFQT                 0.83 0.68 0.32   1
## 
##                 MR1
## SS loadings    7.15
## 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  136  and the objective function was  11 with Chi Square of  47858
## The degrees of freedom for the model are 119  and the objective function was  3.3 
## 
## 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  4462 with the empirical chi square  10932  with prob <  0 
## The total number of observations was  4462  with Likelihood Chi Square =  14733  with prob <  0 
## 
## Tucker Lewis Index of factoring reliability =  0.65
## RMSEA index =  0.17  and the 90 % confidence intervals are  0.16 0.17
## BIC =  13733
## Fit based upon off diagonal values = 0.95
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.97
## Multiple R square of scores with factors          0.94
## Minimum correlation of possible factor scores     0.88
d_adj$g_noGPT = fa_g$scores %>% as.vector

#factor method variance
fa_all_methods(d_adj[g_tests_noGPT], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##          1          1          1          1          1          1 
##   midrange 
##          1
#cors
wtd.cors(d_adj[c("g", "g_noGPT", "ncv")])
##           g g_noGPT ncv
## g       1.0     1.0 0.1
## g_noGPT 1.0     1.0 0.1
## ncv     0.1     0.1 1.0
#plot
GG_scatter(d_adj, "ncv", "g", case_names = F) +
  geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'

silence(ggsave("figures/ncv_g_noGPT.png"))

#Jensen's method based on EFA
fa_Jensens_method(fa_g_noGPT, d_adj, criterion = "ncv", loading_reversing = F, indicator_criterion_method = "pearson", text_pos = "tl")
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("figures/Jensen_method_ncv_noGPT.png"))

SEM approach

Usually produces about the same relationship as EFA.

#SEM
g_part = "g =~ " + str_c(g_tests, collapse = " + ")
ncv_part = "ncv =~ " + str_c(ncv_tests, collapse = " + ")
model_str = g_part + "\n" + ncv_part + "\n" +
"g ~~ ncv"
cat(model_str)
## g =~ WRAT + CVLT + WCST + WAIS_BD + WAIS_Inf + copy_direct + copy_immediate + copy_delayed + PASAT + GPT_left + GPT_right + WLGT + ACB_verbal_early + ACB_verbal_later + ACB_arithmetic_early + ACB_arithmetic_later + PA + GIT + AFQT
## ncv =~ MED_MOTOR_NCV + MED_SENSORY_DL_NCV + MED_SENSORY_PL_NCV + ULN_SENSORY_NCV + PER_MOTOR_NCV + SUR_SENSORY_NCV
## g ~~ ncv
#fit
fit = sem(model_str, data = d_adj, std.ov = T, std.lv = T)
parameterestimates(fit)
##                     lhs op                  rhs   est    se    z pvalue
## 1                     g =~                 WRAT 0.756 0.013 58.6  0.000
## 2                     g =~                 CVLT 0.398 0.015 27.0  0.000
## 3                     g =~                 WCST 0.409 0.015 27.8  0.000
## 4                     g =~              WAIS_BD 0.579 0.014 41.4  0.000
## 5                     g =~             WAIS_Inf 0.772 0.013 60.4  0.000
## 6                     g =~          copy_direct 0.400 0.015 27.1  0.000
## 7                     g =~       copy_immediate 0.455 0.015 31.2  0.000
## 8                     g =~         copy_delayed 0.457 0.015 31.4  0.000
## 9                     g =~                PASAT 0.520 0.014 36.4  0.000
## 10                    g =~             GPT_left 0.278 0.015 18.4  0.000
## 11                    g =~            GPT_right 0.280 0.015 18.5  0.000
## 12                    g =~                 WLGT 0.512 0.014 35.7  0.000
## 13                    g =~     ACB_verbal_early 0.836 0.012 68.1  0.000
## 14                    g =~     ACB_verbal_later 0.833 0.012 67.6  0.000
## 15                    g =~ ACB_arithmetic_early 0.797 0.013 63.3  0.000
## 16                    g =~ ACB_arithmetic_later 0.785 0.013 61.9  0.000
## 17                    g =~                   PA 0.645 0.014 47.3  0.000
## 18                    g =~                  GIT 0.658 0.014 48.5  0.000
## 19                    g =~                 AFQT 0.816 0.012 65.6  0.000
## 20                  ncv =~        MED_MOTOR_NCV 0.063 0.019  3.3  0.001
## 21                  ncv =~   MED_SENSORY_DL_NCV 0.424 0.021 19.8  0.000
## 22                  ncv =~   MED_SENSORY_PL_NCV 0.240 0.019 12.4  0.000
## 23                  ncv =~      ULN_SENSORY_NCV 0.744 0.029 25.4  0.000
## 24                  ncv =~        PER_MOTOR_NCV 0.177 0.019  9.3  0.000
## 25                  ncv =~      SUR_SENSORY_NCV 0.319 0.020 16.0  0.000
## 26                    g ~~                  ncv 0.137 0.019  7.1  0.000
## 27                 WRAT ~~                 WRAT 0.428 0.010 43.5  0.000
## 28                 CVLT ~~                 CVLT 0.841 0.018 46.7  0.000
## 29                 WCST ~~                 WCST 0.833 0.018 46.7  0.000
## 30              WAIS_BD ~~              WAIS_BD 0.664 0.014 45.8  0.000
## 31             WAIS_Inf ~~             WAIS_Inf 0.403 0.009 43.0  0.000
## 32          copy_direct ~~          copy_direct 0.840 0.018 46.7  0.000
## 33       copy_immediate ~~       copy_immediate 0.793 0.017 46.5  0.000
## 34         copy_delayed ~~         copy_delayed 0.791 0.017 46.5  0.000
## 35                PASAT ~~                PASAT 0.730 0.016 46.2  0.000
## 36             GPT_left ~~             GPT_left 0.923 0.020 47.0  0.000
## 37            GPT_right ~~            GPT_right 0.922 0.020 47.0  0.000
## 38                 WLGT ~~                 WLGT 0.738 0.016 46.2  0.000
## 39     ACB_verbal_early ~~     ACB_verbal_early 0.300 0.007 40.6  0.000
## 40     ACB_verbal_later ~~     ACB_verbal_later 0.307 0.008 40.8  0.000
## 41 ACB_arithmetic_early ~~ ACB_arithmetic_early 0.365 0.009 42.3  0.000
## 42 ACB_arithmetic_later ~~ ACB_arithmetic_later 0.383 0.009 42.7  0.000
## 43                   PA ~~                   PA 0.584 0.013 45.2  0.000
## 44                  GIT ~~                  GIT 0.567 0.013 45.1  0.000
## 45                 AFQT ~~                 AFQT 0.334 0.008 41.6  0.000
## 46        MED_MOTOR_NCV ~~        MED_MOTOR_NCV 0.996 0.021 47.1  0.000
## 47   MED_SENSORY_DL_NCV ~~   MED_SENSORY_DL_NCV 0.820 0.022 37.2  0.000
## 48   MED_SENSORY_PL_NCV ~~   MED_SENSORY_PL_NCV 0.942 0.021 45.2  0.000
## 49      ULN_SENSORY_NCV ~~      ULN_SENSORY_NCV 0.446 0.040 11.1  0.000
## 50        PER_MOTOR_NCV ~~        PER_MOTOR_NCV 0.968 0.021 46.2  0.000
## 51      SUR_SENSORY_NCV ~~      SUR_SENSORY_NCV 0.898 0.021 43.0  0.000
## 52                    g ~~                    g 1.000 0.000   NA     NA
## 53                  ncv ~~                  ncv 1.000 0.000   NA     NA
##    ci.lower ci.upper
## 1     0.731     0.78
## 2     0.369     0.43
## 3     0.380     0.44
## 4     0.552     0.61
## 5     0.747     0.80
## 6     0.371     0.43
## 7     0.426     0.48
## 8     0.429     0.49
## 9     0.492     0.55
## 10    0.248     0.31
## 11    0.250     0.31
## 12    0.484     0.54
## 13    0.812     0.86
## 14    0.808     0.86
## 15    0.772     0.82
## 16    0.761     0.81
## 17    0.618     0.67
## 18    0.631     0.69
## 19    0.792     0.84
## 20    0.026     0.10
## 21    0.382     0.47
## 22    0.203     0.28
## 23    0.687     0.80
## 24    0.140     0.21
## 25    0.280     0.36
## 26    0.099     0.17
## 27    0.409     0.45
## 28    0.806     0.88
## 29    0.798     0.87
## 30    0.636     0.69
## 31    0.385     0.42
## 32    0.805     0.88
## 33    0.760     0.83
## 34    0.758     0.82
## 35    0.699     0.76
## 36    0.884     0.96
## 37    0.883     0.96
## 38    0.707     0.77
## 39    0.286     0.32
## 40    0.292     0.32
## 41    0.348     0.38
## 42    0.365     0.40
## 43    0.558     0.61
## 44    0.542     0.59
## 45    0.318     0.35
## 46    0.954     1.04
## 47    0.777     0.86
## 48    0.901     0.98
## 49    0.367     0.53
## 50    0.927     1.01
## 51    0.857     0.94
## 52    1.000     1.00
## 53    1.000     1.00

As expected, this produced roughly the same result as the EFA approach.

EFA: multi-factor

Given that the two outlying tests are variants by hand, perhaps variance from non-g factors are obscuring the relationship. We try extracting more factors.

#determine number of factors
nFactors::nScree(d_adj[g_tests] %>% as.data.frame)
##   noc naf nparallel nkaiser
## 1   3   1         3       3
#g bifactor efa
fa_bi3 = fa(d_adj[g_tests], nfactors = 3, rotate = "bifactor")
## Loading required namespace: GPArotation
fa_plot_loadings(fa_bi3)
## Warning: Some components of ... were not used: fun

fa_bi4 = fa(d_adj[g_tests], nfactors = 4, rotate = "bifactor")
fa_plot_loadings(fa_bi4)
## Warning: Some components of ... were not used: fun

#Jensen's method for bifactor
fa_Jensens_method(fa_bi3, df = d_adj, criterion = "ncv", n_factor = 1, loading_reversing = F)
## Using Pearson correlations for the criterion-indicators relationships.

fa_Jensens_method(fa_bi3, df = d_adj, criterion = "ncv", n_factor = 2, loading_reversing = F)
## Using Pearson correlations for the criterion-indicators relationships.

fa_Jensens_method(fa_bi3, df = d_adj, criterion = "ncv", n_factor = 3, loading_reversing = F)
## Using Pearson correlations for the criterion-indicators relationships.

#Jensen's method regression
#construct data frame with test level data
d_test = data_frame(
  test = g_tests,
  g = fa_bi3$loadings %>% `[`(, 1),
  F1 = fa_bi3$loadings %>% `[`(, 2),
  F2 = fa_bi3$loadings %>% `[`(, 3),
  criterion_r = wtd.cors(d_adj[c("ncv", g_tests)]) %>% `[`(-1, 1)
)
## Warning: `data_frame()` is deprecated, use `tibble()`.
## This warning is displayed once per session.
d_test
## # A tibble: 19 x 5
##    test                     g       F1       F2 criterion_r
##    <chr>                <dbl>    <dbl>    <dbl>       <dbl>
##  1 WRAT                 0.653  0.444   -0.00777      0.0758
##  2 CVLT                 0.420  0.0183  -0.00737      0.0231
##  3 WCST                 0.411  0.0444   0.104        0.0651
##  4 WAIS_BD              0.637 -0.0903   0.189        0.0580
##  5 WAIS_Inf             0.704  0.334   -0.0302       0.108 
##  6 copy_direct          0.484 -0.198    0.116        0.0446
##  7 copy_immediate       0.704 -0.591   -0.00922      0.0315
##  8 copy_delayed         0.709 -0.595   -0.00730      0.0245
##  9 PASAT                0.497  0.152    0.112        0.0762
## 10 GPT_left             0.255 -0.0152   0.705        0.0755
## 11 GPT_right            0.245  0.0144   0.778        0.0662
## 12 WLGT                 0.463  0.237    0.0520       0.0721
## 13 ACB_verbal_early     0.731  0.472   -0.0263       0.103 
## 14 ACB_verbal_later     0.731  0.461    0.00328      0.0981
## 15 ACB_arithmetic_early 0.734  0.315    0.0131       0.0775
## 16 ACB_arithmetic_later 0.742  0.255    0.0561       0.0912
## 17 PA                   0.673 -0.00773  0.126        0.0415
## 18 GIT                  0.594  0.274   -0.00463      0.0461
## 19 AFQT                 0.796  0.178    0.0713       0.0506
lm("criterion_r ~ g + F1 + F2", data = d_test) %>% MOD_summary(kfold = F)
## 
##     ---- Model summary ----    
## Model coefficients
##    Beta   SE CI_lower CI_upper
## g  0.29 0.23    -0.21     0.79
## F1 0.77 0.16     0.43     1.11
## F2 0.36 0.23    -0.13     0.86
## 
## 
## Model meta-data
##       outcome  N df   R2 R2-adj. R2-cv
## 1 criterion_r 19 15 0.64    0.56    NA
## 
## 
## Etas from analysis of variance
##     Eta Eta_partial
## g  0.19        0.31
## F1 0.76        0.78
## F2 0.24        0.38
#case-level
d_adj$bi_g = fa_bi3$scores %>% `[`(, 1)
d_adj$bi_F1 = fa_bi3$scores %>% `[`(, 2)
d_adj$bi_F2 = fa_bi3$scores %>% `[`(, 3)

#model
lm("ncv ~ bi_g + bi_F1 + bi_F2", data = d_adj) %>% MOD_summary(progress = F)
## 
##     ---- Model summary ----    
## Model coefficients
##        Beta    SE CI_lower CI_upper
## bi_g  0.084 0.015    0.055    0.114
## bi_F1 0.060 0.015    0.031    0.090
## bi_F2 0.053 0.015    0.023    0.082
## 
## 
## Model meta-data
##   outcome    N   df    R2 R2-adj. R2-cv
## 1     ncv 4462 4458 0.014   0.013    NA
## 
## 
## Etas from analysis of variance
##         Eta Eta_partial
## bi_g  0.084       0.085
## bi_F1 0.060       0.061
## bi_F2 0.053       0.053

These results are similar to the previous ones.

Whites only

Perhaps we should not control for SIRE and instead just use the White subsample.

#subset, adjust
d_white_adj = d %>%
  filter(race == "White") %>% 
  do_adjust(vars = c(g_tests, ncv_tests), control_vars = control_vars_noSIRE)

#extract g
(fa_g = fa(d_white_adj[g_tests]))
## Factor Analysis using method =  minres
## Call: fa(r = d_white_adj[g_tests])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                       MR1   h2   u2 com
## WRAT                 0.73 0.53 0.47   1
## CVLT                 0.42 0.18 0.82   1
## WCST                 0.42 0.18 0.82   1
## WAIS_BD              0.63 0.40 0.60   1
## WAIS_Inf             0.75 0.57 0.43   1
## copy_direct          0.45 0.20 0.80   1
## copy_immediate       0.53 0.28 0.72   1
## copy_delayed         0.54 0.29 0.71   1
## PASAT                0.54 0.29 0.71   1
## GPT_left             0.33 0.11 0.89   1
## GPT_right            0.32 0.10 0.90   1
## WLGT                 0.51 0.26 0.74   1
## ACB_verbal_early     0.80 0.64 0.36   1
## ACB_verbal_later     0.81 0.65 0.35   1
## ACB_arithmetic_early 0.79 0.63 0.37   1
## ACB_arithmetic_later 0.79 0.63 0.37   1
## PA                   0.69 0.48 0.52   1
## GIT                  0.65 0.43 0.57   1
## AFQT                 0.84 0.71 0.29   1
## 
##                MR1
## SS loadings    7.6
## Proportion Var 0.4
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  171  and the objective function was  12 with Chi Square of  43230
## The degrees of freedom for the model are 152  and the objective function was  3.9 
## 
## 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  3654 with the empirical chi square  11257  with prob <  0 
## The total number of observations was  3654  with Likelihood Chi Square =  14080  with prob <  0 
## 
## Tucker Lewis Index of factoring reliability =  0.64
## RMSEA index =  0.16  and the 90 % confidence intervals are  0.16 0.16
## BIC =  12833
## Fit based upon off diagonal values = 0.95
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.97
## Multiple R square of scores with factors          0.94
## Minimum correlation of possible factor scores     0.88
d_white_adj$g = fa_g$scores %>% as.vector

#factor method variance
fa_all_methods(d_white_adj[g_tests], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##       1.00       1.00       1.00       1.00       1.00       1.00 
##   midrange 
##       0.99
#extract ncv
(fa_ncv = fa(d_white_adj[ncv_tests]))
## Factor Analysis using method =  minres
## Call: fa(r = d_white_adj[ncv_tests])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                     MR1     h2   u2 com
## MED_MOTOR_NCV      0.09 0.0082 0.99   1
## MED_SENSORY_DL_NCV 0.34 0.1153 0.88   1
## MED_SENSORY_PL_NCV 0.25 0.0628 0.94   1
## ULN_SENSORY_NCV    0.87 0.7530 0.25   1
## PER_MOTOR_NCV      0.17 0.0273 0.97   1
## SUR_SENSORY_NCV    0.28 0.0765 0.92   1
## 
##                 MR1
## SS loadings    1.04
## Proportion Var 0.17
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  15  and the objective function was  0.29 with Chi Square of  1064
## The degrees of freedom for the model are 9  and the objective function was  0.06 
## 
## The root mean square of the residuals (RMSR) is  0.05 
## The df corrected root mean square of the residuals is  0.07 
## 
## The harmonic number of observations is  3654 with the empirical chi square  310  with prob <  2.1e-61 
## The total number of observations was  3654  with Likelihood Chi Square =  229  with prob <  2.1e-44 
## 
## Tucker Lewis Index of factoring reliability =  0.65
## RMSEA index =  0.082  and the 90 % confidence intervals are  0.073 0.091
## BIC =  156
## Fit based upon off diagonal values = 0.85
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.88
## Multiple R square of scores with factors          0.77
## Minimum correlation of possible factor scores     0.55
d_white_adj$ncv = fa_ncv$scores %>% as.vector

#factor method variance
fa_all_methods(d_white_adj[ncv_tests], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##       0.65       0.48       0.30       1.00       0.88       0.67 
##   midrange 
##       0.53
#cors
wtd.cors(d_white_adj[c("education", "g", "ncv")])
##           education     g   ncv
## education      1.00 0.586 0.102
## g              0.59 1.000 0.095
## ncv            0.10 0.095 1.000
#plot
GG_scatter(d_white_adj, "ncv", "g", case_names = F) +
  geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'

silence(ggsave("figures/ncv_g_white.png"))

#Jensen's method based on EFA
fa_Jensens_method(fa_g, d_white_adj, criterion = "ncv", loading_reversing = F, indicator_criterion_method = "pearson", text_pos = "tr")
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("figures/Jensen_method_ncv_white.png"))

However, these results are quite similar to the others.

Without controls

Perhaps we are overcontrolling the data in some way. We can examine the relationships if we don’t control for possible confounders.

#extract g
(fa_g = fa(d[g_tests]))
## Factor Analysis using method =  minres
## Call: fa(r = d[g_tests])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                       MR1   h2   u2 com
## WRAT                 0.73 0.53 0.47   1
## CVLT                 0.42 0.18 0.82   1
## WCST                 0.46 0.21 0.79   1
## WAIS_BD              0.67 0.45 0.55   1
## WAIS_Inf             0.76 0.58 0.42   1
## copy_direct          0.47 0.22 0.78   1
## copy_immediate       0.55 0.30 0.70   1
## copy_delayed         0.55 0.30 0.70   1
## PASAT                0.57 0.32 0.68   1
## GPT_left             0.34 0.12 0.88   1
## GPT_right            0.33 0.11 0.89   1
## WLGT                 0.49 0.24 0.76   1
## ACB_verbal_early     0.82 0.67 0.33   1
## ACB_verbal_later     0.82 0.67 0.33   1
## ACB_arithmetic_early 0.81 0.66 0.34   1
## ACB_arithmetic_later 0.82 0.67 0.33   1
## PA                   0.71 0.50 0.50   1
## GIT                  0.69 0.48 0.52   1
## AFQT                 0.85 0.73 0.27   1
## 
##                 MR1
## SS loadings    7.94
## 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  171  and the objective function was  13 with Chi Square of  56112
## The degrees of freedom for the model are 152  and the objective function was  3.9 
## 
## 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  4462 with the empirical chi square  13128  with prob <  0 
## The total number of observations was  4462  with Likelihood Chi Square =  17325  with prob <  0 
## 
## Tucker Lewis Index of factoring reliability =  0.66
## RMSEA index =  0.16  and the 90 % confidence intervals are  0.16 0.16
## BIC =  16047
## Fit based upon off diagonal values = 0.95
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.97
## Multiple R square of scores with factors          0.95
## Minimum correlation of possible factor scores     0.89
d$g = fa_g$scores %>% as.vector

#factor method variance
fa_all_methods(d[g_tests], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##          1          1          1          1          1          1 
##   midrange 
##          1
#extract ncv
(fa_ncv = fa(d[ncv_tests]))
## Factor Analysis using method =  minres
## Call: fa(r = d[ncv_tests])
## Standardized loadings (pattern matrix) based upon correlation matrix
##                     MR1     h2   u2 com
## MED_MOTOR_NCV      0.07 0.0049 1.00   1
## MED_SENSORY_DL_NCV 0.42 0.1777 0.82   1
## MED_SENSORY_PL_NCV 0.25 0.0633 0.94   1
## ULN_SENSORY_NCV    0.76 0.5706 0.43   1
## PER_MOTOR_NCV      0.19 0.0363 0.96   1
## SUR_SENSORY_NCV    0.36 0.1298 0.87   1
## 
##                 MR1
## SS loadings    0.98
## Proportion Var 0.16
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  15  and the objective function was  0.29 with Chi Square of  1307
## The degrees of freedom for the model are 9  and the objective function was  0.04 
## 
## The root mean square of the residuals (RMSR) is  0.04 
## The df corrected root mean square of the residuals is  0.05 
## 
## The harmonic number of observations is  4462 with the empirical chi square  220  with prob <  2.2e-42 
## The total number of observations was  4462  with Likelihood Chi Square =  161  with prob <  3.9e-30 
## 
## Tucker Lewis Index of factoring reliability =  0.8
## RMSEA index =  0.062  and the 90 % confidence intervals are  0.053 0.07
## BIC =  86
## Fit based upon off diagonal values = 0.92
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.80
## Multiple R square of scores with factors          0.64
## Minimum correlation of possible factor scores     0.29
d$ncv = fa_ncv$scores %>% as.vector

#factor method variance
fa_all_methods(d[ncv_tests], messages = F) %>% `[[`("scores") %>% wtd.cors %>% MAT_half %>% averages
## arithmetic  geometric   harmonic       mode     median    trimmed 
##       0.66       0.45       0.26       1.00       0.95       0.69 
##   midrange 
##       0.54
#cors
wtd.cors(d[c("education", "g", "ncv")])
##           education    g  ncv
## education      1.00 0.55 0.12
## g              0.55 1.00 0.15
## ncv            0.12 0.15 1.00
#plot
GG_scatter(d, "ncv", "g", case_names = F) +
  geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'

silence(ggsave("figures/ncv_g_noAdj.png"))

#Jensen's method based on EFA
fa_Jensens_method(fa_g, d, criterion = "ncv", loading_reversing = F, indicator_criterion_method = "pearson", text_pos = "tr")
## Using Pearson correlations for the criterion-indicators relationships.

silence(ggsave("figures/Jensen_method_ncv_noAdj.png"))

Early and later g

#extract early and later g
fa_g_early = fa(d_adj[g_tests_early])
d_adj$g_early = fa_g_early$scores %>% as.vector
fa_g_later = fa(d_adj[g_tests_later])
d_adj$g_later = fa_g_later$scores %>% as.vector

#correlate
cor_matrix(d_adj[c("g", "g_early", "g_later", "ncv")], CI = .95)
##         g                  g_early            g_later           
## g       "1"                "0.94 [0.93 0.94]" "0.97 [0.97 0.97]"
## g_early "0.94 [0.93 0.94]" "1"                "0.82 [0.82 0.83]"
## g_later "0.97 [0.97 0.97]" "0.82 [0.82 0.83]" "1"               
## ncv     "0.10 [0.07 0.13]" "0.07 [0.05 0.10]" "0.11 [0.08 0.14]"
##         ncv               
## g       "0.10 [0.07 0.13]"
## g_early "0.07 [0.05 0.10]"
## g_later "0.11 [0.08 0.14]"
## ncv     "1"

Height as confounding factor

d_orig$ncv = d_adj$ncv
GG_scatter(d_orig, "g", "ncv")

GG_scatter(d_orig, "height", "g")

GG_scatter(d_orig, "height", "ncv")

Other correlates

Which other variables are related to PNCV?

#overview of correlates
wtd.cors(d_adj[c("g_early", "g_later", exploratory_vars)])
##                   g_early g_later education income unemployment_3yrs
## g_early             1.000  0.8248     0.517  0.310            -0.127
## g_later             0.825  1.0000     0.545  0.338            -0.173
## education           0.517  0.5454     1.000  0.349            -0.152
## income              0.310  0.3380     0.349  1.000            -0.487
## unemployment_3yrs  -0.127 -0.1725    -0.152 -0.487             1.000
## height              0.118  0.1064     0.091  0.092            -0.027
## weight              0.017  0.0032     0.025  0.062            -0.031
## BMI                -0.045 -0.0549    -0.021  0.021            -0.020
##                    height  weight     BMI
## g_early            0.1184  0.0174 -0.0446
## g_later            0.1064  0.0032 -0.0549
## education          0.0908  0.0251 -0.0205
## income             0.0917  0.0625  0.0211
## unemployment_3yrs -0.0268 -0.0306 -0.0203
## height             1.0000  0.4808 -0.0056
## weight             0.4808  1.0000  0.8707
## BMI               -0.0056  0.8707  1.0000
#models
ols(ncv ~ g + education, data = d_adj)
## Linear Regression Model
##  
##  ols(formula = ncv ~ g + education, data = d_adj)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs    4462    LR chi2     71.41    R2       0.016    
##  sigma0.9923    d.f.            2    R2 adj   0.015    
##  d.f.   4459    Pr(> chi2) 0.0000    g        0.142    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -7.84130 -0.59625  0.03094  0.64452  8.30186 
##  
##  
##            Coef    S.E.   t     Pr(>|t|)
##  Intercept -0.5310 0.1053 -5.04 <0.0001 
##  g          0.0489 0.0180  2.71 0.0067  
##  education  0.0400 0.0078  5.09 <0.0001 
## 
ols(ncv ~ g + education, data = d)
## Linear Regression Model
##  
##  ols(formula = ncv ~ g + education, data = d)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs    4462    LR chi2    108.92    R2       0.024    
##  sigma0.7927    d.f.            2    R2 adj   0.024    
##  d.f.   4459    Pr(> chi2) 0.0000    g        0.142    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -5.38008 -0.48226  0.02194  0.51100  6.23856 
##  
##  
##            Coef    S.E.   t     Pr(>|t|)
##  Intercept -0.2790 0.0828 -3.37 0.0008  
##  g          0.0941 0.0146  6.47 <0.0001 
##  education  0.0210 0.0062  3.40 0.0007  
## 
ols(ncv ~ g + education, data = d_white_adj)
## Linear Regression Model
##  
##  ols(formula = ncv ~ g + education, data = d_white_adj)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs    3654    LR chi2     44.97    R2       0.012    
##  sigma0.8740    d.f.            2    R2 adj   0.012    
##  d.f.   3651    Pr(> chi2) 0.0000    g        0.110    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -4.47049 -0.53475  0.02179  0.56756  4.19471 
##  
##  
##            Coef    S.E.   t     Pr(>|t|)
##  Intercept -0.3524 0.1025 -3.44 0.0006  
##  g          0.0484 0.0184  2.63 0.0085  
##  education  0.0264 0.0076  3.47 0.0005  
## 
#path model for mediation
med_model = "
ncv ~ g + education
education ~ g"

#estimate
sem(med_model, data = d) %>% parameterestimates()
##         lhs op       rhs   est    se    z pvalue ci.lower ci.upper
## 1       ncv  ~         g 0.094 0.015  6.5  0.000    0.066    0.123
## 2       ncv  ~ education 0.021 0.006  3.4  0.001    0.009    0.033
## 3 education  ~         g 1.287 0.030 43.5  0.000    1.229    1.345
## 4       ncv ~~       ncv 0.628 0.013 47.2  0.000    0.602    0.654
## 5 education ~~ education 3.702 0.078 47.2  0.000    3.548    3.856
## 6         g ~~         g 0.947 0.000   NA     NA    0.947    0.947
sem(med_model, data = d_adj) %>% parameterestimates()
##         lhs op       rhs   est    se    z pvalue ci.lower ci.upper
## 1       ncv  ~         g 0.049 0.018  2.7  0.007    0.014    0.084
## 2       ncv  ~ education 0.040 0.008  5.1  0.000    0.025    0.055
## 3 education  ~         g 1.298 0.028 45.8  0.000    1.242    1.353
## 4       ncv ~~       ncv 0.984 0.021 47.2  0.000    0.943    1.025
## 5 education ~~ education 3.587 0.076 47.2  0.000    3.438    3.735
## 6         g ~~         g 1.000 0.000   NA     NA    1.000    1.000
sem(med_model, data = d_white_adj) %>% parameterestimates()
##         lhs op       rhs   est    se    z pvalue ci.lower ci.upper
## 1       ncv  ~         g 0.048 0.018  2.6  0.008    0.012    0.084
## 2       ncv  ~ education 0.026 0.008  3.5  0.001    0.012    0.041
## 3 education  ~         g 1.414 0.032 43.7  0.000    1.351    1.478
## 4       ncv ~~       ncv 0.763 0.018 42.7  0.000    0.728    0.798
## 5 education ~~ education 3.607 0.084 42.7  0.000    3.441    3.772
## 6         g ~~         g 0.942 0.000   NA     NA    0.942    0.942

Export data

#complete data as RDS
readr::write_rds(d, "data/VES_NCV.rds", compress = "gz")

#CSVs
write_csv(d, "data/d.csv", na = "")
write_csv(d_adj, "data/d_adj.csv", na = "")

Versions

write_sessioninfo()
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Linux Mint 19.1
## 
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] rms_5.1-3          SparseM_1.77       lavaan_0.6-3      
##  [4] haven_2.1.0        kirkegaard_2018.05 metafor_2.0-0     
##  [7] Matrix_1.2-17      psych_1.8.12       magrittr_1.5      
## [10] assertthat_0.2.1   weights_1.0        mice_3.4.0        
## [13] gdata_2.18.0       Hmisc_4.2-0        Formula_1.2-3     
## [16] survival_2.43-3    lattice_0.20-38    forcats_0.4.0     
## [19] stringr_1.4.0      dplyr_0.8.0.1      purrr_0.3.2       
## [22] readr_1.3.1        tidyr_0.8.3        tibble_2.1.1      
## [25] ggplot2_3.1.1      tidyverse_1.2.1    pacman_0.5.0      
## 
## loaded via a namespace (and not attached):
##   [1] TH.data_1.0-10        minqa_1.2.4           colorspace_1.4-1     
##   [4] ellipsis_0.1.0        nFactors_2.3.3        class_7.3-15         
##   [7] rio_0.5.16            htmlTable_1.13.1      base64enc_0.1-3      
##  [10] rstudioapi_0.10       MatrixModels_0.4-1    fansi_0.4.0          
##  [13] mvtnorm_1.0-10        lubridate_1.7.4       ranger_0.11.1        
##  [16] xml2_1.2.0            codetools_0.2-16      splines_3.5.3        
##  [19] mnormt_1.5-5          robustbase_0.93-3     knitr_1.22           
##  [22] jsonlite_1.6          lsr_0.5               nloptr_1.2.1         
##  [25] broom_0.5.2           cluster_2.0.8         compiler_3.5.3       
##  [28] httr_1.4.0            backports_1.1.4       lazyeval_0.2.2       
##  [31] cli_1.1.0             acepack_1.4.1         htmltools_0.3.6      
##  [34] quantreg_5.38         tools_3.5.3           gtable_0.3.0         
##  [37] glue_1.3.1            Rcpp_1.0.1            carData_3.0-2        
##  [40] cellranger_1.1.0      nlme_3.1-139          multilevel_2.6       
##  [43] lmtest_0.9-36         laeken_0.5.0          xfun_0.6             
##  [46] Rcsdp_0.1.55          openxlsx_4.1.0        lme4_1.1-21          
##  [49] rvest_0.3.3           gtools_3.8.1          polspline_1.1.14     
##  [52] pan_1.6               DEoptimR_1.0-8        MASS_7.3-51.1        
##  [55] zoo_1.8-4             scales_1.0.0          VIM_4.8.0            
##  [58] hms_0.4.2             parallel_3.5.3        sandwich_2.5-0       
##  [61] RColorBrewer_1.1-2    psychometric_2.2      yaml_2.2.0           
##  [64] curl_3.3              gridExtra_2.3         rpart_4.1-13         
##  [67] latticeExtra_0.6-28   stringi_1.4.3         e1071_1.7-0.1        
##  [70] checkmate_1.9.1       zip_1.0.0             boot_1.3-20          
##  [73] rlang_0.3.4           pkgconfig_2.0.2       evaluate_0.13        
##  [76] htmlwidgets_1.3       labeling_0.3          tidyselect_0.2.5     
##  [79] plyr_1.8.4            R6_2.4.0              generics_0.0.2       
##  [82] mitml_0.3-7           multcomp_1.4-10       mgcv_1.8-28          
##  [85] pillar_1.3.1          foreign_0.8-70        withr_2.1.2          
##  [88] abind_1.4-5           sp_1.3-1              nnet_7.3-12          
##  [91] modelr_0.1.4          crayon_1.3.4          car_3.0-2            
##  [94] jomo_2.6-7            utf8_1.1.4            rmarkdown_1.12       
##  [97] grid_3.5.3            readxl_1.3.1          data.table_1.12.2    
## [100] pbivnorm_0.6.0        vcd_1.4-4             digest_0.6.18        
## [103] GPArotation_2014.11-1 stats4_3.5.3          munsell_0.5.0