Init

options(digits = 2)
library(pacman)
p_load(kirkegaard, readxl, rms)
theme_set(theme_bw())

Data

Data are from Jensen, A. R. (1970). IQ’s of identical twins reared apart. Behavior Genetics, l, 133-148.

#read data
jensen = read_excel("data/Jensen 1970.xlsx")

#show data
jensen

Results

#overall
GG_scatter(jensen, "A", "B", color = "Source")

ggplot(jensen, aes(A, B)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap("Source")

#color by country
GG_scatter(jensen, "A", "B", color = "Country")

ggplot(jensen, aes(A, B)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap("Country")

#differences
jensen %<>% mutate(
  delta = A - B,
  abs_delta = abs(delta)
)

#distributions of deltas
GG_denhist(jensen, "delta", "Source", vline = F)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

GG_denhist(jensen, "abs_delta", "Source", vline = F)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

#numerics
#range restriction adjust
jensen %>% 
  group_by(Source) %>% 
  summarise(
    n = n(),
    r = wtd.cors(A, B),
    mean_A = mean(A),
    mean_B = mean(B),
    mean_mean = mean(mean_A, mean_B),
    sd_A = sd(A),
    sd_B = sd(B),
    sd_mean = mean(sd_A, sd_B),
    r_cor = rangeCorrection(r, sdu = 15, sdr = sd_mean, case=2)
  )
#models
ols(A ~ B, data = jensen)
## Linear Regression Model
##  
##  ols(formula = A ~ B, data = jensen)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs     122    LR chi2    139.49    R2       0.681    
##  sigma7.7065    d.f.            1    R2 adj   0.679    
##  d.f.    120    Pr(> chi2) 0.0000    g       12.824    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -18.7819  -4.9573  -0.4713   5.2658  22.8402 
##  
##  
##            Coef    S.E.   t     Pr(>|t|)
##  Intercept 23.5359 4.6290  5.08 <0.0001 
##  B          0.7568 0.0473 16.01 <0.0001 
## 
ols(A ~ B + Source, data = jensen)
## Linear Regression Model
##  
##  ols(formula = A ~ B + Source, data = jensen)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs     122    LR chi2    141.66    R2       0.687    
##  sigma7.7356    d.f.            4    R2 adj   0.676    
##  d.f.    117    Pr(> chi2) 0.0000    g       12.873    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -17.4786  -5.2505  -0.4846   4.7495  23.0357 
##  
##  
##                      Coef    S.E.   t     Pr(>|t|)
##  Intercept           25.5801 4.9175  5.20 <0.0001 
##  B                    0.7383 0.0491 15.03 <0.0001 
##  Source=Juel-Nielsen  2.4426 2.5123  0.97 0.3329  
##  Source=Newman       -0.5370 2.0709 -0.26 0.7959  
##  Source=Shields      -1.3116 1.6605 -0.79 0.4312  
## 
ols(A ~ B * Source, data = jensen)
## Linear Regression Model
##  
##  ols(formula = A ~ B * Source, data = jensen)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs     122    LR chi2    147.22    R2       0.701    
##  sigma7.6600    d.f.            7    R2 adj   0.682    
##  d.f.    114    Pr(> chi2) 0.0000    g       12.990    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -16.4311  -5.0639  -0.3369   5.0465  22.5941 
##  
##  
##                          Coef    S.E.    t     Pr(>|t|)
##  Intercept               15.1999  6.8990  2.20 0.0296  
##  B                        0.8445  0.0698 12.11 <0.0001 
##  Source=Juel-Nielsen     40.4130 22.8897  1.77 0.0801  
##  Source=Newman           21.3130 14.3194  1.49 0.1394  
##  Source=Shields          14.9619 10.6723  1.40 0.1637  
##  B * Source=Juel-Nielsen -0.3647  0.2150 -1.70 0.0926  
##  B * Source=Newman       -0.2261  0.1474 -1.53 0.1279  
##  B * Source=Shields      -0.1696  0.1111 -1.53 0.1298  
## 
ols(A ~ B + Country, data = jensen)
## Linear Regression Model
##  
##  ols(formula = A ~ B + Country, data = jensen)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs     122    LR chi2    141.01    R2       0.685    
##  sigma7.7232    d.f.            3    R2 adj   0.677    
##  d.f.    118    Pr(> chi2) 0.0000    g       12.865    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -18.3194  -5.1164  -0.4981   4.7645  23.0557 
##  
##  
##                         Coef    S.E.   t     Pr(>|t|)
##  Intercept              27.4455 5.6437  4.86 <0.0001 
##  B                       0.7437 0.0486 15.31 <0.0001 
##  Country=United Kingdom -2.9309 2.4312 -1.21 0.2304  
##  Country=United States  -2.9197 2.8981 -1.01 0.3158  
## 
ols(A ~ B * Country, data = jensen)
## Linear Regression Model
##  
##  ols(formula = A ~ B * Country, data = jensen)
##  
##                 Model Likelihood     Discrimination    
##                    Ratio Test           Indexes        
##  Obs     122    LR chi2    144.27    R2       0.693    
##  sigma7.6862    d.f.            5    R2 adj   0.680    
##  d.f.    116    Pr(> chi2) 0.0000    g       12.969    
##  
##  Residuals
##  
##       Min       1Q   Median       3Q      Max 
##  -18.8849  -5.0639  -0.4331   4.4666  22.5941 
##  
##  
##                             Coef     S.E.    t     Pr(>|t|)
##  Intercept                   55.6129 21.8999  2.54 0.0124  
##  B                            0.4798  0.2041  2.35 0.0204  
##  Country=United Kingdom     -34.9040 22.5129 -1.55 0.1238  
##  Country=United States      -19.1000 25.2613 -0.76 0.4511  
##  B * Country=United Kingdom   0.3036  0.2111  1.44 0.1530  
##  B * Country=United States    0.1386  0.2421  0.57 0.5682  
## 
#LR test of additional predictors
lrtest(ols(A ~ B, data = jensen),
       ols(A ~ B * Source, data = jensen))
## 
## Model 1: A ~ B
## Model 2: A ~ B * Source
## 
## L.R. Chisq       d.f.          P 
##       7.73       6.00       0.26
lrtest(ols(A ~ B, data = jensen),
       ols(A ~ B * Country, data = jensen))
## 
## Model 1: A ~ B
## Model 2: A ~ B * Country
## 
## L.R. Chisq       d.f.          P 
##       4.78       4.00       0.31