# Interactions and scale

Author

Gibran Hemani

Published

July 5, 2023

## Background

Absolute and relative risks will change across populations if the baseline risks are different.

For example, suppose BMI increases CHD by 20% per SD. BMI is distributed differently in two populations

``library(dplyr)``
``````
Attaching package: 'dplyr'``````
``````The following objects are masked from 'package:stats':

filter, lag``````
``````The following objects are masked from 'package:base':

intersect, setdiff, setequal, union``````
``````n <- 10000000

dat <- tibble(
bmi_1 = rnorm(n, 25, sd=5),
bmi_2 = rnorm(n, 20, sd=5),
chdr_1 = 0.2,
chdr_2 = 0.2
)

dat\$chdr_1[dat\$bmi_1 > 27] <- 0.2*1.5
dat\$chdr_2[dat\$bmi_2 > 27] <- 0.2*1.5

dat\$chd_1 <- rbinom(n, 1, dat\$chdr_1)
dat\$chd_2 <- rbinom(n, 1, dat\$chdr_2)

dat``````
``````# A tibble: 10,000,000 × 6
bmi_1 bmi_2 chdr_1 chdr_2 chd_1 chd_2
<dbl> <dbl>  <dbl>  <dbl> <int> <int>
1  17.9  22.4    0.2    0.2     0     0
2  31.9  20.3    0.3    0.2     0     0
3  24.1  23.3    0.2    0.2     0     0
4  21.2  21.6    0.2    0.2     0     1
5  28.5  13.7    0.3    0.2     1     1
6  21.6  30.7    0.2    0.3     1     0
7  26.6  19.3    0.2    0.2     0     0
8  18.8  25.9    0.2    0.2     0     0
9  21.0  26.6    0.2    0.2     0     1
10  25.1  24.1    0.2    0.2     1     0
# ℹ 9,999,990 more rows``````
``mean(dat\$chdr_1)``
``[1] 0.2344512``
``mean(dat\$chdr_2)``
``[1] 0.2080624``
``mean(dat\$chd_1)``
``[1] 0.2345312``
``mean(dat\$chd_2)``
``[1] 0.2079281``
``````rr1 <- mean(dat\$chd_1[dat\$bmi_1 > 27]) / mean(dat\$chd_1)
rr2 <- mean(dat\$chd_2[dat\$bmi_2 > 27]) / mean(dat\$chd_2)
rr1``````
``[1] 1.279043``
``rr2``
``[1] 1.440206``
``glm(chd_1 ~ bmi_1, dat, family="binomial")\$coef[2]``
``````     bmi_1
0.04133235 ``````
``glm(chd_2 ~ bmi_2, dat, family="binomial")\$coef[2]``
``````     bmi_2
0.01829569 ``````
``glm(chd_1 ~ bmi_1>27, dat, family="binomial")\$coef[2]``
``````bmi_1 > 27TRUE
0.5380365 ``````
``glm(chd_2 ~ bmi_2>27, dat, family="binomial")\$coef[2]``
``````bmi_2 > 27TRUE
0.5370367 ``````
``lm(chd_1 ~ bmi_1>27, dat)\$coef[2]``
``````bmi_1 > 27TRUE
0.09984052 ``````
``lm(chd_2 ~ bmi_2>27, dat)\$coef[2]``
``````bmi_2 > 27TRUE
0.09955787 ``````
``lm(chd_1 ~ bmi_1>27, dat)\$coef[2]``
``````bmi_1 > 27TRUE
0.09984052 ``````
``lm(chd_2 ~ bmi_2>27, dat)\$coef[2]``
``````bmi_2 > 27TRUE
0.09955787 ``````

``sessionInfo()``
``````R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.6.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] dplyr_1.1.2

loaded via a namespace (and not attached):
[1] digest_0.6.31     utf8_1.2.3        R6_2.5.1          fastmap_1.1.1
[5] tidyselect_1.2.0  xfun_0.39         magrittr_2.0.3    glue_1.6.2
[9] tibble_3.2.1      knitr_1.43        pkgconfig_2.0.3   htmltools_0.5.5
[13] generics_0.1.3    rmarkdown_2.22    lifecycle_1.0.3   cli_3.6.1
[17] fansi_1.0.4       vctrs_0.6.2       compiler_4.3.0    rstudioapi_0.14
[21] tools_4.3.0       pillar_1.9.0      evaluate_0.21     yaml_2.3.7
[25] rlang_1.1.1       jsonlite_1.8.5    htmlwidgets_1.6.2``````