Krummhörn (1720-1850) robustness analyses

Loading details

source("0__helpers.R")
opts_chunk$set(warning=TRUE, cache=F,cache.lazy=F,tidy=FALSE,autodep=TRUE,dev=c('png','pdf'),fig.width=20,fig.height=12.5,out.width='1440px',out.height='900px',cache.extra=file.info('swed1.rdata')[, 'mtime'])

make_path = function(file) {
    get_coefficient_path(file, "krmh")
} 
# options for each chunk calling knit_child
opts_chunk$set(warning=FALSE, message = FALSE)

Analysis description

Data subset

The krmh.1 dataset contains only those participants where paternal age is known, the birthdate is between 1720 and 1850 and the marriage is known (meaning we know when it started and how it ended by spousal death). In known marriages we can assume that missing death dates for the kids mean that they migrated out.

Model description

All of the following models are the same as our main model m3, except for the noted changes to test robustness.

r1: Relaxed exclusion criteria

For the four historical populations, we imposed quite stringent exclusion criteria to ensure sufficient data quality for our intended analysis. This was not necessary for the modern Swedish data, because there were no exclusion criteria to relax.

model_filename = make_path("r1_relaxed_exclusion_criteria")
if (file.exists(model_filename)) {
    cat(summarise_model())
    r1 = model
}

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 11848) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2897) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.21     0.25        927 1.01
## sd(hu_Intercept)     0.54      0.04     0.47     0.62        874 1.00
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.87      0.28     1.30     2.38        132
## paternalage                   0.04      0.05    -0.05     0.14        757
## birth_cohort1670M1700        -0.02      0.31    -0.59     0.62        152
## birth_cohort1700M1720        -0.09      0.29    -0.62     0.52        143
## birth_cohort1720M1760        -0.20      0.28    -0.70     0.37        129
## birth_cohort1760M1765        -0.15      0.28    -0.67     0.42        132
## birth_cohort1765M1770        -0.30      0.28    -0.80     0.28        134
## birth_cohort1770M1775        -0.30      0.28    -0.80     0.27        131
## birth_cohort1775M1780        -0.22      0.28    -0.72     0.36        131
## birth_cohort1780M1785        -0.30      0.28    -0.81     0.26        131
## birth_cohort1785M1790        -0.26      0.28    -0.77     0.32        131
## birth_cohort1790M1795        -0.24      0.28    -0.73     0.34        130
## birth_cohort1795M1800        -0.29      0.28    -0.79     0.28        131
## birth_cohort1800M1805        -0.29      0.28    -0.80     0.28        130
## birth_cohort1805M1810        -0.30      0.28    -0.80     0.27        130
## birth_cohort1810M1815        -0.27      0.28    -0.77     0.30        130
## birth_cohort1815M1820        -0.34      0.28    -0.84     0.24        129
## birth_cohort1820M1825        -0.39      0.28    -0.89     0.18        130
## birth_cohort1825M1830        -0.39      0.28    -0.88     0.19        129
## birth_cohort1830M1835        -0.38      0.28    -0.88     0.19        129
## male1                         0.09      0.01     0.06     0.12       3000
## maternalage.factor1420       -0.08      0.08    -0.23     0.07       3000
## maternalage.factor3550        0.01      0.03    -0.04     0.06       3000
## paternalage.mean             -0.05      0.05    -0.16     0.04        770
## paternal_loss01              -0.20      0.07    -0.34    -0.06       3000
## paternal_loss15              -0.06      0.05    -0.15     0.04       3000
## paternal_loss510             -0.07      0.04    -0.15     0.01       1793
## paternal_loss1015             0.02      0.04    -0.06     0.09       1724
## paternal_loss1520            -0.08      0.04    -0.15    -0.01       1970
## paternal_loss2025            -0.11      0.03    -0.18    -0.04       2032
## paternal_loss2530            -0.02      0.03    -0.08     0.04       1577
## paternal_loss3035            -0.03      0.03    -0.09     0.03       1593
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1930
## paternal_loss4045            -0.01      0.03    -0.08     0.05       3000
## paternal_lossunclear         -0.05      0.04    -0.13     0.04       1813
## maternal_loss01               0.09      0.07    -0.06     0.23       3000
## maternal_loss15              -0.01      0.04    -0.10     0.08       3000
## maternal_loss510              0.06      0.04    -0.02     0.14       1944
## maternal_loss1015             0.03      0.04    -0.05     0.10       3000
## maternal_loss1520            -0.01      0.04    -0.09     0.06       3000
## maternal_loss2025            -0.01      0.04    -0.08     0.07       3000
## maternal_loss2530            -0.04      0.03    -0.11     0.02       3000
## maternal_loss3035            -0.04      0.03    -0.10     0.02       1225
## maternal_loss3540            -0.04      0.03    -0.10     0.01       3000
## maternal_loss4045            -0.01      0.03    -0.07     0.05       3000
## maternal_lossunclear         -0.10      0.04    -0.19    -0.02       3000
## older_siblings1               0.03      0.02    -0.02     0.08       1473
## older_siblings2              -0.03      0.03    -0.09     0.04        920
## older_siblings3              -0.06      0.04    -0.14     0.03        791
## older_siblings4              -0.05      0.06    -0.16     0.06        797
## older_siblings5P             -0.05      0.07    -0.20     0.08        833
## nr.siblings                   0.00      0.01    -0.01     0.02        892
## last_born1                   -0.03      0.02    -0.07     0.01       3000
## hu_Intercept                 -1.22      0.82    -2.82     0.44        129
## hu_paternalage                0.31      0.13     0.05     0.56        983
## hu_birth_cohort1670M1700      1.05      0.90    -0.76     2.89        144
## hu_birth_cohort1700M1720      0.17      0.85    -1.58     1.83        132
## hu_birth_cohort1720M1760      0.83      0.81    -0.80     2.41        123
## hu_birth_cohort1760M1765      0.80      0.82    -0.85     2.41        124
## hu_birth_cohort1765M1770      0.63      0.81    -1.01     2.21        123
## hu_birth_cohort1770M1775      0.77      0.81    -0.87     2.35        124
## hu_birth_cohort1775M1780      0.70      0.81    -0.95     2.29        127
## hu_birth_cohort1780M1785      0.58      0.81    -1.07     2.19        123
## hu_birth_cohort1785M1790      0.45      0.81    -1.18     2.04        123
## hu_birth_cohort1790M1795      0.56      0.81    -1.10     2.17        123
## hu_birth_cohort1795M1800      0.35      0.81    -1.28     1.94        123
## hu_birth_cohort1800M1805      0.26      0.81    -1.42     1.84        124
## hu_birth_cohort1805M1810      0.52      0.81    -1.13     2.10        124
## hu_birth_cohort1810M1815      0.36      0.81    -1.28     1.93        123
## hu_birth_cohort1815M1820      0.11      0.81    -1.55     1.69        124
## hu_birth_cohort1820M1825      0.28      0.81    -1.37     1.87        124
## hu_birth_cohort1825M1830      0.23      0.81    -1.42     1.81        123
## hu_birth_cohort1830M1835      0.23      0.81    -1.43     1.81        123
## hu_male1                      0.26      0.04     0.18     0.35       3000
## hu_maternalage.factor1420     0.16      0.20    -0.22     0.56       3000
## hu_maternalage.factor3550     0.10      0.07    -0.03     0.23       3000
## hu_paternalage.mean          -0.20      0.13    -0.46     0.06       1049
## hu_paternal_loss01            0.67      0.17     0.33     1.01       3000
## hu_paternal_loss15            0.58      0.12     0.34     0.82       1999
## hu_paternal_loss510           0.25      0.11     0.03     0.46       1983
## hu_paternal_loss1015          0.20      0.10     0.01     0.40       1689
## hu_paternal_loss1520          0.17      0.10    -0.03     0.37       1847
## hu_paternal_loss2025          0.16      0.09    -0.03     0.34       1641
## hu_paternal_loss2530          0.09      0.09    -0.08     0.26       1580
## hu_paternal_loss3035          0.02      0.09    -0.15     0.19       1681
## hu_paternal_loss3540          0.03      0.09    -0.14     0.20       1740
## hu_paternal_loss4045          0.10      0.09    -0.09     0.28       3000
## hu_paternal_lossunclear       0.55      0.11     0.34     0.76       1847
## hu_maternal_loss01            1.60      0.18     1.26     1.94       3000
## hu_maternal_loss15            0.60      0.11     0.38     0.82       3000
## hu_maternal_loss510           0.53      0.10     0.33     0.73       3000
## hu_maternal_loss1015          0.41      0.10     0.20     0.62       3000
## hu_maternal_loss1520          0.33      0.10     0.13     0.54       3000
## hu_maternal_loss2025          0.27      0.10     0.08     0.46       3000
## hu_maternal_loss2530          0.14      0.09    -0.03     0.32       3000
## hu_maternal_loss3035          0.17      0.08     0.02     0.33       3000
## hu_maternal_loss3540          0.09      0.08    -0.06     0.25       3000
## hu_maternal_loss4045          0.28      0.08     0.12     0.43       3000
## hu_maternal_lossunclear       0.86      0.10     0.67     1.06       3000
## hu_older_siblings1           -0.02      0.06    -0.14     0.11       1758
## hu_older_siblings2           -0.16      0.09    -0.33     0.01       1140
## hu_older_siblings3           -0.20      0.11    -0.42     0.03        946
## hu_older_siblings4           -0.23      0.14    -0.51     0.05        954
## hu_older_siblings5P          -0.53      0.19    -0.90    -0.17        975
## hu_nr.siblings                0.09      0.02     0.06     0.13       1241
## hu_last_born1                 0.05      0.06    -0.06     0.16       3000
##                           Rhat
## Intercept                 1.03
## paternalage               1.00
## birth_cohort1670M1700     1.02
## birth_cohort1700M1720     1.02
## birth_cohort1720M1760     1.03
## birth_cohort1760M1765     1.03
## birth_cohort1765M1770     1.03
## birth_cohort1770M1775     1.03
## birth_cohort1775M1780     1.03
## birth_cohort1780M1785     1.03
## birth_cohort1785M1790     1.03
## birth_cohort1790M1795     1.03
## birth_cohort1795M1800     1.03
## birth_cohort1800M1805     1.03
## birth_cohort1805M1810     1.03
## birth_cohort1810M1815     1.03
## birth_cohort1815M1820     1.03
## birth_cohort1820M1825     1.03
## birth_cohort1825M1830     1.03
## birth_cohort1830M1835     1.03
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.00
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## paternal_lossunclear      1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## maternal_lossunclear      1.00
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.00
## older_siblings4           1.00
## older_siblings5P          1.00
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.03
## hu_paternalage            1.00
## hu_birth_cohort1670M1700  1.03
## hu_birth_cohort1700M1720  1.03
## hu_birth_cohort1720M1760  1.03
## hu_birth_cohort1760M1765  1.03
## hu_birth_cohort1765M1770  1.03
## hu_birth_cohort1770M1775  1.03
## hu_birth_cohort1775M1780  1.03
## hu_birth_cohort1780M1785  1.03
## hu_birth_cohort1785M1790  1.03
## hu_birth_cohort1790M1795  1.03
## hu_birth_cohort1795M1800  1.03
## hu_birth_cohort1800M1805  1.03
## hu_birth_cohort1805M1810  1.03
## hu_birth_cohort1810M1815  1.03
## hu_birth_cohort1815M1820  1.03
## hu_birth_cohort1820M1825  1.03
## hu_birth_cohort1825M1830  1.03
## hu_birth_cohort1830M1835  1.03
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_paternal_lossunclear   1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_maternal_lossunclear   1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.00
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 6.462 3.656 10.8
paternalage 1.041 0.9472 1.15
birth_cohort1670M1700 0.9843 0.5557 1.866
birth_cohort1700M1720 0.918 0.5364 1.677
birth_cohort1720M1760 0.8172 0.4943 1.452
birth_cohort1760M1765 0.8579 0.5098 1.523
birth_cohort1765M1770 0.7434 0.448 1.324
birth_cohort1770M1775 0.7402 0.4477 1.312
birth_cohort1775M1780 0.8028 0.4858 1.43
birth_cohort1780M1785 0.7383 0.446 1.301
birth_cohort1785M1790 0.7701 0.463 1.373
birth_cohort1790M1795 0.7895 0.4806 1.401
birth_cohort1795M1800 0.7483 0.4517 1.325
birth_cohort1800M1805 0.7463 0.4513 1.326
birth_cohort1805M1810 0.7419 0.4506 1.314
birth_cohort1810M1815 0.7627 0.4622 1.35
birth_cohort1815M1820 0.709 0.4306 1.276
birth_cohort1820M1825 0.6803 0.4118 1.198
birth_cohort1825M1830 0.6802 0.4138 1.207
birth_cohort1830M1835 0.6832 0.4161 1.207
male1 1.09 1.058 1.122
maternalage.factor1420 0.9207 0.7912 1.073
maternalage.factor3550 1.009 0.9601 1.061
paternalage.mean 0.9485 0.8559 1.045
paternal_loss01 0.8212 0.7138 0.9382
paternal_loss15 0.946 0.8604 1.038
paternal_loss510 0.9311 0.8609 1.009
paternal_loss1015 1.016 0.9422 1.095
paternal_loss1520 0.9229 0.8588 0.9902
paternal_loss2025 0.8948 0.8365 0.9583
paternal_loss2530 0.9797 0.9206 1.04
paternal_loss3035 0.9689 0.9137 1.028
paternal_loss3540 0.9901 0.9326 1.052
paternal_loss4045 0.9861 0.9224 1.054
paternal_lossunclear 0.9542 0.8802 1.036
maternal_loss01 1.098 0.9458 1.265
maternal_loss15 0.9873 0.9024 1.079
maternal_loss510 1.058 0.977 1.145
maternal_loss1015 1.029 0.9531 1.11
maternal_loss1520 0.9905 0.9156 1.066
maternal_loss2025 0.9941 0.9257 1.067
maternal_loss2530 0.9581 0.8984 1.024
maternal_loss3035 0.9603 0.9041 1.02
maternal_loss3540 0.9562 0.9056 1.008
maternal_loss4045 0.9898 0.9327 1.05
maternal_lossunclear 0.9023 0.8299 0.983
older_siblings1 1.033 0.9837 1.084
older_siblings2 0.9739 0.9126 1.04
older_siblings3 0.9452 0.8728 1.027
older_siblings4 0.9524 0.855 1.06
older_siblings5P 0.9474 0.8209 1.088
nr.siblings 1.005 0.9923 1.018
last_born1 0.9699 0.9293 1.01
hu_Intercept 0.2954 0.05966 1.55
hu_paternalage 1.364 1.054 1.754
hu_birth_cohort1670M1700 2.869 0.4688 18.03
hu_birth_cohort1700M1720 1.188 0.2061 6.237
hu_birth_cohort1720M1760 2.299 0.4491 11.16
hu_birth_cohort1760M1765 2.235 0.4276 11.11
hu_birth_cohort1765M1770 1.877 0.3653 9.075
hu_birth_cohort1770M1775 2.17 0.4184 10.53
hu_birth_cohort1775M1780 2.006 0.3881 9.866
hu_birth_cohort1780M1785 1.793 0.3421 8.924
hu_birth_cohort1785M1790 1.567 0.3061 7.7
hu_birth_cohort1790M1795 1.749 0.3319 8.801
hu_birth_cohort1795M1800 1.421 0.2779 6.976
hu_birth_cohort1800M1805 1.293 0.2413 6.319
hu_birth_cohort1805M1810 1.685 0.322 8.167
hu_birth_cohort1810M1815 1.427 0.277 6.884
hu_birth_cohort1815M1820 1.117 0.212 5.436
hu_birth_cohort1820M1825 1.326 0.2551 6.488
hu_birth_cohort1825M1830 1.255 0.242 6.112
hu_birth_cohort1830M1835 1.253 0.2395 6.086
hu_male1 1.303 1.199 1.418
hu_maternalage.factor1420 1.175 0.8043 1.753
hu_maternalage.factor3550 1.104 0.9676 1.261
hu_paternalage.mean 0.8184 0.6344 1.063
hu_paternal_loss01 1.955 1.397 2.75
hu_paternal_loss15 1.783 1.399 2.265
hu_paternal_loss510 1.284 1.034 1.592
hu_paternal_loss1015 1.225 1.014 1.498
hu_paternal_loss1520 1.186 0.9735 1.444
hu_paternal_loss2025 1.169 0.9723 1.41
hu_paternal_loss2530 1.097 0.9223 1.297
hu_paternal_loss3035 1.022 0.8589 1.214
hu_paternal_loss3540 1.028 0.8698 1.22
hu_paternal_loss4045 1.107 0.917 1.328
hu_paternal_lossunclear 1.741 1.408 2.138
hu_maternal_loss01 4.954 3.534 6.975
hu_maternal_loss15 1.82 1.457 2.262
hu_maternal_loss510 1.698 1.39 2.072
hu_maternal_loss1015 1.51 1.224 1.856
hu_maternal_loss1520 1.395 1.144 1.714
hu_maternal_loss2025 1.31 1.084 1.577
hu_maternal_loss2530 1.147 0.9662 1.371
hu_maternal_loss3035 1.188 1.016 1.394
hu_maternal_loss3540 1.096 0.9445 1.278
hu_maternal_loss4045 1.318 1.126 1.542
hu_maternal_lossunclear 2.368 1.945 2.88
hu_older_siblings1 0.9846 0.8684 1.116
hu_older_siblings2 0.8558 0.7187 1.012
hu_older_siblings3 0.8201 0.6551 1.034
hu_older_siblings4 0.7952 0.601 1.048
hu_older_siblings5P 0.5874 0.4078 0.8462
hu_nr.siblings 1.099 1.063 1.136
hu_last_born1 1.049 0.9372 1.177

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 3.95 [1.55;7.6] [2.23;6.08]
estimate father 35y 3.65 [1.3;7.57] [1.94;5.82]
percentage change -7.11 [-23.86;6.73] [-18.09;2.42]
OR/IRR 1.04 [0.95;1.15] [0.98;1.11]
OR hurdle 1.36 [1.05;1.75] [1.15;1.61]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r1_relaxed_exclusion_criteria.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r2: Fewer covariates

Adding covariates increases the complexity of the model and makes it harder to interpret. We chose to adjust for many potential confounds because we are interested in causal isolation of the paternal age effect. Here we show what happens when only birth cohort and average paternal age in the family are adjusted for.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + paternalage.mean + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + paternalage.mean + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1258    1
## sd(hu_Intercept)     0.50      0.04     0.42     0.58       1017    1
## 
## Population-Level Effects: 
##                          Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                    1.70      0.07     1.56     1.83       1587
## paternalage                 -0.03      0.02    -0.06     0.00       3000
## birth_cohort1760M1765        0.00      0.06    -0.12     0.13       3000
## birth_cohort1765M1770       -0.11      0.06    -0.22    -0.01       1284
## birth_cohort1770M1775       -0.11      0.06    -0.23     0.00       1150
## birth_cohort1775M1780       -0.03      0.06    -0.13     0.08        987
## birth_cohort1780M1785       -0.11      0.06    -0.22     0.00       1058
## birth_cohort1785M1790       -0.10      0.06    -0.21     0.01        996
## birth_cohort1790M1795       -0.08      0.05    -0.18     0.02        956
## birth_cohort1795M1800       -0.10      0.05    -0.20     0.00        910
## birth_cohort1800M1805       -0.11      0.05    -0.21    -0.01        831
## birth_cohort1805M1810       -0.13      0.05    -0.23    -0.03        927
## birth_cohort1810M1815       -0.10      0.05    -0.19     0.00        843
## birth_cohort1815M1820       -0.14      0.05    -0.23    -0.05        800
## birth_cohort1820M1825       -0.19      0.05    -0.27    -0.09        799
## birth_cohort1825M1830       -0.22      0.05    -0.31    -0.13        793
## birth_cohort1830M1835       -0.19      0.05    -0.29    -0.10        878
## paternalage.mean             0.01      0.02    -0.03     0.06       3000
## hu_Intercept                 0.64      0.17     0.30     0.98       1615
## hu_paternalage               0.22      0.05     0.13     0.31       3000
## hu_birth_cohort1760M1765    -0.06      0.17    -0.38     0.28       3000
## hu_birth_cohort1765M1770    -0.35      0.15    -0.63    -0.06       1419
## hu_birth_cohort1770M1775    -0.16      0.15    -0.44     0.13       1263
## hu_birth_cohort1775M1780    -0.25      0.15    -0.54     0.04       1305
## hu_birth_cohort1780M1785    -0.32      0.15    -0.60    -0.03       1274
## hu_birth_cohort1785M1790    -0.49      0.15    -0.78    -0.21       1297
## hu_birth_cohort1790M1795    -0.40      0.14    -0.67    -0.14       1129
## hu_birth_cohort1795M1800    -0.55      0.13    -0.81    -0.31       1057
## hu_birth_cohort1800M1805    -0.64      0.13    -0.90    -0.39       1021
## hu_birth_cohort1805M1810    -0.37      0.13    -0.61    -0.12        999
## hu_birth_cohort1810M1815    -0.53      0.12    -0.77    -0.29       1013
## hu_birth_cohort1815M1820    -0.81      0.12    -1.04    -0.57       1004
## hu_birth_cohort1820M1825    -0.67      0.12    -0.90    -0.44        971
## hu_birth_cohort1825M1830    -0.66      0.12    -0.88    -0.43        953
## hu_birth_cohort1830M1835    -0.66      0.12    -0.90    -0.43        936
## hu_paternalage.mean         -0.14      0.06    -0.25    -0.02       3000
##                          Rhat
## Intercept                1.00
## paternalage              1.00
## birth_cohort1760M1765    1.00
## birth_cohort1765M1770    1.00
## birth_cohort1770M1775    1.00
## birth_cohort1775M1780    1.01
## birth_cohort1780M1785    1.00
## birth_cohort1785M1790    1.00
## birth_cohort1790M1795    1.00
## birth_cohort1795M1800    1.00
## birth_cohort1800M1805    1.00
## birth_cohort1805M1810    1.00
## birth_cohort1810M1815    1.00
## birth_cohort1815M1820    1.00
## birth_cohort1820M1825    1.00
## birth_cohort1825M1830    1.00
## birth_cohort1830M1835    1.00
## paternalage.mean         1.00
## hu_Intercept             1.00
## hu_paternalage           1.00
## hu_birth_cohort1760M1765 1.00
## hu_birth_cohort1765M1770 1.00
## hu_birth_cohort1770M1775 1.00
## hu_birth_cohort1775M1780 1.00
## hu_birth_cohort1780M1785 1.01
## hu_birth_cohort1785M1790 1.00
## hu_birth_cohort1790M1795 1.01
## hu_birth_cohort1795M1800 1.00
## hu_birth_cohort1800M1805 1.01
## hu_birth_cohort1805M1810 1.01
## hu_birth_cohort1810M1815 1.01
## hu_birth_cohort1815M1820 1.01
## hu_birth_cohort1820M1825 1.01
## hu_birth_cohort1825M1830 1.01
## hu_birth_cohort1830M1835 1.01
## hu_paternalage.mean      1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.449 4.754 6.234
paternalage 0.9717 0.9395 1.005
birth_cohort1760M1765 1.004 0.8848 1.141
birth_cohort1765M1770 0.8918 0.799 0.9949
birth_cohort1770M1775 0.8937 0.7965 1.001
birth_cohort1775M1780 0.9733 0.875 1.084
birth_cohort1780M1785 0.8931 0.7992 0.9993
birth_cohort1785M1790 0.9041 0.8105 1.011
birth_cohort1790M1795 0.9219 0.8335 1.021
birth_cohort1795M1800 0.9021 0.8188 0.9956
birth_cohort1800M1805 0.894 0.8133 0.9888
birth_cohort1805M1810 0.8772 0.7972 0.9666
birth_cohort1810M1815 0.9083 0.8285 0.996
birth_cohort1815M1820 0.8685 0.7959 0.951
birth_cohort1820M1825 0.8303 0.7606 0.9099
birth_cohort1825M1830 0.8026 0.7331 0.8794
birth_cohort1830M1835 0.8231 0.7465 0.9014
paternalage.mean 1.013 0.9663 1.062
hu_Intercept 1.904 1.346 2.671
hu_paternalage 1.244 1.136 1.357
hu_birth_cohort1760M1765 0.9459 0.681 1.329
hu_birth_cohort1765M1770 0.7061 0.53 0.9461
hu_birth_cohort1770M1775 0.8558 0.6418 1.144
hu_birth_cohort1775M1780 0.7783 0.585 1.041
hu_birth_cohort1780M1785 0.7278 0.5478 0.9658
hu_birth_cohort1785M1790 0.6103 0.458 0.8125
hu_birth_cohort1790M1795 0.6717 0.5103 0.8676
hu_birth_cohort1795M1800 0.5744 0.4468 0.7358
hu_birth_cohort1800M1805 0.5292 0.4084 0.6766
hu_birth_cohort1805M1810 0.6937 0.5435 0.8855
hu_birth_cohort1810M1815 0.5878 0.4644 0.7451
hu_birth_cohort1815M1820 0.4461 0.353 0.5634
hu_birth_cohort1820M1825 0.5134 0.407 0.6458
hu_birth_cohort1825M1830 0.5176 0.4157 0.6499
hu_birth_cohort1830M1835 0.5148 0.4057 0.6522
hu_paternalage.mean 0.8712 0.776 0.9808

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.75 [1.51;2.01] [1.59;1.92]
estimate father 35y 1.47 [1.27;1.69] [1.33;1.61]
percentage change -16.37 [-22.17;-10.38] [-20.15;-12.42]
OR/IRR 0.97 [0.94;1] [0.95;0.99]
OR hurdle 1.24 [1.14;1.36] [1.17;1.32]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r2_few_controls.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r3: Continuous birth order control

We chose to control for birth order/number of older siblings as a categorical variable, lumping all those who had more than 5 in the category 5+. Because a continuous covariate is also plausible, we tested this alternative model as well.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1000; warmup = 500; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.25        983 1.00
## sd(hu_Intercept)     0.47      0.05     0.38     0.56        606 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.67      0.08     1.51     1.82        727
## paternalage                   0.03      0.06    -0.09     0.16       1001
## birth_cohort1760M1765         0.00      0.06    -0.13     0.13        904
## birth_cohort1765M1770        -0.12      0.06    -0.23    -0.01        671
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00        619
## birth_cohort1775M1780        -0.02      0.06    -0.13     0.09        590
## birth_cohort1780M1785        -0.11      0.06    -0.23     0.00        638
## birth_cohort1785M1790        -0.09      0.05    -0.20     0.01        585
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.02        485
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        502
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.01        487
## birth_cohort1805M1810        -0.13      0.05    -0.24    -0.03        480
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        433
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        441
## birth_cohort1820M1825        -0.19      0.05    -0.28    -0.09        400
## birth_cohort1825M1830        -0.21      0.05    -0.31    -0.11        434
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        411
## male1                         0.08      0.02     0.05     0.11       3000
## maternalage.factor1420       -0.06      0.09    -0.25     0.11       3000
## maternalage.factor3550        0.00      0.03    -0.05     0.06       3000
## paternalage.mean             -0.03      0.06    -0.16     0.09        993
## paternal_loss01              -0.15      0.07    -0.29     0.00       3000
## paternal_loss15              -0.03      0.05    -0.13     0.06       1685
## paternal_loss510             -0.07      0.04    -0.15     0.02       1626
## paternal_loss1015             0.01      0.04    -0.07     0.08       1263
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1355
## paternal_loss2025            -0.12      0.04    -0.19    -0.04       1112
## paternal_loss2530            -0.01      0.03    -0.08     0.06       1145
## paternal_loss3035            -0.03      0.03    -0.09     0.04       1219
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1054
## paternal_loss4045            -0.01      0.04    -0.08     0.06       1429
## maternal_loss01               0.10      0.08    -0.05     0.25       3000
## maternal_loss15              -0.02      0.05    -0.11     0.07       1717
## maternal_loss510              0.07      0.04    -0.01     0.14       1424
## maternal_loss1015             0.03      0.04    -0.06     0.11       1526
## maternal_loss1520             0.01      0.04    -0.07     0.08       3000
## maternal_loss2025             0.01      0.04    -0.07     0.08       1343
## maternal_loss2530            -0.02      0.03    -0.09     0.04       1280
## maternal_loss3035            -0.05      0.03    -0.12     0.01       1241
## maternal_loss3540            -0.03      0.03    -0.09     0.02       1273
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings               -0.01      0.02    -0.04     0.02       1264
## nr.siblings                   0.01      0.01    -0.01     0.02       1357
## last_born1                   -0.05      0.02    -0.09     0.00       3000
## hu_Intercept                 -0.14      0.20    -0.54     0.28        861
## hu_paternalage                0.57      0.18     0.22     0.92        963
## hu_birth_cohort1760M1765     -0.03      0.17    -0.35     0.31       1044
## hu_birth_cohort1765M1770     -0.30      0.15    -0.58    -0.02        678
## hu_birth_cohort1770M1775     -0.05      0.15    -0.35     0.22        645
## hu_birth_cohort1775M1780     -0.18      0.14    -0.45     0.10        653
## hu_birth_cohort1780M1785     -0.26      0.15    -0.56     0.01        672
## hu_birth_cohort1785M1790     -0.42      0.14    -0.70    -0.13        722
## hu_birth_cohort1790M1795     -0.30      0.14    -0.56    -0.05        607
## hu_birth_cohort1795M1800     -0.45      0.13    -0.70    -0.20        569
## hu_birth_cohort1800M1805     -0.52      0.13    -0.78    -0.27        627
## hu_birth_cohort1805M1810     -0.25      0.13    -0.50     0.00        530
## hu_birth_cohort1810M1815     -0.42      0.12    -0.67    -0.17        493
## hu_birth_cohort1815M1820     -0.69      0.12    -0.92    -0.46        507
## hu_birth_cohort1820M1825     -0.51      0.12    -0.73    -0.28        497
## hu_birth_cohort1825M1830     -0.53      0.12    -0.76    -0.30        537
## hu_birth_cohort1830M1835     -0.55      0.12    -0.78    -0.31        525
## hu_male1                      0.27      0.05     0.18     0.37       3000
## hu_maternalage.factor1420     0.20      0.23    -0.28     0.65       3000
## hu_maternalage.factor3550     0.11      0.07    -0.03     0.25       3000
## hu_paternalage.mean          -0.49      0.18    -0.84    -0.13       1000
## hu_paternal_loss01            0.58      0.19     0.21     0.94       3000
## hu_paternal_loss15            0.52      0.14     0.26     0.80       1286
## hu_paternal_loss510           0.19      0.11    -0.04     0.41       1257
## hu_paternal_loss1015          0.15      0.11    -0.06     0.36       1022
## hu_paternal_loss1520          0.10      0.10    -0.10     0.30        957
## hu_paternal_loss2025          0.16      0.10    -0.04     0.36       1022
## hu_paternal_loss2530          0.06      0.10    -0.13     0.24        900
## hu_paternal_loss3035         -0.02      0.09    -0.20     0.17       1009
## hu_paternal_loss3540         -0.01      0.09    -0.19     0.17        984
## hu_paternal_loss4045          0.14      0.10    -0.05     0.34       1244
## hu_maternal_loss01            1.58      0.19     1.23     1.96       3000
## hu_maternal_loss15            0.58      0.12     0.34     0.82       3000
## hu_maternal_loss510           0.48      0.11     0.27     0.68       3000
## hu_maternal_loss1015          0.47      0.11     0.27     0.69       3000
## hu_maternal_loss1520          0.31      0.11     0.10     0.52       3000
## hu_maternal_loss2025          0.25      0.10     0.06     0.45       3000
## hu_maternal_loss2530          0.19      0.09     0.00     0.37       3000
## hu_maternal_loss3035          0.21      0.08     0.05     0.38       1796
## hu_maternal_loss3540          0.07      0.08    -0.09     0.23       1644
## hu_maternal_loss4045          0.27      0.08     0.11     0.44       3000
## hu_older_siblings            -0.17      0.04    -0.25    -0.08        990
## hu_nr.siblings                0.14      0.02     0.10     0.19       1040
## hu_last_born1                 0.09      0.06    -0.04     0.22       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.00
## birth_cohort1795M1800     1.00
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.00
## birth_cohort1810M1815     1.00
## birth_cohort1815M1820     1.00
## birth_cohort1820M1825     1.00
## birth_cohort1825M1830     1.00
## birth_cohort1830M1835     1.01
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings            1.01
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.01
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.01
## hu_birth_cohort1795M1800  1.01
## hu_birth_cohort1800M1805  1.01
## hu_birth_cohort1805M1810  1.01
## hu_birth_cohort1810M1815  1.01
## hu_birth_cohort1815M1820  1.01
## hu_birth_cohort1820M1825  1.01
## hu_birth_cohort1825M1830  1.01
## hu_birth_cohort1830M1835  1.01
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.01
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings         1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.3 4.522 6.182
paternalage 1.032 0.9124 1.168
birth_cohort1760M1765 0.9996 0.8797 1.135
birth_cohort1765M1770 0.8879 0.7921 0.9918
birth_cohort1770M1775 0.8929 0.7941 0.9984
birth_cohort1775M1780 0.9767 0.8739 1.089
birth_cohort1780M1785 0.8931 0.7929 1.003
birth_cohort1785M1790 0.9108 0.818 1.01
birth_cohort1790M1795 0.9249 0.8352 1.025
birth_cohort1795M1800 0.9003 0.8176 0.9931
birth_cohort1800M1805 0.8955 0.8136 0.9874
birth_cohort1805M1810 0.8742 0.7899 0.97
birth_cohort1810M1815 0.9062 0.8248 1.001
birth_cohort1815M1820 0.8691 0.7939 0.9556
birth_cohort1820M1825 0.8308 0.7567 0.9148
birth_cohort1825M1830 0.8113 0.7366 0.8925
birth_cohort1830M1835 0.8337 0.7571 0.9169
male1 1.082 1.047 1.118
maternalage.factor1420 0.9379 0.7825 1.118
maternalage.factor3550 1.004 0.9511 1.057
paternalage.mean 0.9671 0.854 1.097
paternal_loss01 0.865 0.7492 0.9973
paternal_loss15 0.9661 0.8747 1.065
paternal_loss510 0.9362 0.8627 1.019
paternal_loss1015 1.006 0.9323 1.088
paternal_loss1520 0.9106 0.8458 0.9825
paternal_loss2025 0.8883 0.8249 0.9572
paternal_loss2530 0.9904 0.9254 1.059
paternal_loss3035 0.9724 0.9111 1.036
paternal_loss3540 0.9896 0.9311 1.055
paternal_loss4045 0.9917 0.926 1.064
maternal_loss01 1.105 0.949 1.284
maternal_loss15 0.9826 0.896 1.074
maternal_loss510 1.069 0.9871 1.154
maternal_loss1015 1.027 0.9461 1.111
maternal_loss1520 1.005 0.9315 1.085
maternal_loss2025 1.008 0.933 1.084
maternal_loss2530 0.9779 0.9129 1.046
maternal_loss3035 0.9467 0.886 1.01
maternal_loss3540 0.9663 0.912 1.023
maternal_loss4045 0.971 0.9095 1.032
older_siblings 0.9893 0.9599 1.019
nr.siblings 1.006 0.9894 1.024
last_born1 0.9559 0.9117 1.004
hu_Intercept 0.8698 0.585 1.32
hu_paternalage 1.77 1.25 2.498
hu_birth_cohort1760M1765 0.9697 0.7023 1.359
hu_birth_cohort1765M1770 0.7406 0.5604 0.9838
hu_birth_cohort1770M1775 0.9487 0.7073 1.252
hu_birth_cohort1775M1780 0.8317 0.6359 1.107
hu_birth_cohort1780M1785 0.7673 0.5722 1.012
hu_birth_cohort1785M1790 0.6593 0.4979 0.8792
hu_birth_cohort1790M1795 0.7383 0.573 0.9544
hu_birth_cohort1795M1800 0.6389 0.4967 0.8198
hu_birth_cohort1800M1805 0.593 0.4603 0.7629
hu_birth_cohort1805M1810 0.7798 0.6087 1
hu_birth_cohort1810M1815 0.6544 0.5137 0.8404
hu_birth_cohort1815M1820 0.5019 0.3977 0.6316
hu_birth_cohort1820M1825 0.6015 0.4824 0.7589
hu_birth_cohort1825M1830 0.5888 0.4658 0.7435
hu_birth_cohort1830M1835 0.5772 0.4597 0.7303
hu_male1 1.316 1.201 1.444
hu_maternalage.factor1420 1.217 0.759 1.92
hu_maternalage.factor3550 1.113 0.9658 1.282
hu_paternalage.mean 0.6129 0.4323 0.8774
hu_paternal_loss01 1.784 1.238 2.557
hu_paternal_loss15 1.688 1.302 2.218
hu_paternal_loss510 1.208 0.9583 1.502
hu_paternal_loss1015 1.165 0.9437 1.432
hu_paternal_loss1520 1.105 0.9048 1.348
hu_paternal_loss2025 1.173 0.9621 1.437
hu_paternal_loss2530 1.061 0.8751 1.277
hu_paternal_loss3035 0.982 0.8155 1.187
hu_paternal_loss3540 0.991 0.8237 1.189
hu_paternal_loss4045 1.154 0.9509 1.408
hu_maternal_loss01 4.852 3.405 7.07
hu_maternal_loss15 1.781 1.411 2.261
hu_maternal_loss510 1.612 1.309 1.977
hu_maternal_loss1015 1.6 1.309 1.994
hu_maternal_loss1520 1.367 1.107 1.687
hu_maternal_loss2025 1.289 1.057 1.566
hu_maternal_loss2530 1.205 1.005 1.442
hu_maternal_loss3035 1.237 1.052 1.463
hu_maternal_loss3540 1.068 0.9125 1.254
hu_maternal_loss4045 1.312 1.115 1.549
hu_older_siblings 0.8472 0.7797 0.9202
hu_nr.siblings 1.155 1.105 1.21
hu_last_born1 1.095 0.9649 1.242

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.78 [2.26;3.38] [2.43;3.18]
estimate father 35y 2.12 [1.78;2.52] [1.89;2.39]
percentage change -23.54 [-37.92;-5.4] [-33.32;-12.25]
OR/IRR 1.03 [0.91;1.17] [0.95;1.12]
OR hurdle 1.77 [1.25;2.5] [1.41;2.23]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r3_birth_order_continuous.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r4: Control number of dependent siblings

Birth order is usually used as a proxy variable for parental investment, the assumption being that older siblings require parental attention. However, there are are reasons to doubt this, as fully-grown siblings probably do not compete for the same resources. To compute a clearer proxy variable of competing siblings, we computed and adjusted for the number of siblings who were alive and younger than five at the time of birth of the anchor child.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + nr.siblings + dependent_sibs_f5y + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + nr.siblings + dependent_sibs_f5y + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1000; warmup = 500; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1126 1.00
## sd(hu_Intercept)     0.52      0.04     0.43     0.60        571 1.02
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.65      0.08     1.50     1.80       1208
## paternalage                  -0.02      0.03    -0.07     0.03       1156
## birth_cohort1760M1765         0.00      0.06    -0.13     0.12       1145
## birth_cohort1765M1770        -0.12      0.06    -0.23    -0.01        872
## birth_cohort1770M1775        -0.11      0.06    -0.22     0.00        945
## birth_cohort1775M1780        -0.03      0.06    -0.14     0.09        868
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.00        828
## birth_cohort1785M1790        -0.09      0.06    -0.20     0.01        844
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03        778
## birth_cohort1795M1800        -0.10      0.05    -0.20    -0.01        766
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        704
## birth_cohort1805M1810        -0.13      0.05    -0.23    -0.04        747
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        664
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        632
## birth_cohort1820M1825        -0.18      0.05    -0.28    -0.09        653
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        638
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        690
## male1                         0.08      0.02     0.05     0.11       3000
## maternalage.factor1420       -0.07      0.09    -0.26     0.11       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       1711
## paternalage.mean              0.01      0.03    -0.04     0.08       1505
## paternal_loss01              -0.14      0.07    -0.28     0.01       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       1692
## paternal_loss510             -0.07      0.04    -0.15     0.01       1360
## paternal_loss1015             0.00      0.04    -0.07     0.08       1554
## paternal_loss1520            -0.10      0.04    -0.17    -0.02       1068
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       1244
## paternal_loss2530            -0.01      0.03    -0.08     0.05        819
## paternal_loss3035            -0.03      0.03    -0.10     0.03       1299
## paternal_loss3540            -0.01      0.03    -0.08     0.05       1417
## paternal_loss4045            -0.01      0.04    -0.08     0.06       1546
## maternal_loss01               0.10      0.08    -0.05     0.26       3000
## maternal_loss15              -0.03      0.05    -0.12     0.06       3000
## maternal_loss510              0.07      0.04    -0.01     0.14       1966
## maternal_loss1015             0.03      0.04    -0.05     0.11       1842
## maternal_loss1520             0.01      0.04    -0.07     0.09       2108
## maternal_loss2025             0.01      0.04    -0.07     0.08       1939
## maternal_loss2530            -0.02      0.03    -0.09     0.04       1768
## maternal_loss3035            -0.05      0.03    -0.12     0.01       2069
## maternal_loss3540            -0.03      0.03    -0.09     0.02       1787
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## nr.siblings                   0.00      0.00    -0.01     0.01       3000
## dependent_sibs_f5y            0.00      0.01    -0.02     0.02       3000
## hu_Intercept                 -0.41      0.20    -0.80    -0.01       1009
## hu_paternalage               -0.04      0.07    -0.18     0.10       1546
## hu_birth_cohort1760M1765     -0.03      0.17    -0.35     0.30       1203
## hu_birth_cohort1765M1770     -0.31      0.15    -0.60    -0.02        887
## hu_birth_cohort1770M1775     -0.07      0.15    -0.35     0.22        722
## hu_birth_cohort1775M1780     -0.19      0.15    -0.47     0.10        668
## hu_birth_cohort1780M1785     -0.25      0.16    -0.55     0.05        774
## hu_birth_cohort1785M1790     -0.41      0.15    -0.70    -0.13        750
## hu_birth_cohort1790M1795     -0.30      0.14    -0.57    -0.03        655
## hu_birth_cohort1795M1800     -0.47      0.13    -0.72    -0.22        597
## hu_birth_cohort1800M1805     -0.53      0.13    -0.79    -0.29        589
## hu_birth_cohort1805M1810     -0.26      0.13    -0.51    -0.01        596
## hu_birth_cohort1810M1815     -0.43      0.13    -0.68    -0.20        606
## hu_birth_cohort1815M1820     -0.71      0.12    -0.95    -0.47        565
## hu_birth_cohort1820M1825     -0.54      0.12    -0.78    -0.30        568
## hu_birth_cohort1825M1830     -0.54      0.12    -0.78    -0.31        575
## hu_birth_cohort1830M1835     -0.56      0.12    -0.80    -0.31        600
## hu_male1                      0.28      0.05     0.19     0.37       3000
## hu_maternalage.factor1420     0.32      0.23    -0.13     0.80       3000
## hu_maternalage.factor3550     0.21      0.07     0.07     0.35       2307
## hu_paternalage.mean           0.12      0.08    -0.03     0.28       1565
## hu_paternal_loss01            0.62      0.19     0.27     1.00       3000
## hu_paternal_loss15            0.54      0.13     0.28     0.80       1714
## hu_paternal_loss510           0.16      0.11    -0.06     0.38       1461
## hu_paternal_loss1015          0.15      0.11    -0.06     0.35       1437
## hu_paternal_loss1520          0.10      0.11    -0.11     0.30       1485
## hu_paternal_loss2025          0.16      0.10    -0.04     0.35       1330
## hu_paternal_loss2530          0.04      0.09    -0.13     0.22       1342
## hu_paternal_loss3035         -0.04      0.09    -0.22     0.14       1426
## hu_paternal_loss3540         -0.03      0.09    -0.20     0.15       1316
## hu_paternal_loss4045          0.13      0.10    -0.08     0.33       1798
## hu_maternal_loss01            1.62      0.19     1.26     2.01       3000
## hu_maternal_loss15            0.59      0.12     0.35     0.84       1880
## hu_maternal_loss510           0.45      0.11     0.25     0.67       1748
## hu_maternal_loss1015          0.47      0.11     0.26     0.68       3000
## hu_maternal_loss1520          0.31      0.11     0.10     0.53       3000
## hu_maternal_loss2025          0.27      0.10     0.06     0.47       3000
## hu_maternal_loss2530          0.18      0.09     0.00     0.37       1682
## hu_maternal_loss3035          0.21      0.09     0.04     0.38       1636
## hu_maternal_loss3540          0.06      0.08    -0.10     0.22       3000
## hu_maternal_loss4045          0.27      0.08     0.11     0.44       3000
## hu_nr.siblings                0.03      0.01     0.00     0.05       2275
## hu_dependent_sibs_f5y         0.14      0.03     0.09     0.19       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.00
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.00
## birth_cohort1795M1800     1.00
## birth_cohort1800M1805     1.00
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.00
## birth_cohort1815M1820     1.00
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.00
## birth_cohort1830M1835     1.00
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.00
## paternal_loss01           1.00
## paternal_loss15           1.01
## paternal_loss510          1.01
## paternal_loss1015         1.01
## paternal_loss1520         1.01
## paternal_loss2025         1.01
## paternal_loss2530         1.01
## paternal_loss3035         1.01
## paternal_loss3540         1.01
## paternal_loss4045         1.01
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## nr.siblings               1.00
## dependent_sibs_f5y        1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.00
## hu_birth_cohort1815M1820  1.00
## hu_birth_cohort1820M1825  1.00
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_nr.siblings            1.00
## hu_dependent_sibs_f5y     1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.19 4.473 6.031
paternalage 0.9838 0.9339 1.035
birth_cohort1760M1765 0.9977 0.88 1.124
birth_cohort1765M1770 0.8861 0.793 0.9916
birth_cohort1770M1775 0.8931 0.7988 1.004
birth_cohort1775M1780 0.9752 0.8723 1.091
birth_cohort1780M1785 0.8935 0.8001 1.001
birth_cohort1785M1790 0.9095 0.8181 1.012
birth_cohort1790M1795 0.9265 0.8346 1.03
birth_cohort1795M1800 0.9014 0.8205 0.9937
birth_cohort1800M1805 0.8943 0.8117 0.9829
birth_cohort1805M1810 0.8738 0.7935 0.9628
birth_cohort1810M1815 0.9063 0.8242 0.9953
birth_cohort1815M1820 0.8695 0.794 0.9498
birth_cohort1820M1825 0.8315 0.7574 0.9094
birth_cohort1825M1830 0.8097 0.7375 0.8868
birth_cohort1830M1835 0.8325 0.7573 0.9136
male1 1.083 1.048 1.12
maternalage.factor1420 0.935 0.7719 1.118
maternalage.factor3550 0.9985 0.9464 1.053
paternalage.mean 1.014 0.958 1.079
paternal_loss01 0.8704 0.7521 1.006
paternal_loss15 0.9576 0.8654 1.06
paternal_loss510 0.9316 0.8572 1.015
paternal_loss1015 1.004 0.9291 1.088
paternal_loss1520 0.9076 0.8409 0.9802
paternal_loss2025 0.8862 0.8238 0.953
paternal_loss2530 0.989 0.9245 1.056
paternal_loss3035 0.9699 0.9084 1.034
paternal_loss3540 0.9869 0.9265 1.052
paternal_loss4045 0.9889 0.9189 1.062
maternal_loss01 1.11 0.9523 1.294
maternal_loss15 0.9744 0.8903 1.067
maternal_loss510 1.07 0.9889 1.154
maternal_loss1015 1.03 0.9508 1.118
maternal_loss1520 1.006 0.9281 1.092
maternal_loss2025 1.008 0.9355 1.087
maternal_loss2530 0.9775 0.9153 1.045
maternal_loss3035 0.9485 0.887 1.012
maternal_loss3540 0.9682 0.9131 1.025
maternal_loss4045 0.9717 0.9149 1.034
nr.siblings 1.003 0.9932 1.013
dependent_sibs_f5y 0.9959 0.9768 1.015
hu_Intercept 0.6651 0.4483 0.9853
hu_paternalage 0.9608 0.8337 1.103
hu_birth_cohort1760M1765 0.9701 0.704 1.346
hu_birth_cohort1765M1770 0.735 0.5487 0.9851
hu_birth_cohort1770M1775 0.9369 0.7024 1.247
hu_birth_cohort1775M1780 0.8299 0.6219 1.109
hu_birth_cohort1780M1785 0.7797 0.5791 1.055
hu_birth_cohort1785M1790 0.6622 0.496 0.8794
hu_birth_cohort1790M1795 0.7381 0.5651 0.9704
hu_birth_cohort1795M1800 0.6233 0.4862 0.7997
hu_birth_cohort1800M1805 0.5858 0.4538 0.7514
hu_birth_cohort1805M1810 0.7743 0.6003 0.9882
hu_birth_cohort1810M1815 0.6487 0.505 0.8205
hu_birth_cohort1815M1820 0.4932 0.3871 0.6221
hu_birth_cohort1820M1825 0.5814 0.4598 0.7426
hu_birth_cohort1825M1830 0.5826 0.4599 0.731
hu_birth_cohort1830M1835 0.5731 0.4482 0.7324
hu_male1 1.32 1.21 1.447
hu_maternalage.factor1420 1.376 0.8783 2.22
hu_maternalage.factor3550 1.232 1.075 1.425
hu_paternalage.mean 1.133 0.9695 1.33
hu_paternal_loss01 1.861 1.306 2.706
hu_paternal_loss15 1.713 1.323 2.222
hu_paternal_loss510 1.171 0.9378 1.467
hu_paternal_loss1015 1.162 0.9371 1.424
hu_paternal_loss1520 1.1 0.8922 1.346
hu_paternal_loss2025 1.17 0.9618 1.414
hu_paternal_loss2530 1.045 0.8747 1.251
hu_paternal_loss3035 0.9569 0.8026 1.147
hu_paternal_loss3540 0.9731 0.8178 1.165
hu_paternal_loss4045 1.134 0.926 1.386
hu_maternal_loss01 5.078 3.52 7.43
hu_maternal_loss15 1.799 1.424 2.307
hu_maternal_loss510 1.576 1.282 1.951
hu_maternal_loss1015 1.596 1.293 1.973
hu_maternal_loss1520 1.369 1.11 1.702
hu_maternal_loss2025 1.305 1.064 1.603
hu_maternal_loss2530 1.202 1.002 1.449
hu_maternal_loss3035 1.235 1.042 1.457
hu_maternal_loss3540 1.057 0.9018 1.248
hu_maternal_loss4045 1.31 1.111 1.547
hu_nr.siblings 1.026 0.9996 1.053
hu_dependent_sibs_f5y 1.153 1.098 1.212

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.21 [1.87;2.57] [1.99;2.45]
estimate father 35y 2.23 [1.86;2.62] [1.99;2.49]
percentage change 0.68 [-8.48;10.93] [-5.24;7.31]
OR/IRR 0.98 [0.93;1.04] [0.95;1.02]
OR hurdle 0.96 [0.83;1.1] [0.88;1.05]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r4_control_dependent_sibs.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r5: Birth order interacted with number of siblings

Plausibly, being first-born has a different effect, when one is an only child as opposed to having two siblings, etc. Here, we allow for such an interaction effect.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings * nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) + older_siblings:nr.siblings
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1165 1.00
## sd(hu_Intercept)     0.48      0.05     0.38     0.56        657 1.01
## 
## Population-Level Effects: 
##                                 Estimate Est.Error l-95% CI u-95% CI
## Intercept                           1.68      0.08     1.52     1.83
## paternalage                         0.06      0.06    -0.05     0.16
## birth_cohort1760M1765               0.00      0.06    -0.13     0.12
## birth_cohort1765M1770              -0.12      0.06    -0.23    -0.01
## birth_cohort1770M1775              -0.12      0.06    -0.23     0.00
## birth_cohort1775M1780              -0.03      0.05    -0.13     0.08
## birth_cohort1780M1785              -0.11      0.06    -0.22     0.00
## birth_cohort1785M1790              -0.10      0.05    -0.20     0.02
## birth_cohort1790M1795              -0.08      0.05    -0.17     0.02
## birth_cohort1795M1800              -0.11      0.05    -0.20    -0.01
## birth_cohort1800M1805              -0.11      0.05    -0.21    -0.02
## birth_cohort1805M1810              -0.14      0.05    -0.23    -0.04
## birth_cohort1810M1815              -0.10      0.05    -0.19     0.00
## birth_cohort1815M1820              -0.14      0.04    -0.23    -0.06
## birth_cohort1820M1825              -0.19      0.04    -0.27    -0.10
## birth_cohort1825M1830              -0.21      0.04    -0.29    -0.12
## birth_cohort1830M1835              -0.18      0.05    -0.27    -0.09
## male1                               0.08      0.02     0.04     0.11
## maternalage.factor1420             -0.04      0.09    -0.23     0.14
## maternalage.factor3550              0.00      0.03    -0.06     0.05
## paternalage.mean                   -0.06      0.06    -0.17     0.05
## paternal_loss01                    -0.15      0.08    -0.31    -0.01
## paternal_loss15                    -0.04      0.05    -0.14     0.06
## paternal_loss510                   -0.07      0.04    -0.15     0.01
## paternal_loss1015                   0.01      0.04    -0.07     0.08
## paternal_loss1520                  -0.09      0.04    -0.17    -0.02
## paternal_loss2025                  -0.12      0.04    -0.20    -0.05
## paternal_loss2530                  -0.01      0.03    -0.07     0.06
## paternal_loss3035                  -0.03      0.03    -0.09     0.03
## paternal_loss3540                  -0.01      0.03    -0.07     0.05
## paternal_loss4045                  -0.01      0.04    -0.08     0.06
## maternal_loss01                     0.10      0.08    -0.05     0.25
## maternal_loss15                    -0.02      0.05    -0.11     0.08
## maternal_loss510                    0.07      0.04    -0.01     0.15
## maternal_loss1015                   0.03      0.04    -0.06     0.10
## maternal_loss1520                   0.00      0.04    -0.08     0.08
## maternal_loss2025                   0.00      0.04    -0.07     0.08
## maternal_loss2530                  -0.02      0.03    -0.09     0.05
## maternal_loss3035                  -0.05      0.03    -0.11     0.01
## maternal_loss3540                  -0.03      0.03    -0.09     0.02
## maternal_loss4045                  -0.03      0.03    -0.09     0.04
## older_siblings1                     0.00      0.05    -0.11     0.10
## older_siblings2                    -0.09      0.07    -0.23     0.04
## older_siblings3                    -0.10      0.09    -0.27     0.08
## older_siblings4                    -0.06      0.13    -0.30     0.19
## older_siblings5P                   -0.18      0.11    -0.41     0.04
## nr.siblings                         0.00      0.01    -0.02     0.02
## last_born1                         -0.04      0.02    -0.09     0.00
## older_siblings1:nr.siblings         0.01      0.01    -0.01     0.03
## older_siblings2:nr.siblings         0.01      0.01    -0.01     0.03
## older_siblings3:nr.siblings         0.01      0.01    -0.02     0.04
## older_siblings4:nr.siblings         0.00      0.02    -0.04     0.04
## older_siblings5P:nr.siblings        0.02      0.01    -0.01     0.04
## hu_Intercept                       -0.26      0.21    -0.66     0.15
## hu_paternalage                      0.29      0.15    -0.02     0.60
## hu_birth_cohort1760M1765           -0.06      0.17    -0.38     0.27
## hu_birth_cohort1765M1770           -0.32      0.15    -0.61    -0.03
## hu_birth_cohort1770M1775           -0.07      0.14    -0.35     0.21
## hu_birth_cohort1775M1780           -0.20      0.15    -0.49     0.09
## hu_birth_cohort1780M1785           -0.28      0.15    -0.57     0.00
## hu_birth_cohort1785M1790           -0.43      0.14    -0.71    -0.15
## hu_birth_cohort1790M1795           -0.32      0.14    -0.59    -0.06
## hu_birth_cohort1795M1800           -0.47      0.13    -0.73    -0.22
## hu_birth_cohort1800M1805           -0.54      0.13    -0.79    -0.29
## hu_birth_cohort1805M1810           -0.27      0.12    -0.52    -0.03
## hu_birth_cohort1810M1815           -0.45      0.12    -0.69    -0.20
## hu_birth_cohort1815M1820           -0.71      0.12    -0.94    -0.48
## hu_birth_cohort1820M1825           -0.53      0.12    -0.76    -0.30
## hu_birth_cohort1825M1830           -0.55      0.12    -0.79    -0.32
## hu_birth_cohort1830M1835           -0.56      0.12    -0.80    -0.34
## hu_male1                            0.27      0.05     0.18     0.36
## hu_maternalage.factor1420           0.28      0.24    -0.17     0.74
## hu_maternalage.factor3550           0.15      0.07     0.02     0.30
## hu_paternalage.mean                -0.21      0.16    -0.51     0.10
## hu_paternal_loss01                  0.59      0.18     0.24     0.94
## hu_paternal_loss15                  0.53      0.13     0.28     0.79
## hu_paternal_loss510                 0.19      0.11    -0.03     0.41
## hu_paternal_loss1015                0.15      0.10    -0.05     0.35
## hu_paternal_loss1520                0.10      0.10    -0.10     0.29
## hu_paternal_loss2025                0.15      0.10    -0.04     0.34
## hu_paternal_loss2530                0.06      0.09    -0.13     0.24
## hu_paternal_loss3035               -0.03      0.09    -0.21     0.15
## hu_paternal_loss3540               -0.02      0.09    -0.20     0.17
## hu_paternal_loss4045                0.15      0.10    -0.05     0.33
## hu_maternal_loss01                  1.59      0.19     1.22     1.98
## hu_maternal_loss15                  0.59      0.12     0.36     0.82
## hu_maternal_loss510                 0.48      0.11     0.27     0.68
## hu_maternal_loss1015                0.47      0.11     0.25     0.68
## hu_maternal_loss1520                0.31      0.11     0.10     0.53
## hu_maternal_loss2025                0.26      0.10     0.06     0.46
## hu_maternal_loss2530                0.19      0.10     0.00     0.38
## hu_maternal_loss3035                0.22      0.09     0.05     0.39
## hu_maternal_loss3540                0.06      0.08    -0.10     0.22
## hu_maternal_loss4045                0.28      0.09     0.11     0.45
## hu_older_siblings1                 -0.08      0.14    -0.36     0.18
## hu_older_siblings2                 -0.25      0.18    -0.61     0.08
## hu_older_siblings3                 -0.43      0.23    -0.89     0.02
## hu_older_siblings4                 -0.70      0.32    -1.33    -0.07
## hu_older_siblings5P                -0.63      0.30    -1.24    -0.06
## hu_nr.siblings                      0.09      0.02     0.04     0.14
## hu_last_born1                       0.09      0.06    -0.03     0.21
## hu_older_siblings1:nr.siblings      0.02      0.03    -0.04     0.07
## hu_older_siblings2:nr.siblings      0.02      0.03    -0.04     0.08
## hu_older_siblings3:nr.siblings      0.05      0.04    -0.03     0.12
## hu_older_siblings4:nr.siblings      0.08      0.05    -0.01     0.17
## hu_older_siblings5P:nr.siblings     0.01      0.04    -0.06     0.08
##                                 Eff.Sample Rhat
## Intercept                             1301 1.01
## paternalage                           1058 1.00
## birth_cohort1760M1765                 1434 1.01
## birth_cohort1765M1770                  834 1.01
## birth_cohort1770M1775                  857 1.01
## birth_cohort1775M1780                  792 1.02
## birth_cohort1780M1785                  764 1.01
## birth_cohort1785M1790                  931 1.01
## birth_cohort1790M1795                  740 1.02
## birth_cohort1795M1800                  707 1.02
## birth_cohort1800M1805                  376 1.02
## birth_cohort1805M1810                  636 1.02
## birth_cohort1810M1815                  555 1.02
## birth_cohort1815M1820                  520 1.02
## birth_cohort1820M1825                  582 1.02
## birth_cohort1825M1830                  299 1.02
## birth_cohort1830M1835                  350 1.02
## male1                                 3000 1.00
## maternalage.factor1420                3000 1.00
## maternalage.factor3550                2380 1.00
## paternalage.mean                      1094 1.00
## paternal_loss01                       3000 1.00
## paternal_loss15                       1394 1.00
## paternal_loss510                      1468 1.00
## paternal_loss1015                     1236 1.00
## paternal_loss1520                     1114 1.00
## paternal_loss2025                     1078 1.00
## paternal_loss2530                     1025 1.00
## paternal_loss3035                     1034 1.00
## paternal_loss3540                     1359 1.00
## paternal_loss4045                     3000 1.00
## maternal_loss01                       3000 1.00
## maternal_loss15                       2039 1.00
## maternal_loss510                      3000 1.00
## maternal_loss1015                     2324 1.00
## maternal_loss1520                     2293 1.00
## maternal_loss2025                     3000 1.00
## maternal_loss2530                     1532 1.00
## maternal_loss3035                     2002 1.00
## maternal_loss3540                     2124 1.00
## maternal_loss4045                     3000 1.00
## older_siblings1                       1379 1.00
## older_siblings2                       1277 1.00
## older_siblings3                       1375 1.00
## older_siblings4                       1116 1.00
## older_siblings5P                      1329 1.00
## nr.siblings                           1732 1.00
## last_born1                            3000 1.00
## older_siblings1:nr.siblings           1592 1.00
## older_siblings2:nr.siblings           1533 1.00
## older_siblings3:nr.siblings           1850 1.00
## older_siblings4:nr.siblings           1549 1.00
## older_siblings5P:nr.siblings          1474 1.00
## hu_Intercept                          1102 1.00
## hu_paternalage                         986 1.00
## hu_birth_cohort1760M1765              3000 1.00
## hu_birth_cohort1765M1770              1173 1.01
## hu_birth_cohort1770M1775              1084 1.00
## hu_birth_cohort1775M1780              1050 1.01
## hu_birth_cohort1780M1785              1003 1.00
## hu_birth_cohort1785M1790               964 1.00
## hu_birth_cohort1790M1795               879 1.01
## hu_birth_cohort1795M1800               850 1.01
## hu_birth_cohort1800M1805               850 1.01
## hu_birth_cohort1805M1810               824 1.01
## hu_birth_cohort1810M1815               800 1.01
## hu_birth_cohort1815M1820               752 1.01
## hu_birth_cohort1820M1825               788 1.01
## hu_birth_cohort1825M1830               761 1.01
## hu_birth_cohort1830M1835               773 1.01
## hu_male1                              3000 1.00
## hu_maternalage.factor1420             3000 1.00
## hu_maternalage.factor3550             3000 1.00
## hu_paternalage.mean                   1009 1.00
## hu_paternal_loss01                    3000 1.00
## hu_paternal_loss15                    1531 1.00
## hu_paternal_loss510                   1394 1.00
## hu_paternal_loss1015                  1294 1.01
## hu_paternal_loss1520                  1084 1.01
## hu_paternal_loss2025                  1194 1.00
## hu_paternal_loss2530                  1128 1.01
## hu_paternal_loss3035                  1163 1.00
## hu_paternal_loss3540                  1342 1.00
## hu_paternal_loss4045                  1459 1.00
## hu_maternal_loss01                    3000 1.00
## hu_maternal_loss15                    1714 1.00
## hu_maternal_loss510                   1569 1.00
## hu_maternal_loss1015                  3000 1.00
## hu_maternal_loss1520                  3000 1.00
## hu_maternal_loss2025                  1688 1.00
## hu_maternal_loss2530                  1578 1.00
## hu_maternal_loss3035                  1549 1.00
## hu_maternal_loss3540                  1662 1.00
## hu_maternal_loss4045                  1586 1.00
## hu_older_siblings1                    1127 1.00
## hu_older_siblings2                    1045 1.00
## hu_older_siblings3                     959 1.00
## hu_older_siblings4                    1213 1.00
## hu_older_siblings5P                   1182 1.00
## hu_nr.siblings                        1614 1.00
## hu_last_born1                         3000 1.00
## hu_older_siblings1:nr.siblings        1334 1.00
## hu_older_siblings2:nr.siblings        1540 1.00
## hu_older_siblings3:nr.siblings        1409 1.00
## hu_older_siblings4:nr.siblings        1792 1.00
## hu_older_siblings5P:nr.siblings       1831 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.35 4.576 6.245
paternalage 1.059 0.9503 1.178
birth_cohort1760M1765 0.9967 0.8816 1.127
birth_cohort1765M1770 0.8892 0.7966 0.9942
birth_cohort1770M1775 0.8893 0.7932 1.002
birth_cohort1775M1780 0.9739 0.8743 1.084
birth_cohort1780M1785 0.8949 0.8007 1.003
birth_cohort1785M1790 0.9092 0.8172 1.015
birth_cohort1790M1795 0.9266 0.8415 1.02
birth_cohort1795M1800 0.8972 0.8175 0.9857
birth_cohort1800M1805 0.8921 0.8131 0.9791
birth_cohort1805M1810 0.8711 0.793 0.9574
birth_cohort1810M1815 0.9065 0.8278 0.9977
birth_cohort1815M1820 0.867 0.7958 0.9452
birth_cohort1820M1825 0.8301 0.7607 0.9049
birth_cohort1825M1830 0.8101 0.7454 0.8852
birth_cohort1830M1835 0.8328 0.7629 0.9139
male1 1.08 1.046 1.116
maternalage.factor1420 0.9595 0.7944 1.149
maternalage.factor3550 1 0.9447 1.055
paternalage.mean 0.9414 0.8402 1.05
paternal_loss01 0.859 0.7351 0.99
paternal_loss15 0.9607 0.8696 1.057
paternal_loss510 0.9322 0.8582 1.013
paternal_loss1015 1.007 0.9315 1.088
paternal_loss1520 0.9097 0.8434 0.9804
paternal_loss2025 0.8856 0.8215 0.9527
paternal_loss2530 0.9906 0.9284 1.059
paternal_loss3035 0.9712 0.9103 1.034
paternal_loss3540 0.9908 0.9283 1.055
paternal_loss4045 0.9897 0.9196 1.061
maternal_loss01 1.104 0.9467 1.286
maternal_loss15 0.983 0.8964 1.081
maternal_loss510 1.074 0.9908 1.162
maternal_loss1015 1.026 0.9432 1.11
maternal_loss1520 1.003 0.9261 1.085
maternal_loss2025 1.004 0.9278 1.086
maternal_loss2530 0.979 0.9163 1.046
maternal_loss3035 0.9504 0.892 1.012
maternal_loss3540 0.9674 0.9137 1.025
maternal_loss4045 0.972 0.9121 1.037
older_siblings1 0.998 0.8987 1.104
older_siblings2 0.9139 0.7977 1.044
older_siblings3 0.9052 0.7663 1.08
older_siblings4 0.9425 0.7424 1.207
older_siblings5P 0.8337 0.6631 1.043
nr.siblings 1.003 0.9847 1.02
last_born1 0.9574 0.9157 1.002
older_siblings1:nr.siblings 1.008 0.9869 1.029
older_siblings2:nr.siblings 1.011 0.9883 1.036
older_siblings3:nr.siblings 1.008 0.9791 1.036
older_siblings4:nr.siblings 0.9982 0.9612 1.036
older_siblings5P:nr.siblings 1.016 0.9882 1.045
hu_Intercept 0.7733 0.5161 1.158
hu_paternalage 1.337 0.9824 1.815
hu_birth_cohort1760M1765 0.939 0.6841 1.314
hu_birth_cohort1765M1770 0.7256 0.5412 0.9712
hu_birth_cohort1770M1775 0.9341 0.703 1.228
hu_birth_cohort1775M1780 0.8173 0.6149 1.09
hu_birth_cohort1780M1785 0.7537 0.5639 1.005
hu_birth_cohort1785M1790 0.6515 0.4932 0.8648
hu_birth_cohort1790M1795 0.7254 0.5564 0.9386
hu_birth_cohort1795M1800 0.6239 0.4809 0.8016
hu_birth_cohort1800M1805 0.5816 0.4528 0.7479
hu_birth_cohort1805M1810 0.7605 0.5953 0.9682
hu_birth_cohort1810M1815 0.6391 0.4998 0.8168
hu_birth_cohort1815M1820 0.4919 0.3909 0.6165
hu_birth_cohort1820M1825 0.5895 0.466 0.741
hu_birth_cohort1825M1830 0.5764 0.4546 0.7271
hu_birth_cohort1830M1835 0.5702 0.4481 0.7148
hu_male1 1.315 1.203 1.435
hu_maternalage.factor1420 1.317 0.8415 2.091
hu_maternalage.factor3550 1.165 1.015 1.353
hu_paternalage.mean 0.8104 0.5975 1.108
hu_paternal_loss01 1.802 1.267 2.563
hu_paternal_loss15 1.707 1.326 2.214
hu_paternal_loss510 1.211 0.9738 1.504
hu_paternal_loss1015 1.168 0.9514 1.423
hu_paternal_loss1520 1.107 0.908 1.333
hu_paternal_loss2025 1.167 0.9628 1.404
hu_paternal_loss2530 1.063 0.8782 1.274
hu_paternal_loss3035 0.9751 0.8142 1.158
hu_paternal_loss3540 0.9834 0.8227 1.179
hu_paternal_loss4045 1.156 0.9528 1.397
hu_maternal_loss01 4.886 3.396 7.216
hu_maternal_loss15 1.799 1.43 2.268
hu_maternal_loss510 1.617 1.306 1.982
hu_maternal_loss1015 1.597 1.289 1.97
hu_maternal_loss1520 1.367 1.103 1.698
hu_maternal_loss2025 1.293 1.067 1.589
hu_maternal_loss2530 1.207 0.9979 1.468
hu_maternal_loss3035 1.24 1.052 1.475
hu_maternal_loss3540 1.064 0.9069 1.244
hu_maternal_loss4045 1.32 1.116 1.561
hu_older_siblings1 0.9231 0.699 1.201
hu_older_siblings2 0.7773 0.545 1.085
hu_older_siblings3 0.648 0.4089 1.021
hu_older_siblings4 0.4962 0.2651 0.935
hu_older_siblings5P 0.5307 0.2898 0.9454
hu_nr.siblings 1.096 1.046 1.147
hu_last_born1 1.092 0.9661 1.236
hu_older_siblings1:nr.siblings 1.017 0.9636 1.075
hu_older_siblings2:nr.siblings 1.021 0.9612 1.087
hu_older_siblings3:nr.siblings 1.046 0.9746 1.123
hu_older_siblings4:nr.siblings 1.082 0.9879 1.188
hu_older_siblings5P:nr.siblings 1.009 0.9388 1.086

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.3 [1.95;2.72] [2.07;2.56]
estimate father 35y 2.05 [1.63;2.58] [1.75;2.39]
percentage change -10.72 [-28.05;9.92] [-22.69;2.31]
OR/IRR 1.06 [0.95;1.18] [0.99;1.14]
OR hurdle 1.34 [0.98;1.81] [1.09;1.63]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r5_birth_order_interact_siblings.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r6: No birth order control

Paternal age and birth order are highly collinear with each other and with maternal age. Therefore, the choice to include this predictor widens standard errors for each predictor and may be disputed. Here we show what happens when we simply omit the birth order control.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + nr.siblings + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + nr.siblings + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25        909 1.00
## sd(hu_Intercept)     0.47      0.05     0.38     0.56        576 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.64      0.08     1.49     1.79       1280
## paternalage                  -0.02      0.03    -0.07     0.03       1190
## birth_cohort1760M1765         0.00      0.06    -0.12     0.12       1518
## birth_cohort1765M1770        -0.12      0.06    -0.23    -0.01       1130
## birth_cohort1770M1775        -0.11      0.06    -0.22    -0.01        991
## birth_cohort1775M1780        -0.02      0.05    -0.13     0.08        954
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.00       1093
## birth_cohort1785M1790        -0.09      0.05    -0.20     0.02        933
## birth_cohort1790M1795        -0.07      0.05    -0.18     0.02        836
## birth_cohort1795M1800        -0.10      0.05    -0.20    -0.01        823
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        811
## birth_cohort1805M1810        -0.13      0.05    -0.23    -0.04        822
## birth_cohort1810M1815        -0.10      0.05    -0.19    -0.01        759
## birth_cohort1815M1820        -0.14      0.04    -0.23    -0.05        734
## birth_cohort1820M1825        -0.18      0.04    -0.27    -0.10        715
## birth_cohort1825M1830        -0.21      0.04    -0.30    -0.12        749
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        778
## male1                         0.08      0.02     0.05     0.11       3000
## maternalage.factor1420       -0.06      0.09    -0.24     0.10       3000
## maternalage.factor3550        0.00      0.03    -0.05     0.05       2155
## paternalage.mean              0.02      0.03    -0.05     0.08       1426
## paternal_loss01              -0.14      0.07    -0.29     0.02       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       1846
## paternal_loss510             -0.07      0.04    -0.15     0.01       1489
## paternal_loss1015             0.01      0.04    -0.07     0.09       1320
## paternal_loss1520            -0.10      0.04    -0.17    -0.02       1435
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       1391
## paternal_loss2530            -0.01      0.03    -0.08     0.06       1240
## paternal_loss3035            -0.03      0.03    -0.09     0.04       1285
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1391
## paternal_loss4045            -0.01      0.04    -0.08     0.06       1738
## maternal_loss01               0.11      0.08    -0.05     0.26       3000
## maternal_loss15              -0.02      0.05    -0.12     0.07       1901
## maternal_loss510              0.07      0.04    -0.01     0.15       3000
## maternal_loss1015             0.03      0.04    -0.05     0.11       1839
## maternal_loss1520             0.01      0.04    -0.07     0.09       1825
## maternal_loss2025             0.01      0.04    -0.06     0.08       1795
## maternal_loss2530            -0.02      0.03    -0.09     0.04       1662
## maternal_loss3035            -0.05      0.03    -0.12     0.01       1858
## maternal_loss3540            -0.03      0.03    -0.09     0.03       1903
## maternal_loss4045            -0.03      0.03    -0.09     0.03       2055
## nr.siblings                   0.00      0.00    -0.01     0.01       2552
## hu_Intercept                 -0.25      0.19    -0.63     0.13        703
## hu_paternalage               -0.05      0.07    -0.18     0.09       1460
## hu_birth_cohort1760M1765     -0.05      0.17    -0.39     0.28       3000
## hu_birth_cohort1765M1770     -0.32      0.15    -0.60    -0.02        862
## hu_birth_cohort1770M1775     -0.08      0.15    -0.37     0.21        731
## hu_birth_cohort1775M1780     -0.20      0.15    -0.49     0.08        712
## hu_birth_cohort1780M1785     -0.28      0.15    -0.57     0.01        816
## hu_birth_cohort1785M1790     -0.43      0.14    -0.71    -0.14        757
## hu_birth_cohort1790M1795     -0.31      0.14    -0.59    -0.04        698
## hu_birth_cohort1795M1800     -0.47      0.13    -0.72    -0.21        516
## hu_birth_cohort1800M1805     -0.55      0.13    -0.81    -0.30        555
## hu_birth_cohort1805M1810     -0.28      0.13    -0.52    -0.03        546
## hu_birth_cohort1810M1815     -0.44      0.12    -0.68    -0.20        518
## hu_birth_cohort1815M1820     -0.71      0.12    -0.94    -0.49        444
## hu_birth_cohort1820M1825     -0.54      0.12    -0.77    -0.30        517
## hu_birth_cohort1825M1830     -0.56      0.12    -0.78    -0.32        503
## hu_birth_cohort1830M1835     -0.56      0.12    -0.80    -0.32        504
## hu_male1                      0.27      0.04     0.19     0.36       3000
## hu_maternalage.factor1420     0.23      0.23    -0.23     0.69       3000
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       2206
## hu_paternalage.mean           0.12      0.08    -0.03     0.28       1434
## hu_paternal_loss01            0.56      0.18     0.21     0.92       3000
## hu_paternal_loss15            0.54      0.13     0.30     0.79       1696
## hu_paternal_loss510           0.19      0.11    -0.03     0.42       1318
## hu_paternal_loss1015          0.15      0.11    -0.06     0.37       1589
## hu_paternal_loss1520          0.10      0.10    -0.09     0.30       1124
## hu_paternal_loss2025          0.15      0.10    -0.04     0.35       1197
## hu_paternal_loss2530          0.05      0.09    -0.13     0.24        975
## hu_paternal_loss3035         -0.03      0.09    -0.20     0.15       1216
## hu_paternal_loss3540         -0.02      0.09    -0.19     0.16       1342
## hu_paternal_loss4045          0.14      0.10    -0.06     0.33       3000
## hu_maternal_loss01            1.55      0.19     1.19     1.92       3000
## hu_maternal_loss15            0.60      0.12     0.36     0.83       3000
## hu_maternal_loss510           0.49      0.10     0.28     0.69       1905
## hu_maternal_loss1015          0.47      0.11     0.27     0.69       3000
## hu_maternal_loss1520          0.31      0.11     0.10     0.52       3000
## hu_maternal_loss2025          0.25      0.10     0.05     0.46       3000
## hu_maternal_loss2530          0.19      0.09     0.01     0.36       1609
## hu_maternal_loss3035          0.21      0.09     0.04     0.39       1886
## hu_maternal_loss3540          0.06      0.08    -0.09     0.21       3000
## hu_maternal_loss4045          0.27      0.09     0.10     0.44       3000
## hu_nr.siblings                0.06      0.01     0.04     0.08       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.00
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.01
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.01
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.01
## birth_cohort1795M1800     1.01
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.00
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.00
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.01
## paternal_loss3035         1.01
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## nr.siblings               1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.01
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.01
## hu_birth_cohort1790M1795  1.01
## hu_birth_cohort1795M1800  1.01
## hu_birth_cohort1800M1805  1.01
## hu_birth_cohort1805M1810  1.01
## hu_birth_cohort1810M1815  1.01
## hu_birth_cohort1815M1820  1.01
## hu_birth_cohort1820M1825  1.01
## hu_birth_cohort1825M1830  1.01
## hu_birth_cohort1830M1835  1.01
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_nr.siblings            1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.15 4.432 5.992
paternalage 0.9814 0.9327 1.034
birth_cohort1760M1765 1.001 0.8846 1.128
birth_cohort1765M1770 0.8887 0.7925 0.991
birth_cohort1770M1775 0.8946 0.802 0.9949
birth_cohort1775M1780 0.9774 0.8794 1.086
birth_cohort1780M1785 0.8953 0.8012 1.001
birth_cohort1785M1790 0.9116 0.8182 1.015
birth_cohort1790M1795 0.9278 0.8384 1.023
birth_cohort1795M1800 0.9029 0.8179 0.9872
birth_cohort1800M1805 0.8959 0.8124 0.9793
birth_cohort1805M1810 0.877 0.7953 0.9622
birth_cohort1810M1815 0.9082 0.8289 0.9904
birth_cohort1815M1820 0.8707 0.7968 0.949
birth_cohort1820M1825 0.8329 0.7602 0.9063
birth_cohort1825M1830 0.8125 0.7433 0.8844
birth_cohort1830M1835 0.8341 0.7589 0.9113
male1 1.083 1.047 1.119
maternalage.factor1420 0.9381 0.7898 1.104
maternalage.factor3550 1.002 0.9518 1.055
paternalage.mean 1.016 0.953 1.078
paternal_loss01 0.8736 0.7501 1.016
paternal_loss15 0.959 0.868 1.063
paternal_loss510 0.9336 0.8587 1.014
paternal_loss1015 1.006 0.9332 1.09
paternal_loss1520 0.9086 0.8413 0.9819
paternal_loss2025 0.8879 0.8247 0.9552
paternal_loss2530 0.9904 0.9241 1.06
paternal_loss3035 0.9709 0.9095 1.038
paternal_loss3540 0.9887 0.9287 1.05
paternal_loss4045 0.9907 0.9217 1.066
maternal_loss01 1.112 0.9553 1.294
maternal_loss15 0.976 0.8863 1.067
maternal_loss510 1.07 0.9875 1.158
maternal_loss1015 1.031 0.9484 1.121
maternal_loss1520 1.008 0.9293 1.09
maternal_loss2025 1.01 0.9384 1.088
maternal_loss2530 0.9784 0.9128 1.045
maternal_loss3035 0.9488 0.8898 1.01
maternal_loss3540 0.9688 0.9165 1.027
maternal_loss4045 0.9718 0.9171 1.032
nr.siblings 1.002 0.994 1.01
hu_Intercept 0.7815 0.5332 1.135
hu_paternalage 0.9537 0.8335 1.096
hu_birth_cohort1760M1765 0.9486 0.6772 1.32
hu_birth_cohort1765M1770 0.7281 0.5502 0.9806
hu_birth_cohort1770M1775 0.9235 0.6914 1.233
hu_birth_cohort1775M1780 0.8153 0.6154 1.079
hu_birth_cohort1780M1785 0.7557 0.5675 1.009
hu_birth_cohort1785M1790 0.653 0.4926 0.8661
hu_birth_cohort1790M1795 0.7304 0.5517 0.9593
hu_birth_cohort1795M1800 0.6248 0.4851 0.8072
hu_birth_cohort1800M1805 0.577 0.4466 0.7388
hu_birth_cohort1805M1810 0.7564 0.5928 0.9689
hu_birth_cohort1810M1815 0.642 0.506 0.8165
hu_birth_cohort1815M1820 0.4911 0.3898 0.6156
hu_birth_cohort1820M1825 0.5854 0.4643 0.7421
hu_birth_cohort1825M1830 0.5739 0.4573 0.7268
hu_birth_cohort1830M1835 0.5719 0.4514 0.7231
hu_male1 1.314 1.204 1.436
hu_maternalage.factor1420 1.255 0.7912 1.992
hu_maternalage.factor3550 1.138 0.9915 1.305
hu_paternalage.mean 1.131 0.966 1.323
hu_paternal_loss01 1.743 1.233 2.52
hu_paternal_loss15 1.711 1.346 2.206
hu_paternal_loss510 1.21 0.974 1.517
hu_paternal_loss1015 1.166 0.9452 1.446
hu_paternal_loss1520 1.105 0.9117 1.344
hu_paternal_loss2025 1.165 0.9634 1.422
hu_paternal_loss2530 1.053 0.8743 1.269
hu_paternal_loss3035 0.9727 0.8158 1.158
hu_paternal_loss3540 0.983 0.8245 1.172
hu_paternal_loss4045 1.148 0.9441 1.397
hu_maternal_loss01 4.713 3.282 6.831
hu_maternal_loss15 1.817 1.432 2.296
hu_maternal_loss510 1.624 1.323 1.984
hu_maternal_loss1015 1.606 1.304 2.002
hu_maternal_loss1520 1.36 1.101 1.68
hu_maternal_loss2025 1.289 1.054 1.576
hu_maternal_loss2530 1.205 1.006 1.439
hu_maternal_loss3035 1.236 1.042 1.47
hu_maternal_loss3540 1.064 0.9124 1.24
hu_maternal_loss4045 1.312 1.106 1.552
hu_nr.siblings 1.062 1.04 1.085

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.17 [1.83;2.53] [1.95;2.4]
estimate father 35y 2.19 [1.83;2.58] [1.95;2.44]
percentage change 1.05 [-8.48;11.09] [-5.31;7.43]
OR/IRR 0.98 [0.93;1.03] [0.95;1.02]
OR hurdle 0.95 [0.83;1.1] [0.87;1.04]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r6_no_birth_order_control.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r7: Less control for parental loss

We adjusted for parental loss very stringently, including covariates for parental loss up to age 45. Here we show what happens, when we only control for parental loss in the first, and the first five years of life.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1000; warmup = 500; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25        999 1.00
## sd(hu_Intercept)     0.48      0.04     0.39     0.56        816 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.64      0.09     1.46     1.82       1523
## paternalage                   0.06      0.05    -0.04     0.16        645
## birth_cohort1760M1765         0.00      0.06    -0.12     0.12        910
## birth_cohort1765M1770        -0.11      0.06    -0.23     0.00        744
## birth_cohort1770M1775        -0.11      0.06    -0.22     0.00        696
## birth_cohort1775M1780        -0.02      0.05    -0.13     0.08        683
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.00        643
## birth_cohort1785M1790        -0.10      0.05    -0.20     0.00        681
## birth_cohort1790M1795        -0.07      0.05    -0.18     0.03        604
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        517
## birth_cohort1800M1805        -0.11      0.05    -0.20    -0.01        552
## birth_cohort1805M1810        -0.13      0.05    -0.23    -0.04        520
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        472
## birth_cohort1815M1820        -0.14      0.04    -0.22    -0.05        451
## birth_cohort1820M1825        -0.18      0.05    -0.27    -0.09        455
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        488
## birth_cohort1830M1835        -0.19      0.05    -0.28    -0.10        495
## male1                         0.08      0.02     0.04     0.11       3000
## maternalage.factor1420       -0.04      0.09    -0.23     0.14       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.05    -0.18     0.03        668
## paternal_loss01              -0.12      0.08    -0.28     0.04       3000
## paternal_losslater            0.00      0.04    -0.08     0.09       2622
## maternal_loss01               0.12      0.08    -0.04     0.28       3000
## maternal_losslater            0.02      0.04    -0.07     0.10       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1243
## older_siblings2              -0.05      0.04    -0.12     0.02        731
## older_siblings3              -0.08      0.05    -0.17     0.01        692
## older_siblings4              -0.09      0.06    -0.21     0.03        697
## older_siblings5P             -0.10      0.08    -0.25     0.05        612
## nr.siblings                   0.01      0.01     0.00     0.02        757
## last_born1                   -0.04      0.02    -0.09     0.01       3000
## hu_Intercept                  0.76      0.22     0.33     1.20       1327
## hu_paternalage                0.40      0.14     0.11     0.69        639
## hu_birth_cohort1760M1765     -0.06      0.17    -0.39     0.27       3000
## hu_birth_cohort1765M1770     -0.29      0.15    -0.58    -0.01        820
## hu_birth_cohort1770M1775     -0.09      0.15    -0.37     0.20        832
## hu_birth_cohort1775M1780     -0.23      0.14    -0.50     0.06        781
## hu_birth_cohort1780M1785     -0.30      0.15    -0.59    -0.02        765
## hu_birth_cohort1785M1790     -0.44      0.14    -0.72    -0.17        775
## hu_birth_cohort1790M1795     -0.34      0.14    -0.61    -0.08        760
## hu_birth_cohort1795M1800     -0.48      0.13    -0.74    -0.24        651
## hu_birth_cohort1800M1805     -0.57      0.13    -0.81    -0.32        657
## hu_birth_cohort1805M1810     -0.32      0.12    -0.56    -0.07        626
## hu_birth_cohort1810M1815     -0.48      0.12    -0.72    -0.25        625
## hu_birth_cohort1815M1820     -0.73      0.12    -0.97    -0.51        609
## hu_birth_cohort1820M1825     -0.58      0.12    -0.81    -0.35        576
## hu_birth_cohort1825M1830     -0.58      0.12    -0.81    -0.36        571
## hu_birth_cohort1830M1835     -0.59      0.12    -0.83    -0.36        605
## hu_male1                      0.27      0.04     0.19     0.36       3000
## hu_maternalage.factor1420     0.27      0.23    -0.18     0.75       3000
## hu_maternalage.factor3550     0.12      0.07    -0.03     0.26       3000
## hu_paternalage.mean          -0.32      0.15    -0.61    -0.02        714
## hu_paternal_loss01            0.05      0.19    -0.32     0.42       3000
## hu_paternal_losslater        -0.40      0.11    -0.62    -0.19       3000
## hu_maternal_loss01            0.99      0.20     0.60     1.37       3000
## hu_maternal_losslater        -0.34      0.11    -0.55    -0.12       3000
## hu_older_siblings1           -0.02      0.07    -0.17     0.12       1230
## hu_older_siblings2           -0.18      0.10    -0.37     0.02        791
## hu_older_siblings3           -0.22      0.13    -0.47     0.02        560
## hu_older_siblings4           -0.27      0.16    -0.59     0.04        636
## hu_older_siblings5P          -0.62      0.21    -1.03    -0.21        618
## hu_nr.siblings                0.10      0.02     0.06     0.13        864
## hu_last_born1                 0.08      0.06    -0.03     0.21       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.01
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.00
## birth_cohort1795M1800     1.01
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.01
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_losslater        1.00
## maternal_loss01           1.00
## maternal_losslater        1.00
## older_siblings1           1.00
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.01
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.01
## hu_birth_cohort1780M1785  1.01
## hu_birth_cohort1785M1790  1.01
## hu_birth_cohort1790M1795  1.01
## hu_birth_cohort1795M1800  1.01
## hu_birth_cohort1800M1805  1.01
## hu_birth_cohort1805M1810  1.01
## hu_birth_cohort1810M1815  1.01
## hu_birth_cohort1815M1820  1.01
## hu_birth_cohort1820M1825  1.01
## hu_birth_cohort1825M1830  1.01
## hu_birth_cohort1830M1835  1.01
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.01
## hu_paternal_loss01        1.00
## hu_paternal_losslater     1.00
## hu_maternal_loss01        1.00
## hu_maternal_losslater     1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.01
## hu_older_siblings3        1.01
## hu_older_siblings4        1.01
## hu_older_siblings5P       1.01
## hu_nr.siblings            1.01
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.159 4.297 6.16
paternalage 1.06 0.9561 1.173
birth_cohort1760M1765 0.9992 0.8829 1.131
birth_cohort1765M1770 0.8922 0.796 0.9975
birth_cohort1770M1775 0.8975 0.8061 1.001
birth_cohort1775M1780 0.9763 0.8779 1.085
birth_cohort1780M1785 0.8965 0.8039 0.9984
birth_cohort1785M1790 0.904 0.8165 1.004
birth_cohort1790M1795 0.9283 0.8391 1.026
birth_cohort1795M1800 0.9 0.8176 0.9923
birth_cohort1800M1805 0.8969 0.8166 0.9855
birth_cohort1805M1810 0.8755 0.7953 0.9631
birth_cohort1810M1815 0.9087 0.8303 0.9951
birth_cohort1815M1820 0.8734 0.8007 0.951
birth_cohort1820M1825 0.8336 0.7635 0.9138
birth_cohort1825M1830 0.8068 0.7412 0.8847
birth_cohort1830M1835 0.8261 0.7549 0.9038
male1 1.08 1.044 1.116
maternalage.factor1420 0.9616 0.7961 1.154
maternalage.factor3550 0.9963 0.9414 1.054
paternalage.mean 0.9291 0.8385 1.034
paternal_loss01 0.8881 0.7592 1.041
paternal_losslater 1.001 0.9194 1.092
maternal_loss01 1.131 0.9583 1.329
maternal_losslater 1.018 0.9365 1.107
older_siblings1 1.026 0.9723 1.081
older_siblings2 0.9539 0.8892 1.025
older_siblings3 0.9263 0.8466 1.014
older_siblings4 0.9104 0.8105 1.027
older_siblings5P 0.9057 0.7779 1.055
nr.siblings 1.01 0.9951 1.023
last_born1 0.9597 0.9151 1.006
hu_Intercept 2.144 1.395 3.334
hu_paternalage 1.489 1.122 1.992
hu_birth_cohort1760M1765 0.9411 0.6774 1.308
hu_birth_cohort1765M1770 0.7446 0.5578 0.995
hu_birth_cohort1770M1775 0.9176 0.6876 1.227
hu_birth_cohort1775M1780 0.7924 0.6045 1.057
hu_birth_cohort1780M1785 0.7383 0.5537 0.983
hu_birth_cohort1785M1790 0.6421 0.4856 0.8424
hu_birth_cohort1790M1795 0.7096 0.542 0.926
hu_birth_cohort1795M1800 0.6172 0.479 0.7886
hu_birth_cohort1800M1805 0.5662 0.4433 0.7283
hu_birth_cohort1805M1810 0.7255 0.5734 0.9308
hu_birth_cohort1810M1815 0.617 0.4891 0.7807
hu_birth_cohort1815M1820 0.4828 0.3805 0.6025
hu_birth_cohort1820M1825 0.5602 0.4453 0.7029
hu_birth_cohort1825M1830 0.5581 0.4456 0.7006
hu_birth_cohort1830M1835 0.5538 0.4353 0.6966
hu_male1 1.314 1.205 1.431
hu_maternalage.factor1420 1.307 0.8364 2.12
hu_maternalage.factor3550 1.125 0.9732 1.297
hu_paternalage.mean 0.7291 0.5421 0.9831
hu_paternal_loss01 1.049 0.7244 1.52
hu_paternal_losslater 0.6687 0.5376 0.83
hu_maternal_loss01 2.687 1.814 3.951
hu_maternal_losslater 0.7149 0.5796 0.886
hu_older_siblings1 0.977 0.8456 1.133
hu_older_siblings2 0.8365 0.6903 1.016
hu_older_siblings3 0.8004 0.626 1.02
hu_older_siblings4 0.7613 0.5563 1.041
hu_older_siblings5P 0.538 0.3579 0.8115
hu_nr.siblings 1.104 1.065 1.144
hu_last_born1 1.087 0.9662 1.231

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.97 [1.68;2.28] [1.78;2.17]
estimate father 35y 1.61 [1.29;1.97] [1.39;1.84]
percentage change -18.19 [-34.37;-0.24] [-29.12;-6.7]
OR/IRR 1.06 [0.96;1.17] [0.99;1.13]
OR hurdle 1.49 [1.12;1.99] [1.24;1.79]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r7_less_parental_loss_control.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r8: Adjust for being first-/last-born adult son

Inheritance is linked to birth order and being male in several of the historical populations. Here, we adjust for the anchor being the first or last born adult son in a family. This implies that we control for our outcome to a certain extent, as “adult sons” cannot have died before adulthood, but a paternal age effect on mortality could still be detected for siblings other than the first- and last-born adults.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth.cohort + first_born_adult_male + last_born_adult_male + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth.cohort + first_born_adult_male + last_born_adult_male + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1147 1.01
## sd(hu_Intercept)     0.54      0.04     0.45     0.63        900 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.68      0.08     1.52     1.83       1277
## paternalage                   0.08      0.05    -0.02     0.19        771
## birth.cohort1760M1765         0.00      0.06    -0.13     0.13       3000
## birth.cohort1765M1770        -0.12      0.06    -0.23    -0.01       1023
## birth.cohort1770M1775        -0.12      0.06    -0.23     0.00        965
## birth.cohort1775M1780        -0.03      0.05    -0.13     0.08        827
## birth.cohort1780M1785        -0.11      0.06    -0.23     0.00        849
## birth.cohort1785M1790        -0.10      0.05    -0.20     0.01        806
## birth.cohort1790M1795        -0.08      0.05    -0.18     0.03        708
## birth.cohort1795M1800        -0.11      0.05    -0.20    -0.01        707
## birth.cohort1800M1805        -0.11      0.05    -0.21    -0.02        715
## birth.cohort1805M1810        -0.14      0.05    -0.23    -0.05        741
## birth.cohort1810M1815        -0.10      0.05    -0.19     0.00        657
## birth.cohort1815M1820        -0.14      0.04    -0.23    -0.05        582
## birth.cohort1820M1825        -0.19      0.05    -0.28    -0.09        640
## birth.cohort1825M1830        -0.21      0.05    -0.30    -0.12        657
## birth.cohort1830M1835        -0.18      0.05    -0.27    -0.09        644
## first_born_adult_male        -0.03      0.03    -0.08     0.02       3000
## last_born_adult_male         -0.05      0.03    -0.11     0.00       3000
## male1                         0.12      0.03     0.07     0.17       2045
## maternalage.factor1420       -0.05      0.09    -0.23     0.12       3000
## maternalage.factor3550        0.00      0.03    -0.05     0.06       3000
## paternalage.mean             -0.09      0.05    -0.20     0.01        721
## paternal_loss01              -0.15      0.08    -0.29     0.00       3000
## paternal_loss15              -0.03      0.05    -0.13     0.07       1929
## paternal_loss510             -0.07      0.04    -0.15     0.02       1671
## paternal_loss1015             0.01      0.04    -0.07     0.09       1542
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1442
## paternal_loss2025            -0.12      0.04    -0.20    -0.05       1555
## paternal_loss2530            -0.01      0.03    -0.08     0.06       1502
## paternal_loss3035            -0.03      0.03    -0.09     0.04       1496
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1463
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.11      0.08    -0.05     0.26       3000
## maternal_loss15              -0.02      0.05    -0.12     0.07       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       2160
## maternal_loss1015             0.03      0.04    -0.05     0.11       3000
## maternal_loss1520             0.00      0.04    -0.08     0.08       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       2035
## maternal_loss2530            -0.02      0.03    -0.09     0.04       1945
## maternal_loss3035            -0.05      0.03    -0.12     0.01       3000
## maternal_loss3540            -0.04      0.03    -0.09     0.02       3000
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.02      0.03    -0.04     0.07       1740
## older_siblings2              -0.06      0.04    -0.13     0.01       1079
## older_siblings3              -0.09      0.05    -0.19     0.00        836
## older_siblings4              -0.11      0.06    -0.23     0.00        946
## older_siblings5P             -0.12      0.08    -0.27     0.03        907
## nr.siblings                   0.01      0.01    -0.01     0.02       1165
## last_born1                   -0.05      0.02    -0.09     0.00       3000
## hu_Intercept                  0.04      0.21    -0.37     0.44       1441
## hu_paternalage                0.39      0.15     0.10     0.68        770
## hu_birth.cohort1760M1765     -0.02      0.17    -0.35     0.33       3000
## hu_birth.cohort1765M1770     -0.31      0.15    -0.60    -0.02       1119
## hu_birth.cohort1770M1775     -0.10      0.15    -0.38     0.20       1087
## hu_birth.cohort1775M1780     -0.25      0.15    -0.53     0.05        958
## hu_birth.cohort1780M1785     -0.32      0.15    -0.63    -0.02       1078
## hu_birth.cohort1785M1790     -0.44      0.15    -0.72    -0.15        996
## hu_birth.cohort1790M1795     -0.33      0.14    -0.61    -0.06        896
## hu_birth.cohort1795M1800     -0.47      0.13    -0.71    -0.20        874
## hu_birth.cohort1800M1805     -0.54      0.13    -0.79    -0.28        738
## hu_birth.cohort1805M1810     -0.28      0.13    -0.53    -0.03        915
## hu_birth.cohort1810M1815     -0.43      0.12    -0.68    -0.19        827
## hu_birth.cohort1815M1820     -0.72      0.12    -0.95    -0.47        667
## hu_birth.cohort1820M1825     -0.54      0.12    -0.78    -0.31        639
## hu_birth.cohort1825M1830     -0.53      0.12    -0.77    -0.29        715
## hu_birth.cohort1830M1835     -0.57      0.12    -0.79    -0.31        692
## hu_first_born_adult_male     -1.04      0.07    -1.18    -0.90       3000
## hu_last_born_adult_male      -0.94      0.08    -1.09    -0.80       3000
## hu_male1                      1.01      0.06     0.89     1.13       3000
## hu_maternalage.factor1420     0.25      0.23    -0.21     0.72       3000
## hu_maternalage.factor3550     0.17      0.08     0.01     0.31       3000
## hu_paternalage.mean          -0.31      0.15    -0.60    -0.02        797
## hu_paternal_loss01            0.61      0.19     0.24     0.98       3000
## hu_paternal_loss15            0.57      0.13     0.31     0.83       1674
## hu_paternal_loss510           0.19      0.11    -0.03     0.41       1601
## hu_paternal_loss1015          0.15      0.11    -0.06     0.36       1605
## hu_paternal_loss1520          0.08      0.10    -0.12     0.28       1360
## hu_paternal_loss2025          0.12      0.10    -0.08     0.31       1325
## hu_paternal_loss2530          0.06      0.10    -0.13     0.25       1351
## hu_paternal_loss3035         -0.03      0.09    -0.22     0.15       1273
## hu_paternal_loss3540         -0.02      0.09    -0.19     0.16       1334
## hu_paternal_loss4045          0.11      0.10    -0.09     0.32       3000
## hu_maternal_loss01            1.58      0.19     1.22     1.96       3000
## hu_maternal_loss15            0.60      0.12     0.35     0.83       3000
## hu_maternal_loss510           0.49      0.11     0.28     0.70       3000
## hu_maternal_loss1015          0.49      0.11     0.27     0.71       3000
## hu_maternal_loss1520          0.30      0.11     0.09     0.52       3000
## hu_maternal_loss2025          0.24      0.11     0.03     0.46       3000
## hu_maternal_loss2530          0.18      0.10    -0.01     0.37       2159
## hu_maternal_loss3035          0.21      0.09     0.03     0.39       3000
## hu_maternal_loss3540          0.03      0.08    -0.13     0.19       3000
## hu_maternal_loss4045          0.29      0.09     0.12     0.48       3000
## hu_older_siblings1           -0.16      0.08    -0.31    -0.01       1298
## hu_older_siblings2           -0.37      0.10    -0.57    -0.17        902
## hu_older_siblings3           -0.46      0.13    -0.72    -0.20        791
## hu_older_siblings4           -0.49      0.16    -0.81    -0.17        745
## hu_older_siblings5P          -0.85      0.21    -1.25    -0.43        716
## hu_nr.siblings                0.07      0.02     0.03     0.11        863
## hu_last_born1                 0.04      0.06    -0.08     0.16       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth.cohort1760M1765     1.00
## birth.cohort1765M1770     1.00
## birth.cohort1770M1775     1.00
## birth.cohort1775M1780     1.00
## birth.cohort1780M1785     1.00
## birth.cohort1785M1790     1.00
## birth.cohort1790M1795     1.01
## birth.cohort1795M1800     1.00
## birth.cohort1800M1805     1.00
## birth.cohort1805M1810     1.00
## birth.cohort1810M1815     1.00
## birth.cohort1815M1820     1.01
## birth.cohort1820M1825     1.00
## birth.cohort1825M1830     1.00
## birth.cohort1830M1835     1.00
## first_born_adult_male     1.00
## last_born_adult_male      1.00
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_birth.cohort1760M1765  1.00
## hu_birth.cohort1765M1770  1.00
## hu_birth.cohort1770M1775  1.00
## hu_birth.cohort1775M1780  1.00
## hu_birth.cohort1780M1785  1.00
## hu_birth.cohort1785M1790  1.00
## hu_birth.cohort1790M1795  1.00
## hu_birth.cohort1795M1800  1.00
## hu_birth.cohort1800M1805  1.00
## hu_birth.cohort1805M1810  1.00
## hu_birth.cohort1810M1815  1.01
## hu_birth.cohort1815M1820  1.00
## hu_birth.cohort1820M1825  1.01
## hu_birth.cohort1825M1830  1.00
## hu_birth.cohort1830M1835  1.00
## hu_first_born_adult_male  1.00
## hu_last_born_adult_male   1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.01
## hu_older_siblings3        1.01
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.01
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.35 4.576 6.243
paternalage 1.088 0.9814 1.211
birth.cohort1760M1765 0.9965 0.8802 1.135
birth.cohort1765M1770 0.8865 0.7928 0.9944
birth.cohort1770M1775 0.8879 0.7931 0.9976
birth.cohort1775M1780 0.9739 0.8766 1.081
birth.cohort1780M1785 0.8927 0.7959 0.9989
birth.cohort1785M1790 0.9084 0.815 1.013
birth.cohort1790M1795 0.9255 0.8336 1.027
birth.cohort1795M1800 0.8987 0.8178 0.9896
birth.cohort1800M1805 0.8927 0.811 0.98
birth.cohort1805M1810 0.8718 0.795 0.9557
birth.cohort1810M1815 0.9056 0.8262 0.9951
birth.cohort1815M1820 0.8671 0.7947 0.9485
birth.cohort1820M1825 0.8308 0.758 0.9099
birth.cohort1825M1830 0.8101 0.7432 0.8881
birth.cohort1830M1835 0.8312 0.7611 0.9095
first_born_adult_male 0.9701 0.9231 1.021
last_born_adult_male 0.9465 0.8987 0.9974
male1 1.125 1.07 1.183
maternalage.factor1420 0.9514 0.7924 1.13
maternalage.factor3550 0.9996 0.9481 1.057
paternalage.mean 0.9161 0.8201 1.015
paternal_loss01 0.8642 0.7457 1.003
paternal_loss15 0.9667 0.8742 1.069
paternal_loss510 0.9338 0.8599 1.018
paternal_loss1015 1.008 0.9343 1.089
paternal_loss1520 0.9103 0.8418 0.9809
paternal_loss2025 0.8857 0.8219 0.9543
paternal_loss2530 0.9909 0.9262 1.061
paternal_loss3035 0.9715 0.9116 1.038
paternal_loss3540 0.9903 0.9299 1.054
paternal_loss4045 0.9885 0.9222 1.063
maternal_loss01 1.113 0.9518 1.3
maternal_loss15 0.9804 0.8908 1.077
maternal_loss510 1.074 0.9917 1.162
maternal_loss1015 1.028 0.9483 1.114
maternal_loss1520 1.001 0.9226 1.083
maternal_loss2025 1.002 0.9296 1.081
maternal_loss2530 0.9765 0.913 1.043
maternal_loss3035 0.9484 0.8882 1.011
maternal_loss3540 0.9639 0.9107 1.022
maternal_loss4045 0.9705 0.9108 1.031
older_siblings1 1.017 0.9632 1.072
older_siblings2 0.9415 0.8748 1.013
older_siblings3 0.9139 0.8289 1.004
older_siblings4 0.896 0.7972 1.005
older_siblings5P 0.8892 0.7634 1.035
nr.siblings 1.009 0.9945 1.024
last_born1 0.9551 0.9132 1
hu_Intercept 1.041 0.6911 1.553
hu_paternalage 1.478 1.106 1.972
hu_birth.cohort1760M1765 0.9807 0.7028 1.389
hu_birth.cohort1765M1770 0.7332 0.5492 0.9762
hu_birth.cohort1770M1775 0.9056 0.6822 1.226
hu_birth.cohort1775M1780 0.7796 0.5867 1.048
hu_birth.cohort1780M1785 0.7235 0.5341 0.9762
hu_birth.cohort1785M1790 0.6471 0.4882 0.8643
hu_birth.cohort1790M1795 0.7177 0.5442 0.9412
hu_birth.cohort1795M1800 0.6271 0.4904 0.8193
hu_birth.cohort1800M1805 0.5825 0.4549 0.7535
hu_birth.cohort1805M1810 0.7531 0.5873 0.9677
hu_birth.cohort1810M1815 0.6483 0.5077 0.8282
hu_birth.cohort1815M1820 0.4864 0.3859 0.6233
hu_birth.cohort1820M1825 0.5819 0.4574 0.7354
hu_birth.cohort1825M1830 0.5895 0.4642 0.7488
hu_birth.cohort1830M1835 0.5681 0.454 0.7328
hu_first_born_adult_male 0.3541 0.3075 0.4074
hu_last_born_adult_male 0.3901 0.3353 0.4499
hu_male1 2.736 2.425 3.087
hu_maternalage.factor1420 1.287 0.8142 2.049
hu_maternalage.factor3550 1.18 1.013 1.365
hu_paternalage.mean 0.7333 0.5475 0.981
hu_paternal_loss01 1.836 1.269 2.67
hu_paternal_loss15 1.764 1.37 2.284
hu_paternal_loss510 1.212 0.9749 1.513
hu_paternal_loss1015 1.163 0.9402 1.436
hu_paternal_loss1520 1.084 0.8858 1.323
hu_paternal_loss2025 1.126 0.9253 1.36
hu_paternal_loss2530 1.064 0.8804 1.278
hu_paternal_loss3035 0.966 0.8059 1.157
hu_paternal_loss3540 0.9843 0.8264 1.174
hu_paternal_loss4045 1.12 0.9149 1.375
hu_maternal_loss01 4.867 3.374 7.12
hu_maternal_loss15 1.814 1.42 2.285
hu_maternal_loss510 1.639 1.324 2.017
hu_maternal_loss1015 1.628 1.311 2.032
hu_maternal_loss1520 1.351 1.092 1.685
hu_maternal_loss2025 1.274 1.031 1.581
hu_maternal_loss2530 1.197 0.9895 1.45
hu_maternal_loss3035 1.237 1.028 1.48
hu_maternal_loss3540 1.031 0.877 1.206
hu_maternal_loss4045 1.342 1.131 1.611
hu_older_siblings1 0.8529 0.7302 0.9923
hu_older_siblings2 0.6886 0.5638 0.8404
hu_older_siblings3 0.6322 0.4889 0.8206
hu_older_siblings4 0.6145 0.4437 0.8401
hu_older_siblings5P 0.4278 0.2864 0.6503
hu_nr.siblings 1.074 1.033 1.117
hu_last_born1 1.042 0.9231 1.177

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.64 [2.34;2.95] [2.44;2.85]
estimate father 35y 2.43 [2.04;2.9] [2.17;2.72]
percentage change -7.93 [-21.26;8.17] [-17.12;2.35]
OR/IRR 1.09 [0.98;1.21] [1.02;1.17]
OR hurdle 1.47 [1.11;1.97] [1.22;1.8]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r8_adjust_for_first_born_adult.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r9: Continuous birth year adjustment

In our main model, we control for birth cohort in 5-year-bins (lumping small bins). We chose to do so, because nonlinear and even sharply spiking effects of birth cohort are plausible (due to e.g. epidemics). This decision may be disputed, as it summarises 5-year-bins. Here, we instead allow for a thin-splate spline on the continuous birth year variable. This allows for smooth nonlinear (but not spiking) birth cohort effects.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
## Warning: There were 9 divergent transitions after warmup. Increasing
## adapt_delta above 0.8 may help. See http://mc-stan.org/misc/
## warnings.html#divergent-transitions-after-warmup
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + s(byear) + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + s(byear) + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## sds ~ student_t(3, 0, 10)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## sds_hu ~ student_t(3, 0, 10)
## 
## Smooth Terms: 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sds(sbyear_1)        0.12      0.13     0.00     0.47        936 1.01
## sds(hu_sbyear_1)     0.31      0.35     0.01     1.27        829 1.01
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.25        998    1
## sd(hu_Intercept)     0.46      0.04     0.38     0.55        802    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.53      0.07     1.40     1.67       2666
## paternalage                   0.07      0.06    -0.04     0.17        761
## male1                         0.08      0.02     0.05     0.11       3000
## maternalage.factor1420       -0.05      0.09    -0.24     0.13       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.06    -0.18     0.04        827
## paternal_loss01              -0.15      0.07    -0.30    -0.01       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       3000
## paternal_loss510             -0.07      0.04    -0.15     0.01       1607
## paternal_loss1015             0.00      0.04    -0.07     0.08       1534
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1597
## paternal_loss2025            -0.12      0.04    -0.20    -0.05       1554
## paternal_loss2530            -0.01      0.03    -0.08     0.05       1248
## paternal_loss3035            -0.03      0.03    -0.09     0.04       1440
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1508
## paternal_loss4045            -0.01      0.04    -0.09     0.06       1743
## maternal_loss01               0.11      0.08    -0.05     0.26       3000
## maternal_loss15              -0.02      0.05    -0.10     0.07       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       2031
## maternal_loss1015             0.03      0.04    -0.05     0.11       2282
## maternal_loss1520             0.00      0.04    -0.08     0.08       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       3000
## maternal_loss2530            -0.02      0.03    -0.09     0.04       3000
## maternal_loss3035            -0.05      0.03    -0.12     0.01       3000
## maternal_loss3540            -0.04      0.03    -0.09     0.02       3000
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1475
## older_siblings2              -0.05      0.04    -0.12     0.02        874
## older_siblings3              -0.07      0.05    -0.17     0.02        845
## older_siblings4              -0.10      0.06    -0.21     0.02        875
## older_siblings5P             -0.10      0.08    -0.25     0.06        753
## nr.siblings                   0.01      0.01     0.00     0.02       1084
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## sbyear_1                     -0.05      0.05    -0.15     0.04        895
## hu_Intercept                 -0.72      0.17    -1.04    -0.38       3000
## hu_paternalage                0.27      0.14    -0.01     0.56        749
## hu_male1                      0.27      0.05     0.18     0.37       3000
## hu_maternalage.factor1420     0.25      0.23    -0.20     0.69       3000
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       3000
## hu_paternalage.mean          -0.19      0.15    -0.48     0.10        768
## hu_paternal_loss01            0.57      0.18     0.24     0.92       3000
## hu_paternal_loss15            0.53      0.13     0.28     0.78       3000
## hu_paternal_loss510           0.19      0.11    -0.03     0.42       1553
## hu_paternal_loss1015          0.14      0.11    -0.07     0.35       1864
## hu_paternal_loss1520          0.10      0.10    -0.10     0.30       1318
## hu_paternal_loss2025          0.16      0.10    -0.03     0.35       1744
## hu_paternal_loss2530          0.06      0.09    -0.12     0.23       1328
## hu_paternal_loss3035         -0.02      0.09    -0.20     0.15       1536
## hu_paternal_loss3540         -0.02      0.09    -0.19     0.16       1530
## hu_paternal_loss4045          0.13      0.10    -0.06     0.32       3000
## hu_maternal_loss01            1.59      0.19     1.22     1.97       3000
## hu_maternal_loss15            0.60      0.12     0.36     0.84       3000
## hu_maternal_loss510           0.48      0.11     0.27     0.69       3000
## hu_maternal_loss1015          0.46      0.11     0.24     0.67       3000
## hu_maternal_loss1520          0.31      0.11     0.09     0.53       3000
## hu_maternal_loss2025          0.27      0.10     0.08     0.46       3000
## hu_maternal_loss2530          0.19      0.09     0.01     0.37       3000
## hu_maternal_loss3035          0.22      0.09     0.04     0.38       3000
## hu_maternal_loss3540          0.06      0.08    -0.09     0.22       3000
## hu_maternal_loss4045          0.26      0.09     0.10     0.43       3000
## hu_older_siblings1           -0.01      0.08    -0.16     0.14       1389
## hu_older_siblings2           -0.15      0.10    -0.35     0.03        912
## hu_older_siblings3           -0.19      0.13    -0.44     0.06        787
## hu_older_siblings4           -0.23      0.16    -0.53     0.07        747
## hu_older_siblings5P          -0.57      0.21    -0.97    -0.16        717
## hu_nr.siblings                0.10      0.02     0.07     0.14        888
## hu_last_born1                 0.07      0.06    -0.04     0.20       3000
## hu_sbyear_1                  -0.15      0.11    -0.37     0.09       1269
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.01
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.00
## older_siblings4           1.00
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## sbyear_1                  1.01
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.01
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.00
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## hu_sbyear_1               1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 4.635 4.06 5.3
paternalage 1.069 0.9609 1.19
male1 1.081 1.049 1.116
maternalage.factor1420 0.9467 0.7855 1.135
maternalage.factor3550 0.9986 0.9441 1.056
paternalage.mean 0.9345 0.8375 1.046
paternal_loss01 0.8579 0.7392 0.9912
paternal_loss15 0.9634 0.8734 1.066
paternal_loss510 0.9321 0.8598 1.008
paternal_loss1015 1.002 0.928 1.083
paternal_loss1520 0.9102 0.8469 0.9845
paternal_loss2025 0.8841 0.8206 0.9527
paternal_loss2530 0.9863 0.9232 1.053
paternal_loss3035 0.9706 0.9115 1.036
paternal_loss3540 0.988 0.9287 1.053
paternal_loss4045 0.9881 0.9181 1.061
maternal_loss01 1.111 0.9498 1.297
maternal_loss15 0.9835 0.9014 1.072
maternal_loss510 1.069 0.986 1.157
maternal_loss1015 1.031 0.9495 1.118
maternal_loss1520 1.001 0.9235 1.082
maternal_loss2025 1.004 0.9332 1.079
maternal_loss2530 0.9772 0.9118 1.045
maternal_loss3035 0.9486 0.8885 1.01
maternal_loss3540 0.9634 0.9097 1.02
maternal_loss4045 0.9676 0.9098 1.029
older_siblings1 1.026 0.9724 1.081
older_siblings2 0.9521 0.8854 1.022
older_siblings3 0.9304 0.8478 1.022
older_siblings4 0.909 0.8081 1.025
older_siblings5P 0.9066 0.7752 1.066
nr.siblings 1.01 0.9951 1.024
last_born1 0.9585 0.9155 1.004
sbyear_1 0.9467 0.8616 1.039
hu_Intercept 0.488 0.3517 0.683
hu_paternalage 1.307 0.9897 1.745
hu_male1 1.316 1.203 1.442
hu_maternalage.factor1420 1.279 0.8223 1.995
hu_maternalage.factor3550 1.141 0.9919 1.315
hu_paternalage.mean 0.8295 0.6213 1.109
hu_paternal_loss01 1.772 1.272 2.512
hu_paternal_loss15 1.698 1.323 2.173
hu_paternal_loss510 1.21 0.9734 1.515
hu_paternal_loss1015 1.152 0.9303 1.419
hu_paternal_loss1520 1.107 0.9046 1.35
hu_paternal_loss2025 1.168 0.9697 1.418
hu_paternal_loss2530 1.059 0.8864 1.264
hu_paternal_loss3035 0.9777 0.8198 1.167
hu_paternal_loss3540 0.9812 0.8263 1.177
hu_paternal_loss4045 1.135 0.9393 1.374
hu_maternal_loss01 4.885 3.393 7.165
hu_maternal_loss15 1.822 1.438 2.306
hu_maternal_loss510 1.615 1.315 1.989
hu_maternal_loss1015 1.579 1.271 1.945
hu_maternal_loss1520 1.357 1.094 1.691
hu_maternal_loss2025 1.311 1.084 1.591
hu_maternal_loss2530 1.21 1.013 1.446
hu_maternal_loss3035 1.243 1.044 1.467
hu_maternal_loss3540 1.067 0.9116 1.241
hu_maternal_loss4045 1.296 1.102 1.53
hu_older_siblings1 0.9886 0.8512 1.147
hu_older_siblings2 0.8586 0.7031 1.032
hu_older_siblings3 0.8251 0.6416 1.063
hu_older_siblings4 0.7922 0.5857 1.076
hu_older_siblings5P 0.5644 0.3792 0.8493
hu_nr.siblings 1.11 1.071 1.152
hu_last_born1 1.078 0.9591 1.224
hu_sbyear_1 0.8597 0.693 1.095

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.54 [2.28;2.81] [2.37;2.72]
estimate father 35y 2.38 [2.01;2.78] [2.13;2.63]
percentage change -6.35 [-21.47;11.08] [-16.4;4.87]
OR/IRR 1.07 [0.96;1.19] [1;1.15]
OR hurdle 1.31 [0.99;1.74] [1.08;1.58]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r9_continuous_byear_adjustment.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r10: Group-level slope added

Paternal age effects may vary between different families. Although we did not explore between-family moderators of paternal age effects in our study, we tested whether modelling an additional group-level slope for paternal age differences within the family, would change the results by allowing for shrinkage and to examine the amount of inter-family differences to be explained for potential future moderator analysis.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
## Warning: There were 3 divergent transitions after warmup. Increasing
## adapt_delta above 0.8 may help. See http://mc-stan.org/misc/
## warnings.html#divergent-transitions-after-warmup
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 + paternalage | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 + paternalage | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 10000; warmup = 4000; thin = 5; 
##          total post-warmup samples = 7200
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## L ~ lkj_corr_cholesky(1)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                                  Estimate Est.Error l-95% CI u-95% CI
## sd(Intercept)                        0.71      0.09     0.52     0.88
## sd(paternalage)                      0.18      0.03     0.12     0.23
## sd(hu_Intercept)                     0.38      0.19     0.03     0.78
## sd(hu_paternalage)                   0.09      0.05     0.01     0.21
## cor(Intercept,paternalage)          -0.96      0.02    -0.98    -0.92
## cor(hu_Intercept,hu_paternalage)    -0.07      0.54    -0.89     0.92
##                                  Eff.Sample Rhat
## sd(Intercept)                          3055 1.00
## sd(paternalage)                        2382 1.00
## sd(hu_Intercept)                       1623 1.00
## sd(hu_paternalage)                      375 1.01
## cor(Intercept,paternalage)             3469 1.00
## cor(hu_Intercept,hu_paternalage)        989 1.00
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.63      0.08     1.47     1.80       6098
## paternalage                   0.07      0.06    -0.04     0.19       5432
## birth_cohort1760M1765        -0.01      0.06    -0.14     0.12       6137
## birth_cohort1765M1770        -0.12      0.06    -0.23    -0.01       5509
## birth_cohort1770M1775        -0.12      0.06    -0.23     0.00       5569
## birth_cohort1775M1780        -0.04      0.06    -0.15     0.07       4964
## birth_cohort1780M1785        -0.12      0.06    -0.23     0.00       5773
## birth_cohort1785M1790        -0.11      0.06    -0.22     0.00       4841
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03       4610
## birth_cohort1795M1800        -0.11      0.05    -0.21    -0.01       5465
## birth_cohort1800M1805        -0.12      0.05    -0.22    -0.02       5205
## birth_cohort1805M1810        -0.14      0.05    -0.24    -0.04       5154
## birth_cohort1810M1815        -0.10      0.05    -0.20    -0.01       4755
## birth_cohort1815M1820        -0.15      0.05    -0.24    -0.06       4574
## birth_cohort1820M1825        -0.20      0.05    -0.29    -0.11       4256
## birth_cohort1825M1830        -0.22      0.05    -0.31    -0.13       4797
## birth_cohort1830M1835        -0.19      0.05    -0.28    -0.09       4854
## male1                         0.08      0.02     0.05     0.11       7028
## maternalage.factor1420       -0.05      0.10    -0.25     0.14       7200
## maternalage.factor3550       -0.01      0.03    -0.06     0.05       7200
## paternalage.mean             -0.07      0.06    -0.19     0.04       5637
## paternal_loss01              -0.15      0.08    -0.30     0.00       7200
## paternal_loss15              -0.04      0.05    -0.14     0.06       6636
## paternal_loss510             -0.08      0.04    -0.16     0.01       6086
## paternal_loss1015             0.00      0.04    -0.08     0.08       6556
## paternal_loss1520            -0.09      0.04    -0.17    -0.01       6344
## paternal_loss2025            -0.12      0.04    -0.19    -0.04       5556
## paternal_loss2530             0.00      0.04    -0.08     0.06       6421
## paternal_loss3035            -0.02      0.03    -0.09     0.04       6486
## paternal_loss3540            -0.01      0.03    -0.07     0.06       6498
## paternal_loss4045            -0.01      0.04    -0.08     0.06       6688
## maternal_loss01               0.10      0.08    -0.06     0.25       6426
## maternal_loss15              -0.01      0.05    -0.11     0.08       6522
## maternal_loss510              0.08      0.04     0.00     0.16       6995
## maternal_loss1015             0.04      0.04    -0.05     0.12       7200
## maternal_loss1520             0.00      0.04    -0.08     0.09       6247
## maternal_loss2025             0.01      0.04    -0.06     0.09       7200
## maternal_loss2530            -0.02      0.04    -0.09     0.05       6373
## maternal_loss3035            -0.04      0.03    -0.11     0.02       7042
## maternal_loss3540            -0.03      0.03    -0.08     0.03       6626
## maternal_loss4045            -0.03      0.03    -0.09     0.04       6922
## older_siblings1               0.03      0.03    -0.03     0.08       6499
## older_siblings2              -0.04      0.04    -0.12     0.03       5862
## older_siblings3              -0.06      0.05    -0.16     0.03       5457
## older_siblings4              -0.09      0.06    -0.21     0.03       5365
## older_siblings5P             -0.09      0.08    -0.26     0.07       5108
## nr.siblings                   0.01      0.01     0.00     0.02       5755
## last_born1                   -0.04      0.02    -0.09     0.00       7200
## hu_Intercept                 -0.33      0.20    -0.73     0.04       5660
## hu_paternalage                0.27      0.14     0.00     0.56       5204
## hu_birth_cohort1760M1765     -0.05      0.17    -0.37     0.29       6156
## hu_birth_cohort1765M1770     -0.31      0.15    -0.60    -0.01       5878
## hu_birth_cohort1770M1775     -0.07      0.15    -0.35     0.22       5488
## hu_birth_cohort1775M1780     -0.20      0.14    -0.47     0.09       5508
## hu_birth_cohort1780M1785     -0.27      0.15    -0.56     0.01       5653
## hu_birth_cohort1785M1790     -0.42      0.14    -0.70    -0.13       5560
## hu_birth_cohort1790M1795     -0.31      0.13    -0.57    -0.05       5122
## hu_birth_cohort1795M1800     -0.45      0.13    -0.70    -0.19       5377
## hu_birth_cohort1800M1805     -0.53      0.12    -0.78    -0.29       5514
## hu_birth_cohort1805M1810     -0.26      0.13    -0.51    -0.02       5520
## hu_birth_cohort1810M1815     -0.44      0.12    -0.67    -0.20       5187
## hu_birth_cohort1815M1820     -0.70      0.12    -0.93    -0.47       5205
## hu_birth_cohort1820M1825     -0.52      0.12    -0.75    -0.29       5218
## hu_birth_cohort1825M1830     -0.54      0.12    -0.78    -0.31       4984
## hu_birth_cohort1830M1835     -0.56      0.12    -0.79    -0.32       5239
## hu_male1                      0.27      0.05     0.19     0.36       6970
## hu_maternalage.factor1420     0.25      0.23    -0.19     0.72       7200
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       7200
## hu_paternalage.mean          -0.19      0.15    -0.48     0.10       5314
## hu_paternal_loss01            0.57      0.18     0.21     0.93       6845
## hu_paternal_loss15            0.54      0.13     0.29     0.79       6671
## hu_paternal_loss510           0.19      0.11    -0.03     0.41       6421
## hu_paternal_loss1015          0.16      0.10    -0.05     0.36       6184
## hu_paternal_loss1520          0.10      0.10    -0.10     0.30       6605
## hu_paternal_loss2025          0.15      0.10    -0.03     0.35       6452
## hu_paternal_loss2530          0.06      0.09    -0.12     0.24       6379
## hu_paternal_loss3035         -0.02      0.09    -0.20     0.15       6013
## hu_paternal_loss3540         -0.02      0.09    -0.19     0.16       6448
## hu_paternal_loss4045          0.14      0.10    -0.05     0.34       7012
## hu_maternal_loss01            1.58      0.19     1.21     1.95       6948
## hu_maternal_loss15            0.58      0.12     0.35     0.82       6888
## hu_maternal_loss510           0.48      0.11     0.27     0.69       6840
## hu_maternal_loss1015          0.46      0.11     0.25     0.68       7008
## hu_maternal_loss1520          0.30      0.11     0.09     0.52       7055
## hu_maternal_loss2025          0.26      0.10     0.06     0.47       7119
## hu_maternal_loss2530          0.19      0.09     0.01     0.37       7200
## hu_maternal_loss3035          0.22      0.09     0.05     0.39       6972
## hu_maternal_loss3540          0.07      0.08    -0.10     0.22       7200
## hu_maternal_loss4045          0.28      0.08     0.11     0.44       6930
## hu_older_siblings1           -0.01      0.07    -0.16     0.13       6576
## hu_older_siblings2           -0.16      0.10    -0.35     0.03       5814
## hu_older_siblings3           -0.20      0.13    -0.45     0.04       5382
## hu_older_siblings4           -0.24      0.16    -0.54     0.07       5809
## hu_older_siblings5P          -0.58      0.20    -0.98    -0.18       5468
## hu_nr.siblings                0.10      0.02     0.07     0.14       5772
## hu_last_born1                 0.08      0.06    -0.04     0.21       6346
##                           Rhat
## Intercept                    1
## paternalage                  1
## birth_cohort1760M1765        1
## birth_cohort1765M1770        1
## birth_cohort1770M1775        1
## birth_cohort1775M1780        1
## birth_cohort1780M1785        1
## birth_cohort1785M1790        1
## birth_cohort1790M1795        1
## birth_cohort1795M1800        1
## birth_cohort1800M1805        1
## birth_cohort1805M1810        1
## birth_cohort1810M1815        1
## birth_cohort1815M1820        1
## birth_cohort1820M1825        1
## birth_cohort1825M1830        1
## birth_cohort1830M1835        1
## male1                        1
## maternalage.factor1420       1
## maternalage.factor3550       1
## paternalage.mean             1
## paternal_loss01              1
## paternal_loss15              1
## paternal_loss510             1
## paternal_loss1015            1
## paternal_loss1520            1
## paternal_loss2025            1
## paternal_loss2530            1
## paternal_loss3035            1
## paternal_loss3540            1
## paternal_loss4045            1
## maternal_loss01              1
## maternal_loss15              1
## maternal_loss510             1
## maternal_loss1015            1
## maternal_loss1520            1
## maternal_loss2025            1
## maternal_loss2530            1
## maternal_loss3035            1
## maternal_loss3540            1
## maternal_loss4045            1
## older_siblings1              1
## older_siblings2              1
## older_siblings3              1
## older_siblings4              1
## older_siblings5P             1
## nr.siblings                  1
## last_born1                   1
## hu_Intercept                 1
## hu_paternalage               1
## hu_birth_cohort1760M1765     1
## hu_birth_cohort1765M1770     1
## hu_birth_cohort1770M1775     1
## hu_birth_cohort1775M1780     1
## hu_birth_cohort1780M1785     1
## hu_birth_cohort1785M1790     1
## hu_birth_cohort1790M1795     1
## hu_birth_cohort1795M1800     1
## hu_birth_cohort1800M1805     1
## hu_birth_cohort1805M1810     1
## hu_birth_cohort1810M1815     1
## hu_birth_cohort1815M1820     1
## hu_birth_cohort1820M1825     1
## hu_birth_cohort1825M1830     1
## hu_birth_cohort1830M1835     1
## hu_male1                     1
## hu_maternalage.factor1420    1
## hu_maternalage.factor3550    1
## hu_paternalage.mean          1
## hu_paternal_loss01           1
## hu_paternal_loss15           1
## hu_paternal_loss510          1
## hu_paternal_loss1015         1
## hu_paternal_loss1520         1
## hu_paternal_loss2025         1
## hu_paternal_loss2530         1
## hu_paternal_loss3035         1
## hu_paternal_loss3540         1
## hu_paternal_loss4045         1
## hu_maternal_loss01           1
## hu_maternal_loss15           1
## hu_maternal_loss510          1
## hu_maternal_loss1015         1
## hu_maternal_loss1520         1
## hu_maternal_loss2025         1
## hu_maternal_loss2530         1
## hu_maternal_loss3035         1
## hu_maternal_loss3540         1
## hu_maternal_loss4045         1
## hu_older_siblings1           1
## hu_older_siblings2           1
## hu_older_siblings3           1
## hu_older_siblings4           1
## hu_older_siblings5P          1
## hu_nr.siblings               1
## hu_last_born1                1
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.117 4.351 6.029
paternalage 1.076 0.9647 1.204
birth_cohort1760M1765 0.991 0.8713 1.123
birth_cohort1765M1770 0.8854 0.7909 0.993
birth_cohort1770M1775 0.8904 0.7913 1.001
birth_cohort1775M1780 0.9581 0.8586 1.071
birth_cohort1780M1785 0.8898 0.7926 0.9958
birth_cohort1785M1790 0.8946 0.801 0.9985
birth_cohort1790M1795 0.9252 0.8324 1.027
birth_cohort1795M1800 0.8941 0.809 0.9862
birth_cohort1800M1805 0.8893 0.8053 0.9775
birth_cohort1805M1810 0.8709 0.7872 0.9613
birth_cohort1810M1815 0.9013 0.8187 0.9918
birth_cohort1815M1820 0.86 0.7852 0.9415
birth_cohort1820M1825 0.8206 0.747 0.8987
birth_cohort1825M1830 0.8032 0.7318 0.88
birth_cohort1830M1835 0.8299 0.7545 0.9109
male1 1.081 1.047 1.118
maternalage.factor1420 0.9483 0.7823 1.146
maternalage.factor3550 0.9919 0.9387 1.048
paternalage.mean 0.9318 0.8299 1.04
paternal_loss01 0.8615 0.7429 0.9958
paternal_loss15 0.9613 0.8698 1.062
paternal_loss510 0.925 0.8489 1.01
paternal_loss1015 1.002 0.9258 1.083
paternal_loss1520 0.9103 0.8423 0.9857
paternal_loss2025 0.8868 0.8233 0.9567
paternal_loss2530 0.9951 0.9274 1.067
paternal_loss3035 0.9756 0.9128 1.044
paternal_loss3540 0.9912 0.9287 1.057
paternal_loss4045 0.9912 0.9219 1.066
maternal_loss01 1.103 0.9401 1.289
maternal_loss15 0.9862 0.8979 1.087
maternal_loss510 1.08 0.9965 1.171
maternal_loss1015 1.037 0.9545 1.123
maternal_loss1520 1.004 0.9234 1.09
maternal_loss2025 1.013 0.9374 1.095
maternal_loss2530 0.9832 0.917 1.056
maternal_loss3035 0.9587 0.8985 1.023
maternal_loss3540 0.9746 0.9194 1.035
maternal_loss4045 0.9746 0.9145 1.038
older_siblings1 1.029 0.9738 1.086
older_siblings2 0.9579 0.8896 1.031
older_siblings3 0.9373 0.8518 1.03
older_siblings4 0.9177 0.8132 1.033
older_siblings5P 0.9136 0.7747 1.068
nr.siblings 1.01 0.9955 1.025
last_born1 0.9572 0.9129 1.004
hu_Intercept 0.7155 0.4833 1.045
hu_paternalage 1.316 0.9956 1.751
hu_birth_cohort1760M1765 0.9507 0.6876 1.335
hu_birth_cohort1765M1770 0.7343 0.5506 0.9873
hu_birth_cohort1770M1775 0.9362 0.702 1.248
hu_birth_cohort1775M1780 0.8217 0.6232 1.093
hu_birth_cohort1780M1785 0.7604 0.5689 1.011
hu_birth_cohort1785M1790 0.6564 0.496 0.8757
hu_birth_cohort1790M1795 0.7349 0.5645 0.9556
hu_birth_cohort1795M1800 0.6352 0.4952 0.8237
hu_birth_cohort1800M1805 0.5868 0.4605 0.7502
hu_birth_cohort1805M1810 0.7673 0.5991 0.9803
hu_birth_cohort1810M1815 0.647 0.5104 0.8224
hu_birth_cohort1815M1820 0.4966 0.3926 0.626
hu_birth_cohort1820M1825 0.5953 0.472 0.7476
hu_birth_cohort1825M1830 0.5808 0.46 0.7335
hu_birth_cohort1830M1835 0.5736 0.4548 0.724
hu_male1 1.315 1.205 1.435
hu_maternalage.factor1420 1.286 0.8262 2.046
hu_maternalage.factor3550 1.14 0.9881 1.314
hu_paternalage.mean 0.8258 0.6163 1.1
hu_paternal_loss01 1.775 1.239 2.538
hu_paternal_loss15 1.711 1.331 2.208
hu_paternal_loss510 1.213 0.9738 1.514
hu_paternal_loss1015 1.17 0.9544 1.438
hu_paternal_loss1520 1.109 0.9082 1.352
hu_paternal_loss2025 1.166 0.9656 1.412
hu_paternal_loss2530 1.063 0.8849 1.271
hu_paternal_loss3035 0.9787 0.8201 1.16
hu_paternal_loss3540 0.984 0.8261 1.171
hu_paternal_loss4045 1.152 0.9475 1.401
hu_maternal_loss01 4.845 3.369 7.003
hu_maternal_loss15 1.792 1.417 2.267
hu_maternal_loss510 1.618 1.312 1.992
hu_maternal_loss1015 1.591 1.286 1.967
hu_maternal_loss1520 1.356 1.097 1.677
hu_maternal_loss2025 1.295 1.06 1.592
hu_maternal_loss2530 1.208 1.01 1.446
hu_maternal_loss3035 1.241 1.05 1.472
hu_maternal_loss3540 1.068 0.9086 1.25
hu_maternal_loss4045 1.32 1.115 1.552
hu_older_siblings1 0.9873 0.8548 1.142
hu_older_siblings2 0.8541 0.7069 1.03
hu_older_siblings3 0.8196 0.6403 1.043
hu_older_siblings4 0.7899 0.5819 1.071
hu_older_siblings5P 0.5613 0.3753 0.835
hu_nr.siblings 1.111 1.071 1.153
hu_last_born1 1.085 0.9585 1.23

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.26 [1.92;2.67] [2.04;2.52]
estimate father 35y 2.07 [1.64;2.57] [1.78;2.39]
percentage change -8.56 [-25.31;11.57] [-19.96;3.93]
OR/IRR 1.08 [0.96;1.2] [1;1.16]
OR hurdle 1.32 [1;1.75] [1.09;1.58]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r10_add_random_slope.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r11: Separate group-level effects for each parent

Most anchors in our sample are full biological siblings and especially in the historical populations, divorce and remarriage was rare. Therefore, we chose to include only one group-level effect, for the parent couple (i.e. one group-level effect per father-mother-dyad). Including one intercept per parent is potentially a better way to adjust for genetic propensities inherited from either parent and allows estimating this propensity also from half-siblings, while half-sibling relationships were ignored in our main models. This comes at the cost of modelling complexity.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idMere) + (1 | idPere) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idMere) + (1 | idPere)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 10000; warmup = 4000; thin = 5; 
##          total post-warmup samples = 7200
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idMere (Number of levels: 2124) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.16      0.05     0.03     0.23        361 1.01
## sd(hu_Intercept)     0.41      0.10     0.10     0.54        490 1.01
## 
## ~idPere (Number of levels: 2038) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.13      0.06     0.01     0.23        345 1.01
## sd(hu_Intercept)     0.20      0.13     0.01     0.46        540 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.66      0.08     1.50     1.81       6344
## paternalage                   0.07      0.05    -0.04     0.17       5378
## birth_cohort1760M1765        -0.01      0.06    -0.13     0.12       6228
## birth_cohort1765M1770        -0.12      0.06    -0.23    -0.01       5330
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00       5477
## birth_cohort1775M1780        -0.03      0.06    -0.13     0.08       5347
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.00       5374
## birth_cohort1785M1790        -0.09      0.05    -0.20     0.01       5191
## birth_cohort1790M1795        -0.07      0.05    -0.18     0.03       5273
## birth_cohort1795M1800        -0.10      0.05    -0.20    -0.01       5346
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02       4838
## birth_cohort1805M1810        -0.14      0.05    -0.23    -0.04       5037
## birth_cohort1810M1815        -0.10      0.05    -0.19    -0.01       4791
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05       4789
## birth_cohort1820M1825        -0.18      0.05    -0.27    -0.10       5002
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12       4956
## birth_cohort1830M1835        -0.18      0.05    -0.27    -0.09       5121
## male1                         0.08      0.02     0.05     0.11       7049
## maternalage.factor1420       -0.06      0.09    -0.24     0.12       6924
## maternalage.factor3550        0.00      0.03    -0.06     0.05       6274
## paternalage.mean             -0.07      0.06    -0.18     0.04       5465
## paternal_loss01              -0.15      0.07    -0.30     0.00       7014
## paternal_loss15              -0.03      0.05    -0.13     0.07       6696
## paternal_loss510             -0.07      0.04    -0.15     0.02       6569
## paternal_loss1015             0.01      0.04    -0.07     0.09       6457
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       6296
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       6398
## paternal_loss2530            -0.01      0.03    -0.07     0.06       6888
## paternal_loss3035            -0.03      0.03    -0.09     0.04       6319
## paternal_loss3540            -0.01      0.03    -0.07     0.06       6777
## paternal_loss4045            -0.01      0.04    -0.08     0.06       6360
## maternal_loss01               0.10      0.08    -0.06     0.25       6964
## maternal_loss15              -0.02      0.05    -0.11     0.07       6898
## maternal_loss510              0.07      0.04    -0.01     0.15       6798
## maternal_loss1015             0.03      0.04    -0.05     0.11       6059
## maternal_loss1520             0.00      0.04    -0.08     0.08       6999
## maternal_loss2025             0.00      0.04    -0.07     0.08       7138
## maternal_loss2530            -0.02      0.03    -0.09     0.04       7078
## maternal_loss3035            -0.05      0.03    -0.11     0.01       6812
## maternal_loss3540            -0.03      0.03    -0.09     0.02       6931
## maternal_loss4045            -0.03      0.03    -0.09     0.03       6981
## older_siblings1               0.02      0.03    -0.03     0.08       5936
## older_siblings2              -0.05      0.04    -0.12     0.02       5943
## older_siblings3              -0.07      0.05    -0.17     0.02       5885
## older_siblings4              -0.09      0.06    -0.21     0.03       5531
## older_siblings5P             -0.10      0.08    -0.25     0.06       5554
## nr.siblings                   0.01      0.01     0.00     0.02       5858
## last_born1                   -0.04      0.02    -0.09     0.00       7200
## hu_Intercept                 -0.32      0.20    -0.71     0.07       6441
## hu_paternalage                0.26      0.14    -0.03     0.54       5609
## hu_birth_cohort1760M1765     -0.05      0.17    -0.38     0.29       6444
## hu_birth_cohort1765M1770     -0.31      0.15    -0.61    -0.02       6056
## hu_birth_cohort1770M1775     -0.07      0.15    -0.36     0.22       6451
## hu_birth_cohort1775M1780     -0.20      0.14    -0.47     0.08       5778
## hu_birth_cohort1780M1785     -0.27      0.15    -0.56     0.02       5681
## hu_birth_cohort1785M1790     -0.42      0.15    -0.71    -0.12       5891
## hu_birth_cohort1790M1795     -0.31      0.14    -0.58    -0.05       5570
## hu_birth_cohort1795M1800     -0.46      0.13    -0.71    -0.21       5679
## hu_birth_cohort1800M1805     -0.54      0.13    -0.78    -0.29       5475
## hu_birth_cohort1805M1810     -0.27      0.13    -0.52    -0.03       5868
## hu_birth_cohort1810M1815     -0.44      0.12    -0.68    -0.20       5451
## hu_birth_cohort1815M1820     -0.70      0.12    -0.93    -0.47       5462
## hu_birth_cohort1820M1825     -0.52      0.12    -0.76    -0.29       5472
## hu_birth_cohort1825M1830     -0.55      0.12    -0.78    -0.32       5631
## hu_birth_cohort1830M1835     -0.55      0.12    -0.79    -0.32       5467
## hu_male1                      0.27      0.05     0.19     0.36       7200
## hu_maternalage.factor1420     0.24      0.23    -0.20     0.70       7200
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       6260
## hu_paternalage.mean          -0.18      0.15    -0.47     0.11       5627
## hu_paternal_loss01            0.58      0.18     0.23     0.93       6759
## hu_paternal_loss15            0.53      0.13     0.27     0.78       6115
## hu_paternal_loss510           0.19      0.11    -0.03     0.41       6933
## hu_paternal_loss1015          0.16      0.11    -0.05     0.36       6843
## hu_paternal_loss1520          0.10      0.10    -0.09     0.30       6789
## hu_paternal_loss2025          0.16      0.10    -0.04     0.35       6860
## hu_paternal_loss2530          0.06      0.09    -0.12     0.24       6632
## hu_paternal_loss3035         -0.02      0.09    -0.20     0.16       6543
## hu_paternal_loss3540         -0.01      0.09    -0.19     0.16       6848
## hu_paternal_loss4045          0.14      0.10    -0.05     0.34       6969
## hu_maternal_loss01            1.58      0.19     1.22     1.95       7200
## hu_maternal_loss15            0.59      0.12     0.35     0.82       6637
## hu_maternal_loss510           0.48      0.11     0.28     0.69       7032
## hu_maternal_loss1015          0.47      0.11     0.26     0.68       7200
## hu_maternal_loss1520          0.31      0.11     0.10     0.52       6745
## hu_maternal_loss2025          0.26      0.10     0.06     0.46       7003
## hu_maternal_loss2530          0.19      0.09     0.01     0.37       6168
## hu_maternal_loss3035          0.22      0.09     0.05     0.38       6961
## hu_maternal_loss3540          0.07      0.08    -0.09     0.23       7200
## hu_maternal_loss4045          0.28      0.08     0.11     0.45       7200
## hu_older_siblings1           -0.01      0.07    -0.15     0.14       6623
## hu_older_siblings2           -0.15      0.10    -0.34     0.04       6181
## hu_older_siblings3           -0.19      0.12    -0.44     0.05       5694
## hu_older_siblings4           -0.23      0.16    -0.53     0.08       5694
## hu_older_siblings5P          -0.57      0.21    -0.97    -0.17       5652
## hu_nr.siblings                0.10      0.02     0.07     0.14       6153
## hu_last_born1                 0.08      0.06    -0.04     0.21       7024
##                           Rhat
## Intercept                    1
## paternalage                  1
## birth_cohort1760M1765        1
## birth_cohort1765M1770        1
## birth_cohort1770M1775        1
## birth_cohort1775M1780        1
## birth_cohort1780M1785        1
## birth_cohort1785M1790        1
## birth_cohort1790M1795        1
## birth_cohort1795M1800        1
## birth_cohort1800M1805        1
## birth_cohort1805M1810        1
## birth_cohort1810M1815        1
## birth_cohort1815M1820        1
## birth_cohort1820M1825        1
## birth_cohort1825M1830        1
## birth_cohort1830M1835        1
## male1                        1
## maternalage.factor1420       1
## maternalage.factor3550       1
## paternalage.mean             1
## paternal_loss01              1
## paternal_loss15              1
## paternal_loss510             1
## paternal_loss1015            1
## paternal_loss1520            1
## paternal_loss2025            1
## paternal_loss2530            1
## paternal_loss3035            1
## paternal_loss3540            1
## paternal_loss4045            1
## maternal_loss01              1
## maternal_loss15              1
## maternal_loss510             1
## maternal_loss1015            1
## maternal_loss1520            1
## maternal_loss2025            1
## maternal_loss2530            1
## maternal_loss3035            1
## maternal_loss3540            1
## maternal_loss4045            1
## older_siblings1              1
## older_siblings2              1
## older_siblings3              1
## older_siblings4              1
## older_siblings5P             1
## nr.siblings                  1
## last_born1                   1
## hu_Intercept                 1
## hu_paternalage               1
## hu_birth_cohort1760M1765     1
## hu_birth_cohort1765M1770     1
## hu_birth_cohort1770M1775     1
## hu_birth_cohort1775M1780     1
## hu_birth_cohort1780M1785     1
## hu_birth_cohort1785M1790     1
## hu_birth_cohort1790M1795     1
## hu_birth_cohort1795M1800     1
## hu_birth_cohort1800M1805     1
## hu_birth_cohort1805M1810     1
## hu_birth_cohort1810M1815     1
## hu_birth_cohort1815M1820     1
## hu_birth_cohort1820M1825     1
## hu_birth_cohort1825M1830     1
## hu_birth_cohort1830M1835     1
## hu_male1                     1
## hu_maternalage.factor1420    1
## hu_maternalage.factor3550    1
## hu_paternalage.mean          1
## hu_paternal_loss01           1
## hu_paternal_loss15           1
## hu_paternal_loss510          1
## hu_paternal_loss1015         1
## hu_paternal_loss1520         1
## hu_paternal_loss2025         1
## hu_paternal_loss2530         1
## hu_paternal_loss3035         1
## hu_paternal_loss3540         1
## hu_paternal_loss4045         1
## hu_maternal_loss01           1
## hu_maternal_loss15           1
## hu_maternal_loss510          1
## hu_maternal_loss1015         1
## hu_maternal_loss1520         1
## hu_maternal_loss2025         1
## hu_maternal_loss2530         1
## hu_maternal_loss3035         1
## hu_maternal_loss3540         1
## hu_maternal_loss4045         1
## hu_older_siblings1           1
## hu_older_siblings2           1
## hu_older_siblings3           1
## hu_older_siblings4           1
## hu_older_siblings5P          1
## hu_nr.siblings               1
## hu_last_born1                1
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.241 4.498 6.122
paternalage 1.069 0.9607 1.187
birth_cohort1760M1765 0.9946 0.8784 1.128
birth_cohort1765M1770 0.8887 0.7923 0.994
birth_cohort1770M1775 0.8943 0.7976 1
birth_cohort1775M1780 0.9746 0.8739 1.087
birth_cohort1780M1785 0.8955 0.7998 1.001
birth_cohort1785M1790 0.9113 0.82 1.014
birth_cohort1790M1795 0.9281 0.8389 1.027
birth_cohort1795M1800 0.9016 0.8202 0.9939
birth_cohort1800M1805 0.8929 0.8119 0.9818
birth_cohort1805M1810 0.8729 0.7932 0.9588
birth_cohort1810M1815 0.9074 0.8275 0.9948
birth_cohort1815M1820 0.8685 0.7933 0.9491
birth_cohort1820M1825 0.8321 0.7611 0.9094
birth_cohort1825M1830 0.8106 0.7381 0.888
birth_cohort1830M1835 0.8339 0.7597 0.9164
male1 1.081 1.046 1.116
maternalage.factor1420 0.9458 0.7839 1.13
maternalage.factor3550 0.9972 0.9443 1.054
paternalage.mean 0.9319 0.8369 1.039
paternal_loss01 0.8635 0.7439 0.9989
paternal_loss15 0.9705 0.8774 1.075
paternal_loss510 0.936 0.8585 1.021
paternal_loss1015 1.01 0.9327 1.094
paternal_loss1520 0.9116 0.8463 0.9835
paternal_loss2025 0.888 0.8263 0.9554
paternal_loss2530 0.9931 0.9288 1.064
paternal_loss3035 0.9744 0.9123 1.04
paternal_loss3540 0.9938 0.9313 1.058
paternal_loss4045 0.9921 0.9237 1.066
maternal_loss01 1.105 0.9442 1.286
maternal_loss15 0.9789 0.8915 1.071
maternal_loss510 1.071 0.99 1.16
maternal_loss1015 1.027 0.9465 1.112
maternal_loss1520 1.003 0.926 1.087
maternal_loss2025 1.003 0.9293 1.085
maternal_loss2530 0.9777 0.9144 1.045
maternal_loss3035 0.9504 0.8915 1.013
maternal_loss3540 0.9669 0.912 1.023
maternal_loss4045 0.9711 0.9125 1.033
older_siblings1 1.025 0.9722 1.083
older_siblings2 0.9535 0.8866 1.024
older_siblings3 0.9288 0.8479 1.019
older_siblings4 0.9117 0.8113 1.026
older_siblings5P 0.9082 0.7798 1.061
nr.siblings 1.01 0.9955 1.024
last_born1 0.9577 0.913 1.004
hu_Intercept 0.7266 0.4938 1.074
hu_paternalage 1.295 0.975 1.715
hu_birth_cohort1760M1765 0.9496 0.6837 1.331
hu_birth_cohort1765M1770 0.7308 0.542 0.9769
hu_birth_cohort1770M1775 0.9347 0.7009 1.245
hu_birth_cohort1775M1780 0.8204 0.6225 1.081
hu_birth_cohort1780M1785 0.7598 0.5726 1.017
hu_birth_cohort1785M1790 0.6556 0.4921 0.8838
hu_birth_cohort1790M1795 0.731 0.5579 0.9521
hu_birth_cohort1795M1800 0.6325 0.4902 0.8137
hu_birth_cohort1800M1805 0.5853 0.4569 0.7497
hu_birth_cohort1805M1810 0.7644 0.5937 0.9752
hu_birth_cohort1810M1815 0.6438 0.5054 0.8209
hu_birth_cohort1815M1820 0.4943 0.3937 0.6221
hu_birth_cohort1820M1825 0.5918 0.4678 0.7494
hu_birth_cohort1825M1830 0.579 0.4578 0.7294
hu_birth_cohort1830M1835 0.5744 0.4521 0.7297
hu_male1 1.315 1.203 1.438
hu_maternalage.factor1420 1.271 0.8165 2.006
hu_maternalage.factor3550 1.142 0.9916 1.313
hu_paternalage.mean 0.8357 0.6237 1.12
hu_paternal_loss01 1.784 1.254 2.547
hu_paternal_loss15 1.691 1.31 2.184
hu_paternal_loss510 1.211 0.9682 1.503
hu_paternal_loss1015 1.17 0.9529 1.438
hu_paternal_loss1520 1.11 0.91 1.35
hu_paternal_loss2025 1.168 0.9629 1.418
hu_paternal_loss2530 1.062 0.8833 1.273
hu_paternal_loss3035 0.9789 0.8201 1.172
hu_paternal_loss3540 0.9856 0.8275 1.17
hu_paternal_loss4045 1.153 0.9487 1.398
hu_maternal_loss01 4.844 3.381 7.038
hu_maternal_loss15 1.798 1.423 2.269
hu_maternal_loss510 1.623 1.318 1.986
hu_maternal_loss1015 1.597 1.299 1.965
hu_maternal_loss1520 1.363 1.105 1.685
hu_maternal_loss2025 1.299 1.066 1.589
hu_maternal_loss2530 1.208 1.007 1.454
hu_maternal_loss3035 1.244 1.055 1.468
hu_maternal_loss3540 1.07 0.9152 1.254
hu_maternal_loss4045 1.321 1.121 1.562
hu_older_siblings1 0.991 0.8579 1.145
hu_older_siblings2 0.858 0.7107 1.037
hu_older_siblings3 0.8247 0.6471 1.053
hu_older_siblings4 0.7973 0.5869 1.079
hu_older_siblings5P 0.5668 0.3796 0.8449
hu_nr.siblings 1.109 1.07 1.15
hu_last_born1 1.085 0.9581 1.23

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.28 [1.92;2.67] [2.04;2.53]
estimate father 35y 2.09 [1.65;2.59] [1.79;2.4]
percentage change -8.41 [-25.14;11.23] [-19.31;3.87]
OR/IRR 1.07 [0.96;1.19] [1;1.15]
OR hurdle 1.3 [0.98;1.71] [1.08;1.55]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r11_separate_random_effects_for_parents.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r12: Sex moderation

It need not be the case that paternal age has the same effect on male and female children. For example, male children inherit only the small Y chromosome from the father, but female children inherit the larger X chromosome, so that paternal age predicts X-chromosomal de novo mutations in females but not in males (Francioli et al., 2016). At the same time, the autism literature suggests that males are less robust to heritable and de novo autism risk variants and that these effects are not simply due to having only one X chromosome (Werling & Geschwind, 2015). Here we let a dummy variable for being male moderate the paternal age effect.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage * male + birth_cohort + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + male + birth_cohort + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) + paternalage:male
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1029 1.00
## sd(hu_Intercept)     0.48      0.05     0.38     0.57        728 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.66      0.09     1.49     1.83       1372
## paternalage                   0.07      0.06    -0.04     0.18        690
## male1                         0.07      0.08    -0.09     0.22       2537
## birth_cohort1760M1765         0.00      0.06    -0.12     0.12       1423
## birth_cohort1765M1770        -0.12      0.06    -0.23     0.00        983
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00        916
## birth_cohort1775M1780        -0.03      0.06    -0.13     0.09        936
## birth_cohort1780M1785        -0.11      0.06    -0.23     0.00        933
## birth_cohort1785M1790        -0.10      0.05    -0.20     0.01        856
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03        778
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        761
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        708
## birth_cohort1805M1810        -0.14      0.05    -0.23    -0.04        786
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        675
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        697
## birth_cohort1820M1825        -0.19      0.05    -0.28    -0.10        674
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        678
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        720
## maternalage.factor1420       -0.05      0.09    -0.23     0.13       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.06    -0.18     0.04        735
## paternal_loss01              -0.15      0.08    -0.30     0.00       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       2087
## paternal_loss510             -0.07      0.04    -0.15     0.02       1729
## paternal_loss1015             0.01      0.04    -0.07     0.09       1755
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1714
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       1697
## paternal_loss2530            -0.01      0.03    -0.08     0.05       1607
## paternal_loss3035            -0.03      0.03    -0.09     0.03       1484
## paternal_loss3540            -0.01      0.03    -0.07     0.06       1899
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.10      0.08    -0.06     0.25       3000
## maternal_loss15              -0.02      0.05    -0.11     0.07       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       3000
## maternal_loss1015             0.03      0.04    -0.05     0.11       3000
## maternal_loss1520             0.00      0.04    -0.08     0.09       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       3000
## maternal_loss2530            -0.02      0.04    -0.09     0.04       3000
## maternal_loss3035            -0.05      0.03    -0.12     0.01       3000
## maternal_loss3540            -0.03      0.03    -0.09     0.02       3000
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1749
## older_siblings2              -0.05      0.04    -0.12     0.02        971
## older_siblings3              -0.07      0.05    -0.17     0.02        761
## older_siblings4              -0.09      0.06    -0.21     0.03        698
## older_siblings5P             -0.10      0.08    -0.26     0.06        663
## nr.siblings                   0.01      0.01     0.00     0.02        764
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## paternalage:male1             0.00      0.02    -0.04     0.05       2481
## hu_Intercept                 -0.35      0.22    -0.78     0.10       1351
## hu_paternalage                0.27      0.14    -0.01     0.55        783
## hu_male1                      0.30      0.21    -0.10     0.73       2166
## hu_birth_cohort1760M1765     -0.05      0.17    -0.37     0.28       3000
## hu_birth_cohort1765M1770     -0.31      0.14    -0.58    -0.03       3000
## hu_birth_cohort1770M1775     -0.07      0.14    -0.35     0.21       1453
## hu_birth_cohort1775M1780     -0.20      0.14    -0.47     0.07       1401
## hu_birth_cohort1780M1785     -0.28      0.14    -0.56     0.01       3000
## hu_birth_cohort1785M1790     -0.42      0.14    -0.70    -0.14       1593
## hu_birth_cohort1790M1795     -0.31      0.13    -0.58    -0.06       1100
## hu_birth_cohort1795M1800     -0.46      0.12    -0.69    -0.22       1006
## hu_birth_cohort1800M1805     -0.53      0.12    -0.78    -0.30        594
## hu_birth_cohort1805M1810     -0.27      0.12    -0.51    -0.03        767
## hu_birth_cohort1810M1815     -0.44      0.12    -0.67    -0.20       1083
## hu_birth_cohort1815M1820     -0.70      0.11    -0.93    -0.47        886
## hu_birth_cohort1820M1825     -0.52      0.11    -0.75    -0.30        878
## hu_birth_cohort1825M1830     -0.54      0.11    -0.77    -0.32        849
## hu_birth_cohort1830M1835     -0.55      0.12    -0.78    -0.32        580
## hu_maternalage.factor1420     0.24      0.23    -0.21     0.70       3000
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       3000
## hu_paternalage.mean          -0.18      0.14    -0.46     0.10        854
## hu_paternal_loss01            0.58      0.19     0.22     0.94       3000
## hu_paternal_loss15            0.53      0.13     0.28     0.80       3000
## hu_paternal_loss510           0.20      0.11    -0.03     0.42       1793
## hu_paternal_loss1015          0.16      0.11    -0.05     0.36       1579
## hu_paternal_loss1520          0.10      0.10    -0.10     0.30       1473
## hu_paternal_loss2025          0.15      0.10    -0.03     0.34       1411
## hu_paternal_loss2530          0.06      0.09    -0.12     0.24       1425
## hu_paternal_loss3035         -0.02      0.09    -0.20     0.15       1352
## hu_paternal_loss3540         -0.01      0.09    -0.19     0.16       1563
## hu_paternal_loss4045          0.14      0.10    -0.07     0.34       3000
## hu_maternal_loss01            1.58      0.18     1.23     1.94       3000
## hu_maternal_loss15            0.59      0.12     0.36     0.82       3000
## hu_maternal_loss510           0.48      0.11     0.28     0.69       3000
## hu_maternal_loss1015          0.47      0.10     0.27     0.68       3000
## hu_maternal_loss1520          0.31      0.10     0.11     0.52       3000
## hu_maternal_loss2025          0.26      0.10     0.07     0.46       3000
## hu_maternal_loss2530          0.19      0.09     0.00     0.37       3000
## hu_maternal_loss3035          0.21      0.09     0.04     0.38       3000
## hu_maternal_loss3540          0.07      0.08    -0.09     0.22       3000
## hu_maternal_loss4045          0.28      0.08     0.11     0.45       3000
## hu_older_siblings1           -0.01      0.07    -0.16     0.13       1597
## hu_older_siblings2           -0.16      0.10    -0.35     0.02        955
## hu_older_siblings3           -0.20      0.13    -0.43     0.05        817
## hu_older_siblings4           -0.23      0.15    -0.53     0.06        775
## hu_older_siblings5P          -0.58      0.20    -0.98    -0.19        755
## hu_nr.siblings                0.10      0.02     0.07     0.14       1054
## hu_last_born1                 0.08      0.06    -0.04     0.20       3000
## hu_paternalage:male1         -0.01      0.06    -0.13     0.11       2259
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## male1                     1.00
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.01
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.01
## birth_cohort1790M1795     1.01
## birth_cohort1795M1800     1.01
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.00
## birth_cohort1810M1815     1.00
## birth_cohort1815M1820     1.00
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.00
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.00
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## paternalage:male1         1.00
## hu_Intercept              1.00
## hu_paternalage            1.01
## hu_male1                  1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.00
## hu_birth_cohort1815M1820  1.00
## hu_birth_cohort1820M1825  1.00
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.01
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.01
## hu_older_siblings3        1.02
## hu_older_siblings4        1.01
## hu_older_siblings5P       1.02
## hu_nr.siblings            1.01
## hu_last_born1             1.00
## hu_paternalage:male1      1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.234 4.431 6.222
paternalage 1.069 0.959 1.199
male1 1.075 0.9174 1.252
birth_cohort1760M1765 0.9968 0.8842 1.124
birth_cohort1765M1770 0.8874 0.7925 0.996
birth_cohort1770M1775 0.8916 0.7966 0.9962
birth_cohort1775M1780 0.9742 0.876 1.091
birth_cohort1780M1785 0.8962 0.7965 1.002
birth_cohort1785M1790 0.9078 0.8172 1.009
birth_cohort1790M1795 0.9262 0.8339 1.028
birth_cohort1795M1800 0.8999 0.8172 0.9893
birth_cohort1800M1805 0.8919 0.8112 0.9781
birth_cohort1805M1810 0.873 0.7922 0.9616
birth_cohort1810M1815 0.9072 0.8266 0.9967
birth_cohort1815M1820 0.8679 0.7929 0.95
birth_cohort1820M1825 0.8305 0.7575 0.9088
birth_cohort1825M1830 0.8102 0.7378 0.8859
birth_cohort1830M1835 0.8332 0.7584 0.9129
maternalage.factor1420 0.9476 0.795 1.134
maternalage.factor3550 0.9971 0.9446 1.054
paternalage.mean 0.9327 0.8316 1.039
paternal_loss01 0.8576 0.7407 1.001
paternal_loss15 0.9638 0.8701 1.063
paternal_loss510 0.9351 0.8609 1.017
paternal_loss1015 1.007 0.9296 1.089
paternal_loss1520 0.9116 0.8438 0.9804
paternal_loss2025 0.8878 0.8257 0.953
paternal_loss2530 0.991 0.9271 1.056
paternal_loss3035 0.9723 0.9129 1.035
paternal_loss3540 0.9913 0.9326 1.058
paternal_loss4045 0.9907 0.921 1.063
maternal_loss01 1.105 0.9397 1.287
maternal_loss15 0.9804 0.8945 1.072
maternal_loss510 1.073 0.9923 1.159
maternal_loss1015 1.027 0.9486 1.111
maternal_loss1520 1.003 0.9255 1.089
maternal_loss2025 1.005 0.9329 1.081
maternal_loss2530 0.9785 0.9118 1.046
maternal_loss3035 0.9503 0.89 1.01
maternal_loss3540 0.9678 0.9126 1.021
maternal_loss4045 0.972 0.9152 1.034
older_siblings1 1.026 0.9732 1.084
older_siblings2 0.953 0.8855 1.024
older_siblings3 0.9292 0.8455 1.02
older_siblings4 0.9113 0.8073 1.026
older_siblings5P 0.9078 0.7743 1.063
nr.siblings 1.01 0.9953 1.024
last_born1 0.9572 0.9146 1.002
paternalage:male1 1.002 0.9593 1.048
hu_Intercept 0.7072 0.4605 1.103
hu_paternalage 1.307 0.9891 1.731
hu_male1 1.354 0.909 2.069
hu_birth_cohort1760M1765 0.9518 0.6918 1.32
hu_birth_cohort1765M1770 0.7366 0.5582 0.969
hu_birth_cohort1770M1775 0.9358 0.7081 1.235
hu_birth_cohort1775M1780 0.8219 0.6275 1.071
hu_birth_cohort1780M1785 0.758 0.5704 1.005
hu_birth_cohort1785M1790 0.6589 0.4962 0.8668
hu_birth_cohort1790M1795 0.7329 0.5612 0.9434
hu_birth_cohort1795M1800 0.634 0.5001 0.8051
hu_birth_cohort1800M1805 0.5858 0.4586 0.7379
hu_birth_cohort1805M1810 0.7657 0.6016 0.9733
hu_birth_cohort1810M1815 0.6452 0.5101 0.8151
hu_birth_cohort1815M1820 0.4959 0.3931 0.6254
hu_birth_cohort1820M1825 0.5935 0.4735 0.7408
hu_birth_cohort1825M1830 0.5812 0.4626 0.7292
hu_birth_cohort1830M1835 0.5762 0.4563 0.7243
hu_maternalage.factor1420 1.269 0.8077 2.004
hu_maternalage.factor3550 1.142 0.9889 1.312
hu_paternalage.mean 0.8342 0.6308 1.101
hu_paternal_loss01 1.785 1.241 2.557
hu_paternal_loss15 1.697 1.323 2.221
hu_paternal_loss510 1.217 0.9739 1.519
hu_paternal_loss1015 1.174 0.956 1.439
hu_paternal_loss1520 1.108 0.9071 1.347
hu_paternal_loss2025 1.166 0.967 1.409
hu_paternal_loss2530 1.061 0.8888 1.274
hu_paternal_loss3035 0.9777 0.817 1.164
hu_paternal_loss3540 0.9865 0.8257 1.176
hu_paternal_loss4045 1.153 0.9351 1.407
hu_maternal_loss01 4.863 3.423 6.949
hu_maternal_loss15 1.8 1.433 2.277
hu_maternal_loss510 1.624 1.32 1.991
hu_maternal_loss1015 1.606 1.312 1.968
hu_maternal_loss1520 1.369 1.117 1.675
hu_maternal_loss2025 1.299 1.073 1.583
hu_maternal_loss2530 1.21 1.004 1.453
hu_maternal_loss3035 1.239 1.044 1.469
hu_maternal_loss3540 1.07 0.9124 1.251
hu_maternal_loss4045 1.319 1.121 1.564
hu_older_siblings1 0.9858 0.848 1.137
hu_older_siblings2 0.8538 0.7055 1.024
hu_older_siblings3 0.8215 0.6479 1.053
hu_older_siblings4 0.7911 0.5892 1.066
hu_older_siblings5P 0.5611 0.3767 0.8303
hu_nr.siblings 1.11 1.071 1.15
hu_last_born1 1.084 0.9612 1.226
hu_paternalage:male1 0.9917 0.8812 1.112

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.29 [1.94;2.7] [2.05;2.54]
estimate father 35y 2.09 [1.65;2.59] [1.8;2.41]
percentage change -9.05 [-25.49;11.82] [-20.29;4.37]
OR/IRR 1.07 [0.96;1.2] [0.99;1.15]
OR hurdle 1.3 [0.99;1.73] [1.09;1.57]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r12_sex_moderation.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r13: Control paternal age at first birth

We already control for the average paternal age at which the children in a family were born. The mean is a more complete summary of the reproductive timing of the father than the age at first birth. However, far more literature has examined age at first birth and it has the advantage of never being censored (although we of course try to rule out censoring by choosing appropriate subsets). Therefore, we added age at first birth as a covariate in this model.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage_at_1st_sib + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage_at_1st_sib + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1500; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.25        860    1
## sd(hu_Intercept)     0.47      0.04     0.39     0.56        818    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.66      0.08     1.50     1.82       1348
## paternalage                   0.07      0.06    -0.04     0.18        708
## birth_cohort1760M1765         0.00      0.06    -0.12     0.12       1182
## birth_cohort1765M1770        -0.12      0.06    -0.23     0.00       1007
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00        869
## birth_cohort1775M1780        -0.02      0.06    -0.14     0.09        786
## birth_cohort1780M1785        -0.11      0.06    -0.23     0.01        881
## birth_cohort1785M1790        -0.09      0.06    -0.21     0.01        739
## birth_cohort1790M1795        -0.07      0.05    -0.18     0.03        680
## birth_cohort1795M1800        -0.10      0.05    -0.20     0.00        674
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.01        613
## birth_cohort1805M1810        -0.13      0.05    -0.23    -0.04        636
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        610
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        538
## birth_cohort1820M1825        -0.18      0.05    -0.27    -0.09        551
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.11        565
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        558
## male1                         0.08      0.02     0.05     0.11       3000
## maternalage.factor1420       -0.05      0.09    -0.24     0.12       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage_at_1st_sib       -0.01      0.03    -0.08     0.05       3000
## paternalage.mean             -0.06      0.06    -0.18     0.06        793
## paternal_loss01              -0.15      0.07    -0.30    -0.01       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       1831
## paternal_loss510             -0.07      0.04    -0.16     0.02       1573
## paternal_loss1015             0.01      0.04    -0.07     0.09       1428
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1574
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       1466
## paternal_loss2530            -0.01      0.03    -0.08     0.06       1382
## paternal_loss3035            -0.03      0.03    -0.10     0.04       1417
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1473
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.10      0.08    -0.06     0.26       3000
## maternal_loss15              -0.02      0.05    -0.11     0.08       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       3000
## maternal_loss1015             0.03      0.04    -0.05     0.11       3000
## maternal_loss1520             0.00      0.04    -0.07     0.08       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       2007
## maternal_loss2530            -0.02      0.03    -0.09     0.05       1932
## maternal_loss3035            -0.05      0.03    -0.12     0.01       1904
## maternal_loss3540            -0.03      0.03    -0.09     0.03       3000
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1335
## older_siblings2              -0.05      0.04    -0.12     0.02        820
## older_siblings3              -0.07      0.05    -0.17     0.02        689
## older_siblings4              -0.09      0.06    -0.22     0.02        739
## older_siblings5P             -0.10      0.08    -0.26     0.06        648
## nr.siblings                   0.01      0.01    -0.01     0.02        764
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                 -0.38      0.20    -0.78     0.01       1116
## hu_paternalage                0.26      0.15    -0.03     0.53        796
## hu_birth_cohort1760M1765     -0.05      0.17    -0.38     0.29       3000
## hu_birth_cohort1765M1770     -0.31      0.15    -0.60    -0.03       1122
## hu_birth_cohort1770M1775     -0.06      0.15    -0.36     0.22       1030
## hu_birth_cohort1775M1780     -0.20      0.14    -0.48     0.09       1005
## hu_birth_cohort1780M1785     -0.28      0.14    -0.56     0.00       1006
## hu_birth_cohort1785M1790     -0.42      0.14    -0.70    -0.14        961
## hu_birth_cohort1790M1795     -0.32      0.13    -0.58    -0.06        798
## hu_birth_cohort1795M1800     -0.47      0.13    -0.72    -0.21        755
## hu_birth_cohort1800M1805     -0.54      0.13    -0.80    -0.29        837
## hu_birth_cohort1805M1810     -0.27      0.13    -0.52    -0.02        813
## hu_birth_cohort1810M1815     -0.44      0.12    -0.67    -0.21        808
## hu_birth_cohort1815M1820     -0.71      0.12    -0.94    -0.48        654
## hu_birth_cohort1820M1825     -0.53      0.12    -0.76    -0.30        697
## hu_birth_cohort1825M1830     -0.55      0.12    -0.78    -0.32        634
## hu_birth_cohort1830M1835     -0.56      0.12    -0.79    -0.32        699
## hu_male1                      0.28      0.05     0.18     0.36       3000
## hu_maternalage.factor1420     0.24      0.23    -0.21     0.69       3000
## hu_maternalage.factor3550     0.14      0.07    -0.01     0.28       3000
## hu_paternalage_at_1st_sib     0.08      0.08    -0.07     0.23       3000
## hu_paternalage.mean          -0.23      0.15    -0.53     0.07        849
## hu_paternal_loss01            0.57      0.19     0.20     0.95       3000
## hu_paternal_loss15            0.53      0.13     0.27     0.79       3000
## hu_paternal_loss510           0.20      0.11    -0.02     0.42       1537
## hu_paternal_loss1015          0.16      0.11    -0.06     0.37       1377
## hu_paternal_loss1520          0.10      0.10    -0.10     0.29       1334
## hu_paternal_loss2025          0.15      0.10    -0.04     0.35       1349
## hu_paternal_loss2530          0.06      0.09    -0.12     0.24       1274
## hu_paternal_loss3035         -0.03      0.09    -0.21     0.15       1360
## hu_paternal_loss3540         -0.02      0.09    -0.20     0.16       1428
## hu_paternal_loss4045          0.14      0.10    -0.05     0.33       3000
## hu_maternal_loss01            1.57      0.19     1.22     1.94       3000
## hu_maternal_loss15            0.58      0.12     0.35     0.82       3000
## hu_maternal_loss510           0.48      0.11     0.27     0.69       3000
## hu_maternal_loss1015          0.47      0.11     0.24     0.68       3000
## hu_maternal_loss1520          0.31      0.11     0.10     0.52       3000
## hu_maternal_loss2025          0.26      0.10     0.06     0.46       3000
## hu_maternal_loss2530          0.19      0.09     0.00     0.37       3000
## hu_maternal_loss3035          0.22      0.09     0.05     0.39       3000
## hu_maternal_loss3540          0.07      0.08    -0.09     0.23       3000
## hu_maternal_loss4045          0.28      0.09     0.10     0.44       3000
## hu_older_siblings1           -0.01      0.08    -0.16     0.14       3000
## hu_older_siblings2           -0.15      0.10    -0.34     0.04        963
## hu_older_siblings3           -0.19      0.12    -0.43     0.05        904
## hu_older_siblings4           -0.23      0.16    -0.53     0.07        829
## hu_older_siblings5P          -0.57      0.21    -0.96    -0.17        773
## hu_nr.siblings                0.11      0.02     0.07     0.15       1000
## hu_last_born1                 0.08      0.06    -0.04     0.20       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.01
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.01
## birth_cohort1795M1800     1.01
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.00
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.01
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage_at_1st_sib    1.00
## paternalage.mean          1.00
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.01
## older_siblings4           1.00
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.01
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.01
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.01
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.01
## hu_birth_cohort1815M1820  1.01
## hu_birth_cohort1820M1825  1.00
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage_at_1st_sib 1.00
## hu_paternalage.mean       1.01
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.01
## hu_older_siblings4        1.01
## hu_older_siblings5P       1.01
## hu_nr.siblings            1.01
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.283 4.478 6.171
paternalage 1.072 0.9582 1.192
birth_cohort1760M1765 0.998 0.8843 1.129
birth_cohort1765M1770 0.8891 0.795 0.9968
birth_cohort1770M1775 0.8928 0.7962 1.005
birth_cohort1775M1780 0.976 0.8703 1.091
birth_cohort1780M1785 0.8976 0.7978 1.007
birth_cohort1785M1790 0.9105 0.8125 1.014
birth_cohort1790M1795 0.9287 0.8344 1.029
birth_cohort1795M1800 0.9021 0.8158 0.9951
birth_cohort1800M1805 0.8946 0.812 0.9857
birth_cohort1805M1810 0.874 0.7924 0.963
birth_cohort1810M1815 0.9085 0.8294 0.998
birth_cohort1815M1820 0.869 0.7942 0.9543
birth_cohort1820M1825 0.8322 0.7601 0.9131
birth_cohort1825M1830 0.8121 0.7416 0.8947
birth_cohort1830M1835 0.8345 0.7562 0.9153
male1 1.081 1.046 1.116
maternalage.factor1420 0.9497 0.7879 1.132
maternalage.factor3550 0.9957 0.9444 1.051
paternalage_at_1st_sib 0.9866 0.9243 1.049
paternalage.mean 0.9388 0.8366 1.062
paternal_loss01 0.8576 0.7379 0.9888
paternal_loss15 0.9628 0.8689 1.063
paternal_loss510 0.9325 0.8557 1.017
paternal_loss1015 1.006 0.9302 1.09
paternal_loss1520 0.9103 0.8426 0.9779
paternal_loss2025 0.8867 0.825 0.9553
paternal_loss2530 0.9905 0.926 1.06
paternal_loss3035 0.9723 0.9085 1.038
paternal_loss3540 0.9909 0.9312 1.055
paternal_loss4045 0.9901 0.92 1.064
maternal_loss01 1.109 0.9384 1.297
maternal_loss15 0.9818 0.8933 1.078
maternal_loss510 1.074 0.9949 1.16
maternal_loss1015 1.027 0.9493 1.112
maternal_loss1520 1.003 0.9282 1.084
maternal_loss2025 1.003 0.9325 1.081
maternal_loss2530 0.9781 0.9147 1.046
maternal_loss3035 0.9493 0.8895 1.013
maternal_loss3540 0.9665 0.9099 1.028
maternal_loss4045 0.9716 0.9138 1.032
older_siblings1 1.026 0.9732 1.081
older_siblings2 0.9525 0.8853 1.025
older_siblings3 0.9279 0.8439 1.023
older_siblings4 0.9096 0.8038 1.023
older_siblings5P 0.9068 0.7727 1.066
nr.siblings 1.009 0.994 1.025
last_born1 0.9574 0.914 1.005
hu_Intercept 0.6826 0.4576 1.013
hu_paternalage 1.295 0.9666 1.699
hu_birth_cohort1760M1765 0.9509 0.6857 1.334
hu_birth_cohort1765M1770 0.7322 0.5465 0.9731
hu_birth_cohort1770M1775 0.9373 0.7007 1.245
hu_birth_cohort1775M1780 0.8213 0.6211 1.095
hu_birth_cohort1780M1785 0.7556 0.5717 1.001
hu_birth_cohort1785M1790 0.654 0.4982 0.8703
hu_birth_cohort1790M1795 0.7273 0.5616 0.9449
hu_birth_cohort1795M1800 0.6281 0.487 0.8102
hu_birth_cohort1800M1805 0.5814 0.4493 0.7461
hu_birth_cohort1805M1810 0.7611 0.5924 0.9772
hu_birth_cohort1810M1815 0.6438 0.5113 0.8127
hu_birth_cohort1815M1820 0.4937 0.3919 0.6171
hu_birth_cohort1820M1825 0.5908 0.4664 0.7423
hu_birth_cohort1825M1830 0.5785 0.4592 0.7226
hu_birth_cohort1830M1835 0.5729 0.4547 0.7258
hu_male1 1.317 1.203 1.438
hu_maternalage.factor1420 1.277 0.8085 1.995
hu_maternalage.factor3550 1.146 0.989 1.327
hu_paternalage_at_1st_sib 1.078 0.9308 1.255
hu_paternalage.mean 0.7968 0.5913 1.077
hu_paternal_loss01 1.771 1.225 2.576
hu_paternal_loss15 1.696 1.316 2.195
hu_paternal_loss510 1.216 0.9768 1.519
hu_paternal_loss1015 1.171 0.9406 1.449
hu_paternal_loss1520 1.107 0.9004 1.339
hu_paternal_loss2025 1.164 0.9596 1.416
hu_paternal_loss2530 1.062 0.8863 1.272
hu_paternal_loss3035 0.9752 0.8103 1.166
hu_paternal_loss3540 0.984 0.821 1.175
hu_paternal_loss4045 1.152 0.9484 1.386
hu_maternal_loss01 4.823 3.377 6.93
hu_maternal_loss15 1.79 1.415 2.26
hu_maternal_loss510 1.614 1.309 1.991
hu_maternal_loss1015 1.601 1.276 1.98
hu_maternal_loss1520 1.367 1.107 1.682
hu_maternal_loss2025 1.299 1.061 1.58
hu_maternal_loss2530 1.209 1.003 1.443
hu_maternal_loss3035 1.243 1.049 1.476
hu_maternal_loss3540 1.073 0.9145 1.261
hu_maternal_loss4045 1.322 1.109 1.556
hu_older_siblings1 0.9893 0.854 1.151
hu_older_siblings2 0.8571 0.7097 1.04
hu_older_siblings3 0.824 0.6519 1.05
hu_older_siblings4 0.7953 0.5906 1.076
hu_older_siblings5P 0.5647 0.3828 0.8455
hu_nr.siblings 1.114 1.074 1.156
hu_last_born1 1.084 0.9581 1.226

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.28 [1.92;2.66] [2.05;2.52]
estimate father 35y 2.09 [1.67;2.62] [1.81;2.41]
percentage change -8.15 [-24.89;12.04] [-19.48;4.45]
OR/IRR 1.07 [0.96;1.19] [1;1.15]
OR hurdle 1.3 [0.97;1.7] [1.07;1.56]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r13_control_paternal_afb.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r14: Compare lfe

Most of the previous literature has not used multilevel modelling, but linear group fixed effects (essentially dummy variables on the many thousands of families in the model). We believe our multilevel modelling approach has the advantage of allowing us to examine the effect of including predictors at the level of the family in the same model.

This allows us to
a) appropriately model a zero-inflated outcome such as number of children including those who died young (we’re not aware of a linear group fixed effect approach that handles hurdle or zero-inflated models)
b) examine group-level slopes for paternal age and potentially to examine moderators at the level of the family (though we did not do this)
c) explicitly model confounders at the level of the family (e.g. number of siblings).

Nevertheless, the prevalence of this approach in the literature mandates that we show how our approach compares. We fit this model using the R package “lfe” and the function felm. All covariates that were not estimable in principle were removed (i.e. number of siblings, paternalage.mean).

## 
## Call:
##    felm(formula = children ~ paternalage + birth_cohort + male +      maternalage.factor + paternal_loss + maternal_loss + older_siblings +      last_born | idParents, data = model_data) 
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.540 -1.573 -0.406  1.027 13.206 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## paternalage                0.17133    0.33109    0.52   0.6049    
## birth_cohort1760-1765      0.35779    0.30698    1.17   0.2438    
## birth_cohort1765-1770      0.43853    0.36777    1.19   0.2331    
## birth_cohort1770-1775      0.07183    0.43056    0.17   0.8675    
## birth_cohort1775-1780      0.33986    0.49995    0.68   0.4967    
## birth_cohort1780-1785      0.29355    0.57618    0.51   0.6104    
## birth_cohort1785-1790      0.53056    0.65420    0.81   0.4174    
## birth_cohort1790-1795      0.24865    0.72729    0.34   0.7325    
## birth_cohort1795-1800      0.40321    0.79871    0.50   0.6137    
## birth_cohort1800-1805      0.43146    0.87013    0.50   0.6200    
## birth_cohort1805-1810      0.04673    0.94056    0.05   0.9604    
## birth_cohort1810-1815      0.28026    1.01517    0.28   0.7825    
## birth_cohort1815-1820      0.45538    1.08829    0.42   0.6756    
## birth_cohort1820-1825      0.10329    1.16289    0.09   0.9292    
## birth_cohort1825-1830      0.02640    1.23637    0.02   0.9830    
## birth_cohort1830-1835      0.08661    1.31567    0.07   0.9475    
## male1                     -0.14997    0.06556   -2.29   0.0222 *  
## maternalage.factor(14,20] -0.00410    0.34424   -0.01   0.9905    
## maternalage.factor(35,50] -0.07796    0.12193   -0.64   0.5226    
## paternal_loss[0,1]        -1.21851    0.86270   -1.41   0.1579    
## paternal_loss(1,5]        -0.87654    0.78516   -1.12   0.2643    
## paternal_loss(5,10]       -0.57513    0.70735   -0.81   0.4162    
## paternal_loss(10,15]      -0.33064    0.62346   -0.53   0.5959    
## paternal_loss(15,20]      -0.40807    0.54130   -0.75   0.4510    
## paternal_loss(20,25]      -0.46128    0.46058   -1.00   0.3166    
## paternal_loss(25,30]      -0.14990    0.38148   -0.39   0.6944    
## paternal_loss(30,35]       0.05866    0.30667    0.19   0.8483    
## paternal_loss(35,40]      -0.00628    0.23313   -0.03   0.9785    
## paternal_loss(40,45]      -0.16950    0.18583   -0.91   0.3617    
## maternal_loss[0,1]        -2.61540    0.76190   -3.43   0.0006 ***
## maternal_loss(1,5]        -1.44548    0.69856   -2.07   0.0386 *  
## maternal_loss(5,10]       -1.15962    0.63265   -1.83   0.0668 .  
## maternal_loss(10,15]      -1.06668    0.56336   -1.89   0.0583 .  
## maternal_loss(15,20]      -1.04251    0.49101   -2.12   0.0338 *  
## maternal_loss(20,25]      -0.80468    0.41611   -1.93   0.0532 .  
## maternal_loss(25,30]      -0.90035    0.34067   -2.64   0.0082 ** 
## maternal_loss(30,35]      -0.82516    0.27191   -3.03   0.0024 ** 
## maternal_loss(35,40]      -0.46819    0.20562   -2.28   0.0228 *  
## maternal_loss(40,45]      -0.59883    0.16080   -3.72   0.0002 ***
## older_siblings1            0.09345    0.10355    0.90   0.3669    
## older_siblings2            0.10412    0.13844    0.75   0.4520    
## older_siblings3            0.06926    0.17858    0.39   0.6982    
## older_siblings4            0.07289    0.22201    0.33   0.7427    
## older_siblings5+           0.43075    0.29032    1.48   0.1379    
## last_born1                -0.14407    0.08445   -1.71   0.0880 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.78 on 7216 degrees of freedom
## Multiple R-squared(full model): 0.279   Adjusted R-squared: 0.0557 
## Multiple R-squared(proj model): 0.0144   Adjusted R-squared: -0.29 
## F-statistic(full model):1.25 on 2230 and 7216 DF, p-value: 1.56e-11 
## F-statistic(proj model): 2.34 on 45 and 7216 DF, p-value: 1.16e-06

r15: Using a moderator by region, group-level effects by parish

In this model we attempted allow for regional variation in paternal age effects and attempted to better control residual variation. Our approach was two-fold: to moderate paternal age by region and to add a random effect for the church parish in which the individual was born. However, for the modern Swedish data, we had no geographic data and no regional information, so this model was not fit.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) + (1 | gebortk) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) + (1 | gebortk)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~gebortk (Number of levels: 105) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.03      0.02     0.00     0.06        496 1.01
## sd(hu_Intercept)     0.13      0.05     0.04     0.23        978 1.00
## 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.25       1127 1.00
## sd(hu_Intercept)     0.46      0.05     0.37     0.54        691 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.65      0.08     1.50     1.81       1142
## paternalage                   0.07      0.05    -0.04     0.17        930
## birth_cohort1760M1765         0.00      0.06    -0.13     0.12       1212
## birth_cohort1765M1770        -0.12      0.06    -0.23    -0.01        976
## birth_cohort1770M1775        -0.11      0.06    -0.22     0.00        996
## birth_cohort1775M1780        -0.03      0.06    -0.13     0.08        907
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.00        877
## birth_cohort1785M1790        -0.10      0.06    -0.21     0.01        895
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03        838
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        655
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        642
## birth_cohort1805M1810        -0.14      0.05    -0.24    -0.04        580
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        636
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        562
## birth_cohort1820M1825        -0.19      0.05    -0.28    -0.10        563
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        443
## birth_cohort1830M1835        -0.18      0.05    -0.27    -0.09        571
## male1                         0.08      0.02     0.04     0.11       3000
## maternalage.factor1420       -0.05      0.09    -0.24     0.13       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.06    -0.18     0.04        938
## paternal_loss01              -0.15      0.07    -0.30    -0.01       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       1974
## paternal_loss510             -0.07      0.04    -0.15     0.02       1229
## paternal_loss1015             0.01      0.04    -0.07     0.08       1419
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1406
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       1400
## paternal_loss2530            -0.01      0.04    -0.08     0.06       1283
## paternal_loss3035            -0.03      0.03    -0.10     0.04       1330
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1545
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.10      0.08    -0.06     0.25       3000
## maternal_loss15              -0.02      0.05    -0.12     0.07       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       3000
## maternal_loss1015             0.03      0.04    -0.05     0.11       3000
## maternal_loss1520             0.00      0.04    -0.08     0.08       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       3000
## maternal_loss2530            -0.02      0.03    -0.09     0.04       3000
## maternal_loss3035            -0.05      0.03    -0.11     0.01       1848
## maternal_loss3540            -0.03      0.03    -0.09     0.02       2283
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1669
## older_siblings2              -0.05      0.04    -0.12     0.02        971
## older_siblings3              -0.08      0.05    -0.17     0.02        916
## older_siblings4              -0.09      0.06    -0.21     0.02        844
## older_siblings5P             -0.10      0.08    -0.25     0.05        865
## nr.siblings                   0.01      0.01     0.00     0.02       1107
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                 -0.35      0.20    -0.73     0.05       1309
## hu_paternalage                0.27      0.14    -0.01     0.54        923
## hu_birth_cohort1760M1765     -0.03      0.17    -0.35     0.29       3000
## hu_birth_cohort1765M1770     -0.29      0.14    -0.57    -0.01       1058
## hu_birth_cohort1770M1775     -0.05      0.15    -0.33     0.23       1038
## hu_birth_cohort1775M1780     -0.19      0.14    -0.47     0.09       1085
## hu_birth_cohort1780M1785     -0.26      0.15    -0.55     0.02       1105
## hu_birth_cohort1785M1790     -0.41      0.14    -0.69    -0.13        943
## hu_birth_cohort1790M1795     -0.30      0.14    -0.57    -0.05        924
## hu_birth_cohort1795M1800     -0.45      0.13    -0.71    -0.21        882
## hu_birth_cohort1800M1805     -0.52      0.13    -0.76    -0.27        783
## hu_birth_cohort1805M1810     -0.25      0.13    -0.51    -0.01        782
## hu_birth_cohort1810M1815     -0.42      0.12    -0.67    -0.19        797
## hu_birth_cohort1815M1820     -0.69      0.12    -0.92    -0.46        691
## hu_birth_cohort1820M1825     -0.50      0.12    -0.73    -0.27        714
## hu_birth_cohort1825M1830     -0.52      0.12    -0.76    -0.29        740
## hu_birth_cohort1830M1835     -0.53      0.12    -0.78    -0.30        762
## hu_male1                      0.27      0.04     0.19     0.36       3000
## hu_maternalage.factor1420     0.24      0.24    -0.21     0.70       3000
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       3000
## hu_paternalage.mean          -0.18      0.15    -0.47     0.10        969
## hu_paternal_loss01            0.56      0.19     0.19     0.93       3000
## hu_paternal_loss15            0.51      0.13     0.25     0.77       3000
## hu_paternal_loss510           0.17      0.11    -0.04     0.39       1537
## hu_paternal_loss1015          0.14      0.10    -0.07     0.34       1422
## hu_paternal_loss1520          0.09      0.10    -0.11     0.29       1297
## hu_paternal_loss2025          0.14      0.10    -0.04     0.34       1256
## hu_paternal_loss2530          0.05      0.09    -0.14     0.23       1346
## hu_paternal_loss3035         -0.04      0.09    -0.21     0.15       1322
## hu_paternal_loss3540         -0.03      0.09    -0.20     0.15       1514
## hu_paternal_loss4045          0.14      0.10    -0.06     0.32       3000
## hu_maternal_loss01            1.57      0.19     1.20     1.93       3000
## hu_maternal_loss15            0.58      0.12     0.35     0.81       3000
## hu_maternal_loss510           0.48      0.11     0.27     0.69       3000
## hu_maternal_loss1015          0.47      0.11     0.25     0.68       3000
## hu_maternal_loss1520          0.31      0.11     0.10     0.51       3000
## hu_maternal_loss2025          0.26      0.11     0.05     0.46       3000
## hu_maternal_loss2530          0.19      0.09     0.01     0.36       3000
## hu_maternal_loss3035          0.21      0.09     0.04     0.38       3000
## hu_maternal_loss3540          0.07      0.08    -0.09     0.22       3000
## hu_maternal_loss4045          0.27      0.09     0.09     0.44       3000
## hu_older_siblings1           -0.01      0.07    -0.16     0.13       1719
## hu_older_siblings2           -0.15      0.10    -0.34     0.03       1137
## hu_older_siblings3           -0.19      0.13    -0.44     0.06       1011
## hu_older_siblings4           -0.23      0.16    -0.53     0.08       1001
## hu_older_siblings5P          -0.57      0.21    -0.97    -0.16        927
## hu_nr.siblings                0.10      0.02     0.07     0.14       1253
## hu_last_born1                 0.08      0.06    -0.04     0.20       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.01
## birth_cohort1795M1800     1.00
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.00
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.00
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.01
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.00
## hu_birth_cohort1815M1820  1.00
## hu_birth_cohort1820M1825  1.00
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.01
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.01
## hu_older_siblings2        1.01
## hu_older_siblings3        1.01
## hu_older_siblings4        1.01
## hu_older_siblings5P       1.01
## hu_nr.siblings            1.01
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.227 4.461 6.138
paternalage 1.072 0.9626 1.189
birth_cohort1760M1765 0.9958 0.8817 1.126
birth_cohort1765M1770 0.8879 0.7924 0.9931
birth_cohort1770M1775 0.8921 0.8015 0.9972
birth_cohort1775M1780 0.9744 0.874 1.081
birth_cohort1780M1785 0.8965 0.8029 1.002
birth_cohort1785M1790 0.9088 0.8131 1.009
birth_cohort1790M1795 0.9277 0.8357 1.027
birth_cohort1795M1800 0.9003 0.8187 0.9938
birth_cohort1800M1805 0.8928 0.8126 0.9821
birth_cohort1805M1810 0.8717 0.7897 0.9593
birth_cohort1810M1815 0.9061 0.8258 0.9959
birth_cohort1815M1820 0.8665 0.7917 0.9471
birth_cohort1820M1825 0.8298 0.7595 0.9071
birth_cohort1825M1830 0.811 0.741 0.888
birth_cohort1830M1835 0.8334 0.7609 0.9144
male1 1.081 1.046 1.117
maternalage.factor1420 0.9499 0.7892 1.139
maternalage.factor3550 0.9969 0.9445 1.055
paternalage.mean 0.931 0.8345 1.037
paternal_loss01 0.8576 0.7428 0.995
paternal_loss15 0.9615 0.8675 1.065
paternal_loss510 0.9337 0.8572 1.019
paternal_loss1015 1.005 0.9282 1.087
paternal_loss1520 0.9099 0.8434 0.9817
paternal_loss2025 0.8865 0.8233 0.956
paternal_loss2530 0.9904 0.9224 1.063
paternal_loss3035 0.9715 0.9083 1.036
paternal_loss3540 0.9914 0.93 1.055
paternal_loss4045 0.9908 0.9234 1.063
maternal_loss01 1.101 0.9446 1.283
maternal_loss15 0.9786 0.8882 1.07
maternal_loss510 1.073 0.9907 1.163
maternal_loss1015 1.026 0.9488 1.113
maternal_loss1520 1.003 0.925 1.086
maternal_loss2025 1.003 0.9321 1.079
maternal_loss2530 0.9774 0.9121 1.044
maternal_loss3035 0.9487 0.8918 1.013
maternal_loss3540 0.9659 0.9147 1.023
maternal_loss4045 0.9706 0.912 1.031
older_siblings1 1.025 0.9711 1.083
older_siblings2 0.9525 0.8895 1.023
older_siblings3 0.9274 0.846 1.017
older_siblings4 0.9102 0.8102 1.02
older_siblings5P 0.9056 0.781 1.051
nr.siblings 1.01 0.996 1.025
last_born1 0.9569 0.9143 1.002
hu_Intercept 0.7074 0.4821 1.048
hu_paternalage 1.304 0.9868 1.724
hu_birth_cohort1760M1765 0.9683 0.7052 1.338
hu_birth_cohort1765M1770 0.7449 0.5639 0.9879
hu_birth_cohort1770M1775 0.9527 0.7196 1.262
hu_birth_cohort1775M1780 0.8269 0.6264 1.096
hu_birth_cohort1780M1785 0.7684 0.5764 1.018
hu_birth_cohort1785M1790 0.663 0.4994 0.8808
hu_birth_cohort1790M1795 0.7382 0.5656 0.9557
hu_birth_cohort1795M1800 0.6351 0.4904 0.8069
hu_birth_cohort1800M1805 0.5961 0.4674 0.767
hu_birth_cohort1805M1810 0.7764 0.5993 0.9945
hu_birth_cohort1810M1815 0.658 0.5135 0.8289
hu_birth_cohort1815M1820 0.5035 0.3969 0.6309
hu_birth_cohort1820M1825 0.6051 0.48 0.7604
hu_birth_cohort1825M1830 0.592 0.4675 0.7448
hu_birth_cohort1830M1835 0.5868 0.4571 0.7382
hu_male1 1.315 1.208 1.434
hu_maternalage.factor1420 1.268 0.8066 2.015
hu_maternalage.factor3550 1.139 0.9936 1.308
hu_paternalage.mean 0.8352 0.6269 1.101
hu_paternal_loss01 1.742 1.215 2.527
hu_paternal_loss15 1.662 1.29 2.169
hu_paternal_loss510 1.189 0.9597 1.482
hu_paternal_loss1015 1.151 0.9365 1.41
hu_paternal_loss1520 1.09 0.8982 1.336
hu_paternal_loss2025 1.152 0.9618 1.404
hu_paternal_loss2530 1.053 0.8699 1.262
hu_paternal_loss3035 0.9656 0.8092 1.16
hu_paternal_loss3540 0.9749 0.8151 1.162
hu_paternal_loss4045 1.148 0.9387 1.384
hu_maternal_loss01 4.797 3.323 6.887
hu_maternal_loss15 1.788 1.414 2.256
hu_maternal_loss510 1.62 1.315 1.985
hu_maternal_loss1015 1.594 1.286 1.974
hu_maternal_loss1520 1.359 1.102 1.673
hu_maternal_loss2025 1.291 1.051 1.582
hu_maternal_loss2530 1.206 1.008 1.437
hu_maternal_loss3035 1.235 1.042 1.459
hu_maternal_loss3540 1.068 0.9123 1.248
hu_maternal_loss4045 1.316 1.1 1.557
hu_older_siblings1 0.9891 0.855 1.139
hu_older_siblings2 0.8565 0.7112 1.034
hu_older_siblings3 0.8231 0.6469 1.065
hu_older_siblings4 0.7959 0.5868 1.082
hu_older_siblings5P 0.5641 0.3803 0.8498
hu_nr.siblings 1.107 1.068 1.149
hu_last_born1 1.082 0.9575 1.219

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.31 [1.94;2.72] [2.07;2.58]
estimate father 35y 2.11 [1.68;2.65] [1.81;2.45]
percentage change -8.31 [-24.61;10.99] [-19.6;4.1]
OR/IRR 1.07 [0.96;1.19] [1;1.15]
OR hurdle 1.3 [0.99;1.72] [1.08;1.56]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r15_region_moderator_parish_ranef.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r16: Restrict to Skellefteå

Only in the DDB (historical Swedish data), parishes in some of the regions were still unlinked. This means that individuals could occur in more than one parish and not be linked. However, the region of Skellefteå was fully linked. Here, we test what happens when we restrict our dataset to Skellefteå.

r17: Simulating Down syndrome cases

  1. We assume that 4 in 1000 births are children with Down syndrome (four times the actual rate).
  2. We randomly excluded 33% of all children who had a mother older than 40 and had no children (many times the actual rate at that age).

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9286) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2179) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.25       1145 1.01
## sd(hu_Intercept)     0.48      0.05     0.38     0.56        673 1.00
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.65      0.08     1.50     1.81       1440
## paternalage                   0.07      0.05    -0.03     0.18        511
## birth_cohort1760M1765         0.00      0.06    -0.12     0.12       1433
## birth_cohort1765M1770        -0.12      0.06    -0.24     0.00        992
## birth_cohort1770M1775        -0.11      0.06    -0.22     0.00       1003
## birth_cohort1775M1780        -0.03      0.05    -0.13     0.08       1037
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.00        862
## birth_cohort1785M1790        -0.10      0.05    -0.20     0.01        913
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03        616
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        775
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        854
## birth_cohort1805M1810        -0.13      0.05    -0.23    -0.04        816
## birth_cohort1810M1815        -0.10      0.05    -0.19    -0.01        665
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        485
## birth_cohort1820M1825        -0.19      0.05    -0.28    -0.10        442
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        643
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        618
## male1                         0.08      0.02     0.05     0.11       3000
## maternalage.factor1420       -0.05      0.09    -0.23     0.13       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.06    -0.18     0.04        543
## paternal_loss01              -0.15      0.07    -0.30     0.00       3000
## paternal_loss15              -0.04      0.05    -0.13     0.06       1903
## paternal_loss510             -0.07      0.04    -0.15     0.01       1674
## paternal_loss1015             0.01      0.04    -0.07     0.09       1598
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1588
## paternal_loss2025            -0.12      0.04    -0.19    -0.05       1604
## paternal_loss2530            -0.01      0.03    -0.07     0.06       1419
## paternal_loss3035            -0.03      0.03    -0.09     0.03       1537
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1718
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.10      0.08    -0.06     0.26       3000
## maternal_loss15              -0.02      0.05    -0.11     0.07       1870
## maternal_loss510              0.07      0.04    -0.01     0.15       1801
## maternal_loss1015             0.03      0.04    -0.06     0.11       1974
## maternal_loss1520             0.00      0.04    -0.08     0.08       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       3000
## maternal_loss2530            -0.02      0.04    -0.09     0.05       1925
## maternal_loss3035            -0.05      0.03    -0.12     0.01       2035
## maternal_loss3540            -0.03      0.03    -0.09     0.02       2104
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1316
## older_siblings2              -0.05      0.04    -0.12     0.02        788
## older_siblings3              -0.08      0.05    -0.17     0.02        618
## older_siblings4              -0.09      0.06    -0.22     0.02        593
## older_siblings5P             -0.10      0.08    -0.26     0.05        565
## nr.siblings                   0.01      0.01     0.00     0.02        636
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                 -0.33      0.19    -0.71     0.04       1158
## hu_paternalage                0.07      0.15    -0.23     0.36        848
## hu_birth_cohort1760M1765     -0.07      0.16    -0.39     0.24       3000
## hu_birth_cohort1765M1770     -0.30      0.15    -0.58    -0.03       1203
## hu_birth_cohort1770M1775     -0.05      0.14    -0.33     0.23       1022
## hu_birth_cohort1775M1780     -0.20      0.14    -0.48     0.07       1058
## hu_birth_cohort1780M1785     -0.28      0.14    -0.56     0.00       1146
## hu_birth_cohort1785M1790     -0.44      0.14    -0.69    -0.16       1043
## hu_birth_cohort1790M1795     -0.30      0.13    -0.56    -0.03        943
## hu_birth_cohort1795M1800     -0.46      0.12    -0.71    -0.21        876
## hu_birth_cohort1800M1805     -0.52      0.12    -0.77    -0.28        925
## hu_birth_cohort1805M1810     -0.28      0.12    -0.51    -0.04        912
## hu_birth_cohort1810M1815     -0.45      0.12    -0.69    -0.20        846
## hu_birth_cohort1815M1820     -0.70      0.11    -0.92    -0.47        747
## hu_birth_cohort1820M1825     -0.52      0.11    -0.74    -0.29        740
## hu_birth_cohort1825M1830     -0.54      0.12    -0.77    -0.32        789
## hu_birth_cohort1830M1835     -0.55      0.12    -0.77    -0.32        820
## hu_male1                      0.27      0.05     0.18     0.36       3000
## hu_maternalage.factor1420     0.23      0.23    -0.21     0.71       3000
## hu_maternalage.factor3550     0.08      0.07    -0.06     0.23       3000
## hu_paternalage.mean           0.00      0.15    -0.30     0.29        853
## hu_paternal_loss01            0.63      0.18     0.29     0.99       3000
## hu_paternal_loss15            0.56      0.13     0.31     0.82       1703
## hu_paternal_loss510           0.21      0.11    -0.01     0.43       1617
## hu_paternal_loss1015          0.17      0.11    -0.04     0.37       1456
## hu_paternal_loss1520          0.11      0.10    -0.10     0.31       1500
## hu_paternal_loss2025          0.16      0.10    -0.03     0.36       1384
## hu_paternal_loss2530          0.07      0.09    -0.11     0.25       1330
## hu_paternal_loss3035         -0.01      0.09    -0.18     0.17       1356
## hu_paternal_loss3540         -0.01      0.09    -0.19     0.16       1293
## hu_paternal_loss4045          0.15      0.10    -0.05     0.35       3000
## hu_maternal_loss01            1.61      0.19     1.25     1.98       3000
## hu_maternal_loss15            0.58      0.12     0.35     0.83       3000
## hu_maternal_loss510           0.47      0.11     0.26     0.68       3000
## hu_maternal_loss1015          0.46      0.11     0.25     0.67       3000
## hu_maternal_loss1520          0.32      0.11     0.10     0.52       3000
## hu_maternal_loss2025          0.27      0.10     0.07     0.47       3000
## hu_maternal_loss2530          0.19      0.09     0.01     0.37       3000
## hu_maternal_loss3035          0.20      0.09     0.03     0.37       3000
## hu_maternal_loss3540          0.07      0.08    -0.09     0.22       3000
## hu_maternal_loss4045          0.28      0.09     0.11     0.46       3000
## hu_older_siblings1            0.03      0.08    -0.11     0.19       1696
## hu_older_siblings2           -0.06      0.10    -0.26     0.13        979
## hu_older_siblings3           -0.07      0.13    -0.31     0.18        870
## hu_older_siblings4           -0.06      0.16    -0.38     0.26        907
## hu_older_siblings5P          -0.40      0.22    -0.82     0.02        823
## hu_nr.siblings                0.09      0.02     0.05     0.13        996
## hu_last_born1                 0.12      0.06    -0.01     0.25       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.01
## birth_cohort1770M1775     1.01
## birth_cohort1775M1780     1.01
## birth_cohort1780M1785     1.01
## birth_cohort1785M1790     1.01
## birth_cohort1790M1795     1.01
## birth_cohort1795M1800     1.01
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.01
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.01
## hu_paternalage            1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.00
## hu_birth_cohort1815M1820  1.01
## hu_birth_cohort1820M1825  1.01
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.01
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.00
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.231 4.503 6.124
paternalage 1.071 0.9663 1.195
birth_cohort1760M1765 0.9974 0.8831 1.129
birth_cohort1765M1770 0.8876 0.7895 0.9978
birth_cohort1770M1775 0.8915 0.7988 0.9954
birth_cohort1775M1780 0.9746 0.8763 1.083
birth_cohort1780M1785 0.8971 0.8022 0.9998
birth_cohort1785M1790 0.9083 0.8174 1.011
birth_cohort1790M1795 0.9276 0.8365 1.029
birth_cohort1795M1800 0.8999 0.8198 0.9926
birth_cohort1800M1805 0.8937 0.8121 0.981
birth_cohort1805M1810 0.8742 0.795 0.962
birth_cohort1810M1815 0.9073 0.827 0.9928
birth_cohort1815M1820 0.8679 0.7939 0.9497
birth_cohort1820M1825 0.831 0.7592 0.9062
birth_cohort1825M1830 0.8111 0.7413 0.8872
birth_cohort1830M1835 0.8337 0.759 0.9117
male1 1.081 1.046 1.116
maternalage.factor1420 0.9489 0.7947 1.134
maternalage.factor3550 0.9961 0.9426 1.051
paternalage.mean 0.9311 0.8346 1.038
paternal_loss01 0.8601 0.7426 0.9979
paternal_loss15 0.965 0.8741 1.066
paternal_loss510 0.9345 0.8612 1.015
paternal_loss1015 1.008 0.9322 1.089
paternal_loss1520 0.9113 0.8447 0.9797
paternal_loss2025 0.8877 0.8263 0.9511
paternal_loss2530 0.9912 0.9295 1.06
paternal_loss3035 0.9728 0.9122 1.035
paternal_loss3540 0.9914 0.9339 1.053
paternal_loss4045 0.991 0.9253 1.065
maternal_loss01 1.104 0.9406 1.298
maternal_loss15 0.9797 0.8926 1.074
maternal_loss510 1.072 0.9929 1.158
maternal_loss1015 1.027 0.946 1.112
maternal_loss1520 1.002 0.9244 1.084
maternal_loss2025 1.004 0.9303 1.079
maternal_loss2530 0.9782 0.9124 1.052
maternal_loss3035 0.9491 0.8899 1.01
maternal_loss3540 0.9657 0.9117 1.019
maternal_loss4045 0.9701 0.9118 1.03
older_siblings1 1.026 0.9736 1.082
older_siblings2 0.9524 0.885 1.023
older_siblings3 0.9276 0.8431 1.016
older_siblings4 0.9099 0.8057 1.019
older_siblings5P 0.9065 0.7679 1.055
nr.siblings 1.01 0.9956 1.025
last_born1 0.9576 0.9134 1.001
hu_Intercept 0.7159 0.491 1.045
hu_paternalage 1.07 0.7962 1.429
hu_birth_cohort1760M1765 0.9338 0.6767 1.275
hu_birth_cohort1765M1770 0.7397 0.5599 0.9723
hu_birth_cohort1770M1775 0.9469 0.7163 1.258
hu_birth_cohort1775M1780 0.8172 0.6186 1.073
hu_birth_cohort1780M1785 0.7563 0.5702 0.9979
hu_birth_cohort1785M1790 0.647 0.5003 0.8539
hu_birth_cohort1790M1795 0.7442 0.5735 0.97
hu_birth_cohort1795M1800 0.6291 0.4941 0.8103
hu_birth_cohort1800M1805 0.5935 0.4637 0.7553
hu_birth_cohort1805M1810 0.7568 0.5984 0.9617
hu_birth_cohort1810M1815 0.638 0.503 0.8148
hu_birth_cohort1815M1820 0.4982 0.4 0.6248
hu_birth_cohort1820M1825 0.5966 0.4766 0.7474
hu_birth_cohort1825M1830 0.5799 0.4609 0.7274
hu_birth_cohort1830M1835 0.5787 0.462 0.7241
hu_male1 1.316 1.197 1.437
hu_maternalage.factor1420 1.256 0.8138 2.043
hu_maternalage.factor3550 1.087 0.9417 1.261
hu_paternalage.mean 0.9972 0.7414 1.343
hu_paternal_loss01 1.877 1.331 2.693
hu_paternal_loss15 1.756 1.358 2.268
hu_paternal_loss510 1.233 0.9872 1.543
hu_paternal_loss1015 1.181 0.9561 1.451
hu_paternal_loss1520 1.118 0.9042 1.364
hu_paternal_loss2025 1.179 0.9697 1.438
hu_paternal_loss2530 1.07 0.8954 1.282
hu_paternal_loss3035 0.9927 0.8347 1.19
hu_paternal_loss3540 0.9904 0.8282 1.174
hu_paternal_loss4045 1.165 0.95 1.413
hu_maternal_loss01 4.98 3.504 7.254
hu_maternal_loss15 1.795 1.421 2.287
hu_maternal_loss510 1.605 1.299 1.978
hu_maternal_loss1015 1.58 1.288 1.956
hu_maternal_loss1520 1.379 1.107 1.689
hu_maternal_loss2025 1.309 1.072 1.594
hu_maternal_loss2530 1.206 1.007 1.451
hu_maternal_loss3035 1.22 1.03 1.441
hu_maternal_loss3540 1.067 0.9155 1.246
hu_maternal_loss4045 1.329 1.116 1.582
hu_older_siblings1 1.034 0.8926 1.204
hu_older_siblings2 0.9402 0.7725 1.144
hu_older_siblings3 0.9356 0.7325 1.196
hu_older_siblings4 0.9411 0.6816 1.3
hu_older_siblings5P 0.6683 0.4392 1.025
hu_nr.siblings 1.096 1.055 1.138
hu_last_born1 1.126 0.9935 1.281

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.21 [1.87;2.58] [1.98;2.45]
estimate father 35y 2.27 [1.8;2.8] [1.96;2.61]
percentage change 2.67 [-15.43;25.56] [-10.09;17.18]
OR/IRR 1.07 [0.97;1.2] [1;1.15]
OR hurdle 1.07 [0.8;1.43] [0.88;1.29]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r17_simulate_downs.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r18: Reversing hurdle_poisson and poisson

To make models computationally feasible and because early mortality was negligible, we fit the very large modern Swedish dataset with a poisson() family distribution. All historical datasets had high early mortality, so we thought a hurdle_poisson() was more appropriate. Here, we show what happens when we reverse this. The hurdle_poisson() model can be fit to the modern Swedish data here, because we only use a subset.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)      0.9      0.02     0.86     0.94        638 1.01
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  0.80      0.15     0.50     1.08        626
## paternalage               -0.02      0.06    -0.14     0.10        595
## birth_cohort1760M1765      0.16      0.07     0.01     0.30        820
## birth_cohort1765M1770      0.23      0.07     0.09     0.37        534
## birth_cohort1770M1775      0.03      0.08    -0.12     0.17        429
## birth_cohort1775M1780      0.21      0.08     0.06     0.35        356
## birth_cohort1780M1785      0.20      0.08     0.04     0.35        373
## birth_cohort1785M1790      0.32      0.08     0.17     0.47        336
## birth_cohort1790M1795      0.22      0.08     0.07     0.37        314
## birth_cohort1795M1800      0.31      0.07     0.16     0.46        297
## birth_cohort1800M1805      0.34      0.07     0.20     0.48        319
## birth_cohort1805M1810      0.15      0.07     0.02     0.30        301
## birth_cohort1810M1815      0.29      0.07     0.15     0.43        273
## birth_cohort1815M1820      0.40      0.07     0.26     0.54        253
## birth_cohort1820M1825      0.25      0.08     0.10     0.39        254
## birth_cohort1825M1830      0.22      0.08     0.07     0.37        243
## birth_cohort1830M1835      0.26      0.08     0.10     0.42        257
## male1                     -0.08      0.02    -0.12    -0.05       3000
## maternalage.factor1420    -0.04      0.10    -0.23     0.15       3000
## maternalage.factor3550    -0.07      0.03    -0.13    -0.01       3000
## paternalage.mean          -0.05      0.07    -0.18     0.08        621
## paternal_loss01           -0.61      0.10    -0.81    -0.42        575
## paternal_loss15           -0.39      0.08    -0.55    -0.24        409
## paternal_loss510          -0.22      0.07    -0.36    -0.08        410
## paternal_loss1015         -0.09      0.06    -0.22     0.03        388
## paternal_loss1520         -0.15      0.06    -0.27    -0.04        414
## paternal_loss2025         -0.19      0.05    -0.30    -0.08        490
## paternal_loss2530         -0.03      0.05    -0.13     0.07        516
## paternal_loss3035          0.05      0.04    -0.04     0.14        580
## paternal_loss3540          0.02      0.04    -0.05     0.10        776
## paternal_loss4045         -0.07      0.04    -0.15     0.01       1186
## maternal_loss01           -1.32      0.10    -1.52    -1.12        736
## maternal_loss15           -0.50      0.07    -0.65    -0.36        447
## maternal_loss510          -0.34      0.06    -0.47    -0.21        418
## maternal_loss1015         -0.33      0.06    -0.46    -0.21        430
## maternal_loss1520         -0.33      0.06    -0.45    -0.21        501
## maternal_loss2025         -0.25      0.06    -0.36    -0.14        519
## maternal_loss2530         -0.29      0.05    -0.39    -0.19        516
## maternal_loss3035         -0.29      0.04    -0.38    -0.21        590
## maternal_loss3540         -0.15      0.04    -0.23    -0.08        679
## maternal_loss4045         -0.26      0.03    -0.32    -0.19       1510
## older_siblings1            0.06      0.03     0.00     0.11       1174
## older_siblings2            0.07      0.04     0.00     0.14        701
## older_siblings3            0.06      0.05    -0.03     0.16        663
## older_siblings4            0.06      0.06    -0.07     0.18        648
## older_siblings5P           0.25      0.08     0.10     0.41        661
## nr.siblings               -0.02      0.01    -0.04     0.00        452
## last_born1                -0.08      0.02    -0.13    -0.04       3000
##                        Rhat
## Intercept              1.01
## paternalage            1.00
## birth_cohort1760M1765  1.01
## birth_cohort1765M1770  1.01
## birth_cohort1770M1775  1.01
## birth_cohort1775M1780  1.01
## birth_cohort1780M1785  1.01
## birth_cohort1785M1790  1.02
## birth_cohort1790M1795  1.01
## birth_cohort1795M1800  1.02
## birth_cohort1800M1805  1.01
## birth_cohort1805M1810  1.02
## birth_cohort1810M1815  1.02
## birth_cohort1815M1820  1.03
## birth_cohort1820M1825  1.03
## birth_cohort1825M1830  1.04
## birth_cohort1830M1835  1.04
## male1                  1.00
## maternalage.factor1420 1.00
## maternalage.factor3550 1.00
## paternalage.mean       1.01
## paternal_loss01        1.01
## paternal_loss15        1.02
## paternal_loss510       1.02
## paternal_loss1015      1.02
## paternal_loss1520      1.02
## paternal_loss2025      1.01
## paternal_loss2530      1.01
## paternal_loss3035      1.01
## paternal_loss3540      1.01
## paternal_loss4045      1.01
## maternal_loss01        1.00
## maternal_loss15        1.01
## maternal_loss510       1.01
## maternal_loss1015      1.01
## maternal_loss1520      1.01
## maternal_loss2025      1.01
## maternal_loss2530      1.00
## maternal_loss3035      1.00
## maternal_loss3540      1.00
## maternal_loss4045      1.00
## older_siblings1        1.00
## older_siblings2        1.00
## older_siblings3        1.00
## older_siblings4        1.01
## older_siblings5P       1.01
## nr.siblings            1.01
## last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 2.217 1.651 2.938
paternalage 0.9788 0.8696 1.104
birth_cohort1760M1765 1.169 1.012 1.345
birth_cohort1765M1770 1.253 1.091 1.445
birth_cohort1770M1775 1.028 0.8913 1.19
birth_cohort1775M1780 1.228 1.057 1.425
birth_cohort1780M1785 1.22 1.045 1.416
birth_cohort1785M1790 1.38 1.181 1.597
birth_cohort1790M1795 1.249 1.072 1.447
birth_cohort1795M1800 1.366 1.179 1.576
birth_cohort1800M1805 1.406 1.219 1.62
birth_cohort1805M1810 1.167 1.016 1.346
birth_cohort1810M1815 1.339 1.166 1.542
birth_cohort1815M1820 1.493 1.296 1.715
birth_cohort1820M1825 1.278 1.105 1.479
birth_cohort1825M1830 1.249 1.077 1.446
birth_cohort1830M1835 1.295 1.103 1.517
male1 0.9187 0.8886 0.9488
maternalage.factor1420 0.9654 0.7981 1.159
maternalage.factor3550 0.9316 0.8773 0.9891
paternalage.mean 0.9506 0.8313 1.086
paternal_loss01 0.5437 0.4455 0.6582
paternal_loss15 0.6771 0.5787 0.7883
paternal_loss510 0.8056 0.6977 0.92
paternal_loss1015 0.9121 0.8005 1.032
paternal_loss1520 0.8574 0.7601 0.9622
paternal_loss2025 0.8238 0.7399 0.9187
paternal_loss2530 0.9704 0.8788 1.074
paternal_loss3035 1.051 0.9621 1.148
paternal_loss3540 1.025 0.9487 1.106
paternal_loss4045 0.9355 0.8647 1.012
maternal_loss01 0.2665 0.2193 0.326
maternal_loss15 0.604 0.5244 0.7007
maternal_loss510 0.7104 0.6254 0.8082
maternal_loss1015 0.7157 0.6326 0.8091
maternal_loss1520 0.7186 0.6389 0.8097
maternal_loss2025 0.7819 0.6989 0.8716
maternal_loss2530 0.7479 0.6793 0.8243
maternal_loss3035 0.7464 0.6849 0.812
maternal_loss3540 0.8577 0.7984 0.9232
maternal_loss4045 0.7741 0.7237 0.8288
older_siblings1 1.057 1.003 1.113
older_siblings2 1.074 0.9985 1.153
older_siblings3 1.066 0.9737 1.172
older_siblings4 1.059 0.9351 1.194
older_siblings5P 1.29 1.106 1.508
nr.siblings 0.9763 0.9561 0.9974
last_born1 0.9201 0.8801 0.9613

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.57 [1.35;1.81] [1.42;1.72]
estimate father 35y 1.53 [1.27;1.84] [1.36;1.73]
percentage change -2.09 [-13.04;10.4] [-9.43;5.83]
OR/IRR 0.98 [0.87;1.1] [0.91;1.06]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r18_hurdle_poisson.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r19: Normal distribution

Previous analysts sometimes decided to use the normal distribution to predict (potentially zero-inflated) count data. Here, we refit our models using a normal distribution for the outcome. We show that estimates for the paternal age effect can be estimated to have a substantially different magnitude, because of this, but did not change direction.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: gaussian(identity) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## sigma ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     0.53      0.06      0.4     0.65        304 1.03
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  2.92      0.25     2.44     3.39       1574
## paternalage               -0.18      0.18    -0.52     0.18        987
## birth_cohort1760M1765      0.08      0.21    -0.33     0.47       1492
## birth_cohort1765M1770      0.12      0.19    -0.25     0.49       1241
## birth_cohort1770M1775     -0.10      0.18    -0.45     0.26       1336
## birth_cohort1775M1780      0.20      0.18    -0.16     0.56       1212
## birth_cohort1780M1785      0.10      0.19    -0.28     0.47       1220
## birth_cohort1785M1790      0.30      0.18    -0.07     0.65       1107
## birth_cohort1790M1795      0.23      0.17    -0.10     0.56       1138
## birth_cohort1795M1800      0.32      0.17    -0.01     0.64       1099
## birth_cohort1800M1805      0.39      0.16     0.07     0.71       1007
## birth_cohort1805M1810      0.08      0.16    -0.24     0.40        950
## birth_cohort1810M1815      0.33      0.16     0.02     0.63        934
## birth_cohort1815M1820      0.51      0.15     0.23     0.80        956
## birth_cohort1820M1825      0.25      0.15    -0.04     0.55        838
## birth_cohort1825M1830      0.23      0.15    -0.06     0.53        849
## birth_cohort1830M1835      0.28      0.16    -0.04     0.59        926
## male1                     -0.15      0.06    -0.26    -0.03       3000
## maternalage.factor1420    -0.35      0.30    -0.94     0.23       3000
## maternalage.factor3550    -0.12      0.09    -0.30     0.07       3000
## paternalage.mean           0.09      0.18    -0.28     0.44        983
## paternal_loss01           -0.82      0.22    -1.25    -0.39       3000
## paternal_loss15           -0.58      0.16    -0.89    -0.26       3000
## paternal_loss510          -0.35      0.15    -0.63    -0.06       1720
## paternal_loss1015         -0.20      0.14    -0.48     0.07       1626
## paternal_loss1520         -0.31      0.13    -0.57    -0.06        932
## paternal_loss2025         -0.40      0.13    -0.65    -0.16       1606
## paternal_loss2530         -0.10      0.12    -0.34     0.14       1130
## paternal_loss3035         -0.07      0.12    -0.31     0.17       1445
## paternal_loss3540         -0.05      0.12    -0.28     0.18       1658
## paternal_loss4045         -0.20      0.13    -0.46     0.06       3000
## maternal_loss01           -1.37      0.20    -1.77    -0.99       3000
## maternal_loss15           -0.61      0.15    -0.90    -0.31       3000
## maternal_loss510          -0.41      0.14    -0.68    -0.13       3000
## maternal_loss1015         -0.43      0.13    -0.70    -0.18       3000
## maternal_loss1520         -0.33      0.14    -0.59    -0.06       3000
## maternal_loss2025         -0.25      0.14    -0.51     0.02       3000
## maternal_loss2530         -0.24      0.12    -0.49    -0.01       3000
## maternal_loss3035         -0.32      0.12    -0.54    -0.09       3000
## maternal_loss3540         -0.13      0.11    -0.34     0.08       2139
## maternal_loss4045         -0.35      0.11    -0.57    -0.12       3000
## older_siblings1            0.06      0.10    -0.14     0.26       3000
## older_siblings2            0.10      0.12    -0.14     0.34       1254
## older_siblings3            0.09      0.16    -0.22     0.39       1022
## older_siblings4            0.08      0.19    -0.29     0.47       1056
## older_siblings5P           0.45      0.26    -0.07     0.94        887
## nr.siblings               -0.09      0.02    -0.14    -0.05       1201
## last_born1                -0.17      0.08    -0.33    -0.01       3000
##                        Rhat
## Intercept              1.00
## paternalage            1.01
## birth_cohort1760M1765  1.00
## birth_cohort1765M1770  1.01
## birth_cohort1770M1775  1.01
## birth_cohort1775M1780  1.01
## birth_cohort1780M1785  1.01
## birth_cohort1785M1790  1.01
## birth_cohort1790M1795  1.01
## birth_cohort1795M1800  1.01
## birth_cohort1800M1805  1.01
## birth_cohort1805M1810  1.01
## birth_cohort1810M1815  1.01
## birth_cohort1815M1820  1.01
## birth_cohort1820M1825  1.01
## birth_cohort1825M1830  1.01
## birth_cohort1830M1835  1.01
## male1                  1.00
## maternalage.factor1420 1.00
## maternalage.factor3550 1.00
## paternalage.mean       1.01
## paternal_loss01        1.00
## paternal_loss15        1.00
## paternal_loss510       1.00
## paternal_loss1015      1.00
## paternal_loss1520      1.00
## paternal_loss2025      1.00
## paternal_loss2530      1.00
## paternal_loss3035      1.00
## paternal_loss3540      1.00
## paternal_loss4045      1.00
## maternal_loss01        1.00
## maternal_loss15        1.00
## maternal_loss510       1.00
## maternal_loss1015      1.00
## maternal_loss1520      1.00
## maternal_loss2025      1.00
## maternal_loss2530      1.00
## maternal_loss3035      1.00
## maternal_loss3540      1.00
## maternal_loss4045      1.00
## older_siblings1        1.00
## older_siblings2        1.00
## older_siblings3        1.01
## older_siblings4        1.00
## older_siblings5P       1.01
## nr.siblings            1.00
## last_born1             1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     2.79      0.02     2.75     2.84       3000 1.01
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 18.59 11.43 29.62
paternalage 0.8388 0.5955 1.199
birth_cohort1760M1765 1.08 0.7173 1.607
birth_cohort1765M1770 1.129 0.7775 1.63
birth_cohort1770M1775 0.9087 0.6347 1.292
birth_cohort1775M1780 1.225 0.8549 1.744
birth_cohort1780M1785 1.107 0.7594 1.601
birth_cohort1785M1790 1.352 0.9288 1.922
birth_cohort1790M1795 1.26 0.9078 1.752
birth_cohort1795M1800 1.37 0.991 1.89
birth_cohort1800M1805 1.482 1.075 2.035
birth_cohort1805M1810 1.088 0.7857 1.485
birth_cohort1810M1815 1.386 1.022 1.869
birth_cohort1815M1820 1.673 1.253 2.232
birth_cohort1820M1825 1.28 0.9561 1.738
birth_cohort1825M1830 1.263 0.941 1.691
birth_cohort1830M1835 1.328 0.9653 1.796
male1 0.8633 0.7691 0.966
maternalage.factor1420 0.7049 0.3897 1.257
maternalage.factor3550 0.8897 0.7432 1.072
paternalage.mean 1.089 0.7587 1.556
paternal_loss01 0.4417 0.286 0.6778
paternal_loss15 0.5614 0.4096 0.7693
paternal_loss510 0.702 0.5301 0.9383
paternal_loss1015 0.8223 0.6162 1.076
paternal_loss1520 0.734 0.5653 0.9422
paternal_loss2025 0.67 0.5223 0.8551
paternal_loss2530 0.9053 0.7135 1.15
paternal_loss3035 0.9356 0.7354 1.182
paternal_loss3540 0.9546 0.7529 1.202
paternal_loss4045 0.8226 0.6305 1.064
maternal_loss01 0.2539 0.1703 0.3723
maternal_loss15 0.5435 0.405 0.7333
maternal_loss510 0.6664 0.5047 0.877
maternal_loss1015 0.65 0.4986 0.837
maternal_loss1520 0.7176 0.5522 0.9414
maternal_loss2025 0.7773 0.5985 1.017
maternal_loss2530 0.7846 0.6154 0.9939
maternal_loss3035 0.7277 0.5818 0.9156
maternal_loss3540 0.874 0.7145 1.088
maternal_loss4045 0.7076 0.5638 0.8857
older_siblings1 1.064 0.8691 1.292
older_siblings2 1.104 0.8705 1.401
older_siblings3 1.091 0.8003 1.473
older_siblings4 1.087 0.7465 1.599
older_siblings5P 1.562 0.9287 2.566
nr.siblings 0.912 0.8715 0.9543
last_born1 0.8457 0.7169 0.9935

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.31 [2;2.63] [2.11;2.52]
estimate father 35y 2.13 [1.76;2.53] [1.89;2.39]
percentage change -7.69 [-21.51;8.34] [-17.23;2.43]
OR/IRR 0.84 [0.6;1.2] [0.66;1.05]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r19_normal_distribution.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r20: No adjustment for maternal age

In this model, we test what happens when we do not adjust for maternal age, because it is highly collinear with paternal age.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1000; warmup = 500; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.25       1295 1.00
## sd(hu_Intercept)     0.47      0.05     0.38     0.56        562 1.01
## 
## Population-Level Effects: 
##                          Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                    1.65      0.08     1.50     1.81       1198
## paternalage                  0.07      0.05    -0.03     0.16        859
## birth_cohort1760M1765        0.00      0.06    -0.13     0.12       1368
## birth_cohort1765M1770       -0.12      0.06    -0.23    -0.01        981
## birth_cohort1770M1775       -0.11      0.06    -0.23     0.00        889
## birth_cohort1775M1780       -0.03      0.06    -0.13     0.08        774
## birth_cohort1780M1785       -0.11      0.06    -0.22     0.00        903
## birth_cohort1785M1790       -0.10      0.06    -0.20     0.01        830
## birth_cohort1790M1795       -0.08      0.05    -0.18     0.03        783
## birth_cohort1795M1800       -0.11      0.05    -0.20    -0.01        755
## birth_cohort1800M1805       -0.11      0.05    -0.21    -0.02        630
## birth_cohort1805M1810       -0.14      0.05    -0.23    -0.04        665
## birth_cohort1810M1815       -0.10      0.05    -0.19     0.00        648
## birth_cohort1815M1820       -0.14      0.05    -0.23    -0.05        635
## birth_cohort1820M1825       -0.18      0.05    -0.27    -0.09        636
## birth_cohort1825M1830       -0.21      0.05    -0.30    -0.12        613
## birth_cohort1830M1835       -0.18      0.05    -0.27    -0.09        661
## male1                        0.08      0.02     0.05     0.11       3000
## paternalage.mean            -0.07      0.05    -0.17     0.03        915
## paternal_loss01             -0.15      0.07    -0.30    -0.01       3000
## paternal_loss15             -0.04      0.05    -0.14     0.06       2118
## paternal_loss510            -0.07      0.04    -0.16     0.01       1480
## paternal_loss1015            0.01      0.04    -0.07     0.08       1293
## paternal_loss1520           -0.09      0.04    -0.17    -0.02       1290
## paternal_loss2025           -0.12      0.04    -0.19    -0.05       1458
## paternal_loss2530           -0.01      0.03    -0.08     0.06       1174
## paternal_loss3035           -0.03      0.03    -0.09     0.04       1156
## paternal_loss3540           -0.01      0.03    -0.07     0.05       1268
## paternal_loss4045           -0.01      0.04    -0.09     0.06       1960
## maternal_loss01              0.10      0.08    -0.06     0.25       3000
## maternal_loss15             -0.02      0.05    -0.11     0.07       3000
## maternal_loss510             0.07      0.04    -0.01     0.15       3000
## maternal_loss1015            0.03      0.04    -0.06     0.10       3000
## maternal_loss1520            0.00      0.04    -0.08     0.08       3000
## maternal_loss2025            0.00      0.04    -0.07     0.08       3000
## maternal_loss2530           -0.02      0.03    -0.09     0.05       3000
## maternal_loss3035           -0.05      0.03    -0.12     0.01       3000
## maternal_loss3540           -0.03      0.03    -0.09     0.02       3000
## maternal_loss4045           -0.03      0.03    -0.09     0.03       3000
## older_siblings1              0.03      0.03    -0.02     0.08       1541
## older_siblings2             -0.05      0.03    -0.11     0.02       1001
## older_siblings3             -0.07      0.05    -0.16     0.02        957
## older_siblings4             -0.09      0.06    -0.20     0.02        914
## older_siblings5P            -0.09      0.08    -0.25     0.06        830
## nr.siblings                  0.01      0.01     0.00     0.02       1134
## last_born1                  -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                -0.31      0.20    -0.69     0.07       1419
## hu_paternalage               0.36      0.14     0.10     0.62        860
## hu_birth_cohort1760M1765    -0.05      0.17    -0.38     0.28       3000
## hu_birth_cohort1765M1770    -0.32      0.15    -0.60    -0.03       1015
## hu_birth_cohort1770M1775    -0.07      0.14    -0.36     0.21       1055
## hu_birth_cohort1775M1780    -0.20      0.14    -0.47     0.07       1112
## hu_birth_cohort1780M1785    -0.27      0.14    -0.55     0.02       1390
## hu_birth_cohort1785M1790    -0.41      0.14    -0.68    -0.14       1430
## hu_birth_cohort1790M1795    -0.31      0.13    -0.56    -0.05       1360
## hu_birth_cohort1795M1800    -0.46      0.12    -0.71    -0.22       1133
## hu_birth_cohort1800M1805    -0.53      0.12    -0.76    -0.30       1208
## hu_birth_cohort1805M1810    -0.26      0.12    -0.50    -0.02       1109
## hu_birth_cohort1810M1815    -0.43      0.12    -0.66    -0.20       1003
## hu_birth_cohort1815M1820    -0.70      0.11    -0.92    -0.48        613
## hu_birth_cohort1820M1825    -0.53      0.11    -0.75    -0.30       1011
## hu_birth_cohort1825M1830    -0.54      0.11    -0.77    -0.32        712
## hu_birth_cohort1830M1835    -0.55      0.12    -0.78    -0.31        670
## hu_male1                     0.27      0.05     0.19     0.37       3000
## hu_paternalage.mean         -0.27      0.14    -0.54     0.00        846
## hu_paternal_loss01           0.55      0.18     0.21     0.91       3000
## hu_paternal_loss15           0.51      0.13     0.26     0.76       3000
## hu_paternal_loss510          0.17      0.11    -0.05     0.39       2029
## hu_paternal_loss1015         0.15      0.11    -0.06     0.35       1820
## hu_paternal_loss1520         0.09      0.10    -0.10     0.28       1654
## hu_paternal_loss2025         0.15      0.10    -0.04     0.34       1681
## hu_paternal_loss2530         0.06      0.09    -0.12     0.24       1736
## hu_paternal_loss3035        -0.03      0.09    -0.21     0.15       1662
## hu_paternal_loss3540        -0.02      0.09    -0.20     0.16       1668
## hu_paternal_loss4045         0.14      0.10    -0.06     0.34       3000
## hu_maternal_loss01           1.56      0.19     1.20     1.93       3000
## hu_maternal_loss15           0.57      0.12     0.34     0.80       3000
## hu_maternal_loss510          0.48      0.10     0.27     0.69       3000
## hu_maternal_loss1015         0.47      0.10     0.27     0.68       3000
## hu_maternal_loss1520         0.32      0.11     0.12     0.53       3000
## hu_maternal_loss2025         0.27      0.10     0.06     0.46       3000
## hu_maternal_loss2530         0.20      0.09     0.02     0.38       3000
## hu_maternal_loss3035         0.22      0.09     0.06     0.39       3000
## hu_maternal_loss3540         0.07      0.08    -0.09     0.24       3000
## hu_maternal_loss4045         0.28      0.08     0.12     0.44       3000
## hu_older_siblings1          -0.03      0.07    -0.18     0.11       3000
## hu_older_siblings2          -0.19      0.10    -0.38     0.00       1066
## hu_older_siblings3          -0.23      0.12    -0.47     0.01        962
## hu_older_siblings4          -0.26      0.16    -0.58     0.04        892
## hu_older_siblings5P         -0.60      0.21    -1.02    -0.19        864
## hu_nr.siblings               0.11      0.02     0.07     0.14       1113
## hu_last_born1                0.09      0.06    -0.03     0.21       3000
##                          Rhat
## Intercept                1.00
## paternalage              1.00
## birth_cohort1760M1765    1.00
## birth_cohort1765M1770    1.01
## birth_cohort1770M1775    1.01
## birth_cohort1775M1780    1.01
## birth_cohort1780M1785    1.01
## birth_cohort1785M1790    1.01
## birth_cohort1790M1795    1.01
## birth_cohort1795M1800    1.01
## birth_cohort1800M1805    1.01
## birth_cohort1805M1810    1.01
## birth_cohort1810M1815    1.01
## birth_cohort1815M1820    1.01
## birth_cohort1820M1825    1.01
## birth_cohort1825M1830    1.01
## birth_cohort1830M1835    1.01
## male1                    1.00
## paternalage.mean         1.00
## paternal_loss01          1.00
## paternal_loss15          1.00
## paternal_loss510         1.00
## paternal_loss1015        1.00
## paternal_loss1520        1.00
## paternal_loss2025        1.00
## paternal_loss2530        1.00
## paternal_loss3035        1.00
## paternal_loss3540        1.00
## paternal_loss4045        1.00
## maternal_loss01          1.00
## maternal_loss15          1.00
## maternal_loss510         1.00
## maternal_loss1015        1.00
## maternal_loss1520        1.00
## maternal_loss2025        1.00
## maternal_loss2530        1.00
## maternal_loss3035        1.00
## maternal_loss3540        1.00
## maternal_loss4045        1.00
## older_siblings1          1.00
## older_siblings2          1.00
## older_siblings3          1.00
## older_siblings4          1.00
## older_siblings5P         1.00
## nr.siblings              1.00
## last_born1               1.00
## hu_Intercept             1.00
## hu_paternalage           1.00
## hu_birth_cohort1760M1765 1.00
## hu_birth_cohort1765M1770 1.00
## hu_birth_cohort1770M1775 1.00
## hu_birth_cohort1775M1780 1.00
## hu_birth_cohort1780M1785 1.00
## hu_birth_cohort1785M1790 1.00
## hu_birth_cohort1790M1795 1.00
## hu_birth_cohort1795M1800 1.00
## hu_birth_cohort1800M1805 1.00
## hu_birth_cohort1805M1810 1.00
## hu_birth_cohort1810M1815 1.00
## hu_birth_cohort1815M1820 1.01
## hu_birth_cohort1820M1825 1.01
## hu_birth_cohort1825M1830 1.00
## hu_birth_cohort1830M1835 1.01
## hu_male1                 1.00
## hu_paternalage.mean      1.00
## hu_paternal_loss01       1.00
## hu_paternal_loss15       1.00
## hu_paternal_loss510      1.00
## hu_paternal_loss1015     1.00
## hu_paternal_loss1520     1.00
## hu_paternal_loss2025     1.00
## hu_paternal_loss2530     1.00
## hu_paternal_loss3035     1.00
## hu_paternal_loss3540     1.00
## hu_paternal_loss4045     1.00
## hu_maternal_loss01       1.00
## hu_maternal_loss15       1.00
## hu_maternal_loss510      1.00
## hu_maternal_loss1015     1.00
## hu_maternal_loss1520     1.00
## hu_maternal_loss2025     1.00
## hu_maternal_loss2530     1.00
## hu_maternal_loss3035     1.00
## hu_maternal_loss3540     1.00
## hu_maternal_loss4045     1.00
## hu_older_siblings1       1.00
## hu_older_siblings2       1.00
## hu_older_siblings3       1.00
## hu_older_siblings4       1.00
## hu_older_siblings5P      1.00
## hu_nr.siblings           1.00
## hu_last_born1            1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.23 4.491 6.111
paternalage 1.068 0.9739 1.179
birth_cohort1760M1765 0.9974 0.8797 1.132
birth_cohort1765M1770 0.8877 0.7946 0.9932
birth_cohort1770M1775 0.8916 0.7934 1.001
birth_cohort1775M1780 0.9742 0.8759 1.087
birth_cohort1780M1785 0.8955 0.7999 1.002
birth_cohort1785M1790 0.9076 0.8149 1.012
birth_cohort1790M1795 0.9272 0.838 1.031
birth_cohort1795M1800 0.8993 0.8147 0.9909
birth_cohort1800M1805 0.8928 0.8145 0.9786
birth_cohort1805M1810 0.8723 0.793 0.9618
birth_cohort1810M1815 0.9071 0.8307 0.9961
birth_cohort1815M1820 0.8674 0.7975 0.9497
birth_cohort1820M1825 0.8312 0.7612 0.9113
birth_cohort1825M1830 0.8109 0.7419 0.8868
birth_cohort1830M1835 0.8343 0.7631 0.9143
male1 1.081 1.046 1.117
paternalage.mean 0.9338 0.8421 1.032
paternal_loss01 0.8578 0.7411 0.9874
paternal_loss15 0.9625 0.8685 1.061
paternal_loss510 0.9328 0.8562 1.014
paternal_loss1015 1.006 0.9294 1.089
paternal_loss1520 0.9096 0.8424 0.9831
paternal_loss2025 0.8861 0.8244 0.9529
paternal_loss2530 0.9901 0.9251 1.06
paternal_loss3035 0.9716 0.9102 1.04
paternal_loss3540 0.9902 0.9296 1.055
paternal_loss4045 0.9894 0.9181 1.063
maternal_loss01 1.105 0.9416 1.29
maternal_loss15 0.9801 0.8922 1.072
maternal_loss510 1.072 0.9919 1.162
maternal_loss1015 1.026 0.9459 1.108
maternal_loss1520 1.001 0.9211 1.087
maternal_loss2025 1.003 0.9308 1.082
maternal_loss2530 0.9772 0.9139 1.046
maternal_loss3035 0.95 0.8898 1.013
maternal_loss3540 0.966 0.913 1.023
maternal_loss4045 0.9707 0.9101 1.031
older_siblings1 1.028 0.9766 1.081
older_siblings2 0.9553 0.8941 1.022
older_siblings3 0.9303 0.8508 1.017
older_siblings4 0.9129 0.8158 1.022
older_siblings5P 0.9095 0.7816 1.058
nr.siblings 1.01 0.9959 1.024
last_born1 0.9572 0.916 1
hu_Intercept 0.736 0.5014 1.076
hu_paternalage 1.428 1.1 1.866
hu_birth_cohort1760M1765 0.9495 0.6866 1.327
hu_birth_cohort1765M1770 0.7294 0.5508 0.9695
hu_birth_cohort1770M1775 0.9345 0.6966 1.231
hu_birth_cohort1775M1780 0.819 0.6224 1.071
hu_birth_cohort1780M1785 0.7636 0.5748 1.025
hu_birth_cohort1785M1790 0.6631 0.5054 0.8691
hu_birth_cohort1790M1795 0.735 0.5693 0.9513
hu_birth_cohort1795M1800 0.6342 0.494 0.8038
hu_birth_cohort1800M1805 0.5878 0.4668 0.7387
hu_birth_cohort1805M1810 0.7686 0.6069 0.9775
hu_birth_cohort1810M1815 0.6489 0.5151 0.8171
hu_birth_cohort1815M1820 0.4973 0.3977 0.62
hu_birth_cohort1820M1825 0.5911 0.4703 0.7394
hu_birth_cohort1825M1830 0.5802 0.4651 0.7246
hu_birth_cohort1830M1835 0.5774 0.4574 0.73
hu_male1 1.315 1.205 1.442
hu_paternalage.mean 0.7659 0.5808 1.005
hu_paternal_loss01 1.737 1.228 2.478
hu_paternal_loss15 1.668 1.292 2.137
hu_paternal_loss510 1.191 0.9544 1.474
hu_paternal_loss1015 1.16 0.9446 1.426
hu_paternal_loss1520 1.098 0.9019 1.329
hu_paternal_loss2025 1.161 0.9616 1.399
hu_paternal_loss2530 1.058 0.8845 1.273
hu_paternal_loss3035 0.9725 0.8101 1.16
hu_paternal_loss3540 0.9817 0.8179 1.174
hu_paternal_loss4045 1.147 0.9414 1.402
hu_maternal_loss01 4.776 3.316 6.906
hu_maternal_loss15 1.771 1.402 2.228
hu_maternal_loss510 1.616 1.311 1.985
hu_maternal_loss1015 1.606 1.316 1.969
hu_maternal_loss1520 1.375 1.124 1.697
hu_maternal_loss2025 1.305 1.064 1.584
hu_maternal_loss2530 1.222 1.02 1.466
hu_maternal_loss3035 1.251 1.063 1.479
hu_maternal_loss3540 1.076 0.9168 1.267
hu_maternal_loss4045 1.322 1.126 1.552
hu_older_siblings1 0.9677 0.8332 1.112
hu_older_siblings2 0.8249 0.6815 1.001
hu_older_siblings3 0.7932 0.6241 1.011
hu_older_siblings4 0.7675 0.5589 1.043
hu_older_siblings5P 0.5469 0.3605 0.8273
hu_nr.siblings 1.113 1.074 1.155
hu_last_born1 1.096 0.9714 1.236

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.32 [1.96;2.69] [2.08;2.56]
estimate father 35y 2 [1.59;2.48] [1.72;2.29]
percentage change -13.61 [-29.41;3.73] [-23.95;-2.63]
OR/IRR 1.07 [0.97;1.18] [1;1.14]
OR hurdle 1.43 [1.1;1.87] [1.2;1.7]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r20_no_maternalage_control.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r21: Continuous adjustment for maternal age

In this model, we adjust for maternal age using a continuous variable instead of three bins. This does not allow for nonlinear effects, but also does not aggregate the predictor. We cannot compare full siblings, test the effects of maternal and paternal age and adjust for average maternal and paternal age in the family (because the predictors are redundant), so that it is not perfectly possible to disentangle the contribution of maternal and paternal age and compare full siblings.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + maternalage + birth_cohort + male + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + maternalage + birth_cohort + male + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1000; warmup = 500; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25        976    1
## sd(hu_Intercept)     0.48      0.05     0.38     0.57        749    1
## 
## Population-Level Effects: 
##                          Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                    1.67      0.11     1.44     1.89       1119
## paternalage                  0.07      0.06    -0.04     0.18        667
## maternalage                 -0.01      0.03    -0.06     0.05       1711
## birth_cohort1760M1765        0.00      0.06    -0.13     0.12       1096
## birth_cohort1765M1770       -0.12      0.06    -0.23    -0.01        780
## birth_cohort1770M1775       -0.11      0.06    -0.23     0.00        858
## birth_cohort1775M1780       -0.03      0.05    -0.13     0.08        735
## birth_cohort1780M1785       -0.11      0.06    -0.22     0.01        842
## birth_cohort1785M1790       -0.10      0.05    -0.20     0.01        737
## birth_cohort1790M1795       -0.07      0.05    -0.17     0.03        718
## birth_cohort1795M1800       -0.11      0.05    -0.20    -0.01        616
## birth_cohort1800M1805       -0.11      0.05    -0.21    -0.02        555
## birth_cohort1805M1810       -0.14      0.05    -0.23    -0.04        602
## birth_cohort1810M1815       -0.10      0.05    -0.19    -0.01        582
## birth_cohort1815M1820       -0.14      0.05    -0.23    -0.05        562
## birth_cohort1820M1825       -0.18      0.04    -0.27    -0.10        575
## birth_cohort1825M1830       -0.21      0.05    -0.30    -0.12        582
## birth_cohort1830M1835       -0.18      0.05    -0.27    -0.09        604
## male1                        0.08      0.02     0.05     0.11       3000
## paternalage.mean            -0.07      0.06    -0.19     0.03        723
## paternal_loss01             -0.16      0.08    -0.31    -0.02       3000
## paternal_loss15             -0.04      0.05    -0.15     0.06       1636
## paternal_loss510            -0.07      0.04    -0.15     0.01       1419
## paternal_loss1015            0.00      0.04    -0.07     0.08       1334
## paternal_loss1520           -0.10      0.04    -0.17    -0.02       1530
## paternal_loss2025           -0.12      0.04    -0.19    -0.05       1406
## paternal_loss2530           -0.01      0.03    -0.08     0.05       1376
## paternal_loss3035           -0.03      0.03    -0.10     0.04       1338
## paternal_loss3540           -0.01      0.03    -0.07     0.06       1468
## paternal_loss4045           -0.01      0.04    -0.08     0.06       2012
## maternal_loss01              0.10      0.08    -0.06     0.25       3000
## maternal_loss15             -0.02      0.05    -0.11     0.07       1800
## maternal_loss510             0.07      0.04    -0.01     0.15       1570
## maternal_loss1015            0.03      0.04    -0.06     0.11       1682
## maternal_loss1520            0.00      0.04    -0.08     0.08       1545
## maternal_loss2025            0.00      0.04    -0.07     0.08       1618
## maternal_loss2530           -0.02      0.04    -0.09     0.05       1565
## maternal_loss3035           -0.05      0.03    -0.12     0.02       1484
## maternal_loss3540           -0.03      0.03    -0.09     0.03       1588
## maternal_loss4045           -0.03      0.03    -0.09     0.03       3000
## older_siblings1              0.03      0.03    -0.03     0.08       1427
## older_siblings2             -0.05      0.04    -0.12     0.02        913
## older_siblings3             -0.07      0.05    -0.16     0.02        656
## older_siblings4             -0.09      0.06    -0.21     0.02        697
## older_siblings5P            -0.09      0.08    -0.25     0.05        582
## nr.siblings                  0.01      0.01     0.00     0.02        938
## last_born1                  -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                -0.43      0.28    -0.97     0.14       1034
## hu_paternalage               0.31      0.15     0.02     0.63        705
## hu_maternalage               0.04      0.07    -0.10     0.18       1673
## hu_birth_cohort1760M1765    -0.06      0.17    -0.38     0.27       3000
## hu_birth_cohort1765M1770    -0.32      0.15    -0.61    -0.03        893
## hu_birth_cohort1770M1775    -0.07      0.14    -0.36     0.21        865
## hu_birth_cohort1775M1780    -0.20      0.14    -0.48     0.07        876
## hu_birth_cohort1780M1785    -0.28      0.15    -0.57     0.01        860
## hu_birth_cohort1785M1790    -0.42      0.14    -0.70    -0.13        843
## hu_birth_cohort1790M1795    -0.32      0.13    -0.58    -0.06        744
## hu_birth_cohort1795M1800    -0.46      0.13    -0.72    -0.21        702
## hu_birth_cohort1800M1805    -0.54      0.13    -0.79    -0.29        689
## hu_birth_cohort1805M1810    -0.27      0.13    -0.51    -0.01        676
## hu_birth_cohort1810M1815    -0.44      0.12    -0.68    -0.19        672
## hu_birth_cohort1815M1820    -0.70      0.12    -0.92    -0.47        599
## hu_birth_cohort1820M1825    -0.53      0.12    -0.76    -0.30        590
## hu_birth_cohort1825M1830    -0.55      0.12    -0.79    -0.32        597
## hu_birth_cohort1830M1835    -0.56      0.12    -0.80    -0.33        650
## hu_male1                     0.27      0.05     0.18     0.36       3000
## hu_paternalage.mean         -0.23      0.15    -0.54     0.06        708
## hu_paternal_loss01           0.57      0.18     0.21     0.94       3000
## hu_paternal_loss15           0.52      0.13     0.27     0.78       1348
## hu_paternal_loss510          0.19      0.11    -0.03     0.41       1107
## hu_paternal_loss1015         0.16      0.10    -0.05     0.37       1232
## hu_paternal_loss1520         0.10      0.10    -0.10     0.30       1142
## hu_paternal_loss2025         0.15      0.10    -0.04     0.35       1051
## hu_paternal_loss2530         0.06      0.09    -0.11     0.25       1167
## hu_paternal_loss3035        -0.02      0.09    -0.20     0.15       1391
## hu_paternal_loss3540        -0.01      0.09    -0.19     0.15       1517
## hu_paternal_loss4045         0.14      0.10    -0.05     0.34       1823
## hu_maternal_loss01           1.58      0.19     1.21     1.96       3000
## hu_maternal_loss15           0.58      0.12     0.35     0.82       3000
## hu_maternal_loss510          0.48      0.11     0.27     0.70       3000
## hu_maternal_loss1015         0.48      0.11     0.26     0.70       3000
## hu_maternal_loss1520         0.32      0.11     0.12     0.54       2153
## hu_maternal_loss2025         0.27      0.10     0.07     0.47       1977
## hu_maternal_loss2530         0.20      0.09     0.02     0.38       1866
## hu_maternal_loss3035         0.22      0.09     0.05     0.40       1774
## hu_maternal_loss3540         0.07      0.08    -0.09     0.23       1847
## hu_maternal_loss4045         0.28      0.09     0.11     0.44       1970
## hu_older_siblings1          -0.04      0.07    -0.18     0.11       1321
## hu_older_siblings2          -0.19      0.10    -0.38    -0.01        916
## hu_older_siblings3          -0.24      0.13    -0.48     0.01        788
## hu_older_siblings4          -0.27      0.16    -0.58     0.03        704
## hu_older_siblings5P         -0.61      0.21    -1.02    -0.21        670
## hu_nr.siblings               0.11      0.02     0.07     0.14        845
## hu_last_born1                0.09      0.06    -0.03     0.21       3000
##                          Rhat
## Intercept                1.00
## paternalage              1.01
## maternalage              1.00
## birth_cohort1760M1765    1.00
## birth_cohort1765M1770    1.01
## birth_cohort1770M1775    1.01
## birth_cohort1775M1780    1.01
## birth_cohort1780M1785    1.01
## birth_cohort1785M1790    1.01
## birth_cohort1790M1795    1.01
## birth_cohort1795M1800    1.01
## birth_cohort1800M1805    1.01
## birth_cohort1805M1810    1.01
## birth_cohort1810M1815    1.01
## birth_cohort1815M1820    1.01
## birth_cohort1820M1825    1.01
## birth_cohort1825M1830    1.01
## birth_cohort1830M1835    1.01
## male1                    1.00
## paternalage.mean         1.01
## paternal_loss01          1.00
## paternal_loss15          1.00
## paternal_loss510         1.00
## paternal_loss1015        1.00
## paternal_loss1520        1.00
## paternal_loss2025        1.00
## paternal_loss2530        1.00
## paternal_loss3035        1.00
## paternal_loss3540        1.00
## paternal_loss4045        1.00
## maternal_loss01          1.00
## maternal_loss15          1.00
## maternal_loss510         1.00
## maternal_loss1015        1.00
## maternal_loss1520        1.00
## maternal_loss2025        1.00
## maternal_loss2530        1.00
## maternal_loss3035        1.00
## maternal_loss3540        1.00
## maternal_loss4045        1.00
## older_siblings1          1.00
## older_siblings2          1.01
## older_siblings3          1.01
## older_siblings4          1.01
## older_siblings5P         1.01
## nr.siblings              1.01
## last_born1               1.00
## hu_Intercept             1.00
## hu_paternalage           1.01
## hu_maternalage           1.00
## hu_birth_cohort1760M1765 1.00
## hu_birth_cohort1765M1770 1.00
## hu_birth_cohort1770M1775 1.00
## hu_birth_cohort1775M1780 1.00
## hu_birth_cohort1780M1785 1.00
## hu_birth_cohort1785M1790 1.00
## hu_birth_cohort1790M1795 1.01
## hu_birth_cohort1795M1800 1.01
## hu_birth_cohort1800M1805 1.01
## hu_birth_cohort1805M1810 1.01
## hu_birth_cohort1810M1815 1.01
## hu_birth_cohort1815M1820 1.01
## hu_birth_cohort1820M1825 1.01
## hu_birth_cohort1825M1830 1.01
## hu_birth_cohort1830M1835 1.01
## hu_male1                 1.00
## hu_paternalage.mean      1.01
## hu_paternal_loss01       1.00
## hu_paternal_loss15       1.00
## hu_paternal_loss510      1.01
## hu_paternal_loss1015     1.01
## hu_paternal_loss1520     1.01
## hu_paternal_loss2025     1.01
## hu_paternal_loss2530     1.00
## hu_paternal_loss3035     1.00
## hu_paternal_loss3540     1.01
## hu_paternal_loss4045     1.00
## hu_maternal_loss01       1.00
## hu_maternal_loss15       1.00
## hu_maternal_loss510      1.01
## hu_maternal_loss1015     1.00
## hu_maternal_loss1520     1.00
## hu_maternal_loss2025     1.00
## hu_maternal_loss2530     1.00
## hu_maternal_loss3035     1.00
## hu_maternal_loss3540     1.00
## hu_maternal_loss4045     1.00
## hu_older_siblings1       1.00
## hu_older_siblings2       1.01
## hu_older_siblings3       1.01
## hu_older_siblings4       1.01
## hu_older_siblings5P      1.01
## hu_nr.siblings           1.01
## hu_last_born1            1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.311 4.219 6.591
paternalage 1.074 0.9654 1.203
maternalage 0.9941 0.9373 1.055
birth_cohort1760M1765 0.9977 0.8795 1.126
birth_cohort1765M1770 0.8889 0.7947 0.9942
birth_cohort1770M1775 0.8915 0.7963 0.9962
birth_cohort1775M1780 0.9748 0.8754 1.084
birth_cohort1780M1785 0.8983 0.8049 1.005
birth_cohort1785M1790 0.9093 0.8194 1.013
birth_cohort1790M1795 0.9292 0.8418 1.03
birth_cohort1795M1800 0.9002 0.8208 0.992
birth_cohort1800M1805 0.894 0.8136 0.9823
birth_cohort1805M1810 0.8732 0.793 0.9597
birth_cohort1810M1815 0.9076 0.8283 0.9947
birth_cohort1815M1820 0.8684 0.7953 0.9492
birth_cohort1820M1825 0.8313 0.7616 0.9059
birth_cohort1825M1830 0.8114 0.7432 0.8859
birth_cohort1830M1835 0.8336 0.7641 0.9169
male1 1.081 1.046 1.116
paternalage.mean 0.9291 0.8276 1.034
paternal_loss01 0.8533 0.7335 0.9834
paternal_loss15 0.9606 0.8642 1.06
paternal_loss510 0.932 0.8569 1.015
paternal_loss1015 1.005 0.9304 1.086
paternal_loss1520 0.9087 0.8425 0.9798
paternal_loss2025 0.8855 0.8249 0.954
paternal_loss2530 0.9897 0.9223 1.055
paternal_loss3035 0.9708 0.9089 1.036
paternal_loss3540 0.9904 0.9298 1.057
paternal_loss4045 0.9896 0.9216 1.063
maternal_loss01 1.103 0.9402 1.287
maternal_loss15 0.9802 0.8951 1.076
maternal_loss510 1.071 0.9901 1.161
maternal_loss1015 1.027 0.9436 1.113
maternal_loss1520 1.002 0.9239 1.085
maternal_loss2025 1.004 0.9308 1.085
maternal_loss2530 0.9785 0.9145 1.046
maternal_loss3035 0.9503 0.8905 1.016
maternal_loss3540 0.9671 0.9097 1.026
maternal_loss4045 0.9712 0.9109 1.033
older_siblings1 1.028 0.9732 1.082
older_siblings2 0.9554 0.8911 1.024
older_siblings3 0.9314 0.8504 1.021
older_siblings4 0.913 0.8125 1.019
older_siblings5P 0.911 0.7827 1.056
nr.siblings 1.01 0.9957 1.024
last_born1 0.9566 0.9151 1
hu_Intercept 0.6529 0.3794 1.147
hu_paternalage 1.364 1.023 1.87
hu_maternalage 1.046 0.9068 1.196
hu_birth_cohort1760M1765 0.9464 0.6864 1.308
hu_birth_cohort1765M1770 0.7254 0.5425 0.9724
hu_birth_cohort1770M1775 0.9284 0.6977 1.235
hu_birth_cohort1775M1780 0.8156 0.6178 1.074
hu_birth_cohort1780M1785 0.7562 0.5636 1.014
hu_birth_cohort1785M1790 0.6573 0.4952 0.8753
hu_birth_cohort1790M1795 0.7293 0.5598 0.9426
hu_birth_cohort1795M1800 0.629 0.4858 0.8067
hu_birth_cohort1800M1805 0.5816 0.4525 0.7463
hu_birth_cohort1805M1810 0.7645 0.6003 0.9866
hu_birth_cohort1810M1815 0.6467 0.5066 0.8239
hu_birth_cohort1815M1820 0.4954 0.3978 0.6237
hu_birth_cohort1820M1825 0.5895 0.4694 0.7419
hu_birth_cohort1825M1830 0.5757 0.4548 0.7294
hu_birth_cohort1830M1835 0.5726 0.4497 0.7219
hu_male1 1.314 1.199 1.436
hu_paternalage.mean 0.7972 0.5818 1.063
hu_paternal_loss01 1.764 1.235 2.551
hu_paternal_loss15 1.689 1.31 2.182
hu_paternal_loss510 1.207 0.9706 1.508
hu_paternal_loss1015 1.169 0.9549 1.444
hu_paternal_loss1520 1.106 0.9074 1.347
hu_paternal_loss2025 1.167 0.9611 1.413
hu_paternal_loss2530 1.067 0.8936 1.281
hu_paternal_loss3035 0.9755 0.8161 1.165
hu_paternal_loss3540 0.9855 0.8297 1.167
hu_paternal_loss4045 1.152 0.9504 1.409
hu_maternal_loss01 4.85 3.365 7.131
hu_maternal_loss15 1.785 1.415 2.266
hu_maternal_loss510 1.623 1.304 2.015
hu_maternal_loss1015 1.612 1.303 2.009
hu_maternal_loss1520 1.372 1.123 1.713
hu_maternal_loss2025 1.304 1.069 1.595
hu_maternal_loss2530 1.219 1.017 1.467
hu_maternal_loss3035 1.248 1.055 1.486
hu_maternal_loss3540 1.073 0.9106 1.263
hu_maternal_loss4045 1.32 1.113 1.558
hu_older_siblings1 0.9656 0.8392 1.114
hu_older_siblings2 0.8242 0.6808 0.9935
hu_older_siblings3 0.7896 0.6167 1.005
hu_older_siblings4 0.7642 0.5622 1.03
hu_older_siblings5P 0.5443 0.3603 0.8102
hu_nr.siblings 1.113 1.074 1.154
hu_last_born1 1.096 0.9703 1.24

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.24 [1.86;2.7] [1.98;2.53]
estimate father 35y 1.99 [1.6;2.48] [1.73;2.31]
percentage change -10.86 [-28.22;8.72] [-22.22;1.83]
OR/IRR 1.07 [0.97;1.2] [1;1.16]
OR hurdle 1.36 [1.02;1.87] [1.13;1.66]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r21_continuous_maternalage.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r22: Relaxed exclusion and censoring criteria

Like r1, but we use a 30-years-later cutoff year for our birth cohorts, relaxing our censoring requirements.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 21147) 
## Samples: 6 chains, each with iter = 2000; warmup = 300; thin = 1; 
##          total post-warmup samples = 10200
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 5218) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.26      0.01     0.23     0.28       3594    1
## sd(hu_Intercept)     0.64      0.03     0.58     0.71       2700    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.90      0.30     1.32     2.49        433
## paternalage                   0.05      0.04    -0.03     0.14       2701
## birth_cohort1670M1700         0.04      0.33    -0.60     0.68        500
## birth_cohort1700M1720        -0.02      0.31    -0.63     0.59        458
## birth_cohort1720M1760        -0.14      0.30    -0.72     0.43        422
## birth_cohort1760M1765        -0.10      0.30    -0.68     0.49        429
## birth_cohort1765M1770        -0.24      0.30    -0.82     0.33        424
## birth_cohort1770M1775        -0.25      0.30    -0.82     0.33        424
## birth_cohort1775M1780        -0.17      0.30    -0.74     0.40        427
## birth_cohort1780M1785        -0.25      0.30    -0.82     0.33        427
## birth_cohort1785M1790        -0.21      0.30    -0.79     0.37        425
## birth_cohort1790M1795        -0.18      0.30    -0.76     0.39        422
## birth_cohort1795M1800        -0.24      0.30    -0.81     0.34        424
## birth_cohort1800M1805        -0.24      0.30    -0.81     0.33        422
## birth_cohort1805M1810        -0.25      0.30    -0.82     0.33        421
## birth_cohort1810M1815        -0.22      0.30    -0.80     0.35        421
## birth_cohort1815M1820        -0.29      0.30    -0.87     0.28        424
## birth_cohort1820M1825        -0.34      0.30    -0.92     0.24        421
## birth_cohort1825M1830        -0.33      0.30    -0.91     0.24        422
## birth_cohort1830M1835        -0.33      0.30    -0.91     0.24        422
## birth_cohort1835M1840        -0.48      0.30    -1.05     0.09        423
## birth_cohort1840M1845        -0.63      0.30    -1.20    -0.05        423
## birth_cohort1845M1850        -0.97      0.30    -1.54    -0.38        428
## birth_cohort1850M1855        -0.63      0.30    -1.22    -0.04        430
## birth_cohort1855M1860        -0.26      0.30    -0.84     0.33        436
## birth_cohort1860M1865        -0.10      0.30    -0.69     0.48        430
## male1                         0.08      0.01     0.05     0.11      10200
## maternalage.factor1420       -0.06      0.07    -0.21     0.07      10200
## maternalage.factor3550       -0.01      0.02    -0.06     0.03      10200
## paternalage.mean             -0.07      0.05    -0.16     0.01       2718
## paternal_loss01              -0.16      0.07    -0.29    -0.02      10200
## paternal_loss15              -0.07      0.04    -0.15     0.02       4959
## paternal_loss510             -0.07      0.04    -0.15     0.00       4482
## paternal_loss1015             0.00      0.03    -0.07     0.07       4025
## paternal_loss1520            -0.10      0.03    -0.17    -0.04       3912
## paternal_loss2025            -0.12      0.03    -0.18    -0.06       3822
## paternal_loss2530            -0.03      0.03    -0.09     0.03       3697
## paternal_loss3035            -0.04      0.03    -0.10     0.02       3781
## paternal_loss3540             0.00      0.03    -0.06     0.05       4130
## paternal_loss4045            -0.01      0.03    -0.07     0.05       5370
## paternal_lossunclear         -0.10      0.04    -0.17    -0.03       4179
## maternal_loss01               0.09      0.07    -0.04     0.22      10200
## maternal_loss15              -0.05      0.04    -0.14     0.03       5860
## maternal_loss510              0.02      0.04    -0.05     0.09       5452
## maternal_loss1015            -0.04      0.04    -0.11     0.03       5615
## maternal_loss1520            -0.02      0.03    -0.09     0.05       6052
## maternal_loss2025            -0.02      0.03    -0.09     0.04       5663
## maternal_loss2530            -0.07      0.03    -0.13    -0.01       5127
## maternal_loss3035            -0.04      0.03    -0.10     0.01       4720
## maternal_loss3540            -0.04      0.03    -0.09     0.01       4981
## maternal_loss4045            -0.02      0.03    -0.07     0.04       6097
## maternal_lossunclear         -0.13      0.04    -0.20    -0.06       5711
## older_siblings1               0.00      0.02    -0.04     0.05       4953
## older_siblings2              -0.06      0.03    -0.12     0.00       3296
## older_siblings3              -0.08      0.04    -0.16     0.00       2852
## older_siblings4              -0.06      0.05    -0.16     0.03       2948
## older_siblings5P             -0.07      0.06    -0.19     0.06       2779
## nr.siblings                   0.00      0.01    -0.01     0.01       3260
## last_born1                   -0.01      0.02    -0.05     0.02      10200
## hu_Intercept                 -0.98      0.71    -2.33     0.44        157
## hu_paternalage                0.29      0.11     0.08     0.51       2171
## hu_birth_cohort1670M1700      0.70      0.79    -0.89     2.26        196
## hu_birth_cohort1700M1720     -0.22      0.74    -1.67     1.18        176
## hu_birth_cohort1720M1760      0.47      0.70    -0.95     1.79        152
## hu_birth_cohort1760M1765      0.44      0.71    -1.00     1.79        156
## hu_birth_cohort1765M1770      0.24      0.70    -1.18     1.60        152
## hu_birth_cohort1770M1775      0.39      0.70    -1.01     1.73        153
## hu_birth_cohort1775M1780      0.32      0.70    -1.08     1.67        150
## hu_birth_cohort1780M1785      0.22      0.70    -1.21     1.55        153
## hu_birth_cohort1785M1790      0.08      0.70    -1.33     1.40        152
## hu_birth_cohort1790M1795      0.19      0.70    -1.23     1.52        153
## hu_birth_cohort1795M1800     -0.03      0.70    -1.43     1.30        150
## hu_birth_cohort1800M1805     -0.12      0.70    -1.54     1.21        151
## hu_birth_cohort1805M1810      0.16      0.70    -1.25     1.49        151
## hu_birth_cohort1810M1815      0.00      0.70    -1.41     1.33        150
## hu_birth_cohort1815M1820     -0.26      0.70    -1.68     1.07        151
## hu_birth_cohort1820M1825     -0.10      0.70    -1.50     1.22        151
## hu_birth_cohort1825M1830     -0.14      0.70    -1.55     1.18        150
## hu_birth_cohort1830M1835     -0.15      0.70    -1.56     1.17        151
## hu_birth_cohort1835M1840      0.01      0.70    -1.40     1.33        151
## hu_birth_cohort1840M1845      0.19      0.70    -1.23     1.50        151
## hu_birth_cohort1845M1850      0.73      0.70    -0.68     2.03        151
## hu_birth_cohort1850M1855      1.58      0.70     0.16     2.90        151
## hu_birth_cohort1855M1860      2.34      0.70     0.91     3.68        155
## hu_birth_cohort1860M1865      2.19      0.70     0.76     3.51        155
## hu_male1                      0.35      0.04     0.28     0.42      10200
## hu_maternalage.factor1420     0.12      0.18    -0.22     0.48      10200
## hu_maternalage.factor3550     0.04      0.06    -0.07     0.15      10200
## hu_paternalage.mean          -0.17      0.11    -0.39     0.06       2286
## hu_paternal_loss01            0.79      0.16     0.49     1.09      10200
## hu_paternal_loss15            0.59      0.11     0.37     0.81       4501
## hu_paternal_loss510           0.30      0.10     0.11     0.49       4148
## hu_paternal_loss1015          0.32      0.09     0.14     0.50       3686
## hu_paternal_loss1520          0.20      0.09     0.03     0.37       3892
## hu_paternal_loss2025          0.16      0.08     0.00     0.32       3524
## hu_paternal_loss2530          0.08      0.08    -0.08     0.25       3341
## hu_paternal_loss3035          0.02      0.08    -0.14     0.17       3759
## hu_paternal_loss3540          0.05      0.08    -0.11     0.20       3405
## hu_paternal_loss4045          0.04      0.09    -0.13     0.21       4719
## hu_paternal_lossunclear       0.74      0.09     0.57     0.92       3527
## hu_maternal_loss01            1.64      0.16     1.33     1.95      10200
## hu_maternal_loss15            0.77      0.10     0.57     0.98       5140
## hu_maternal_loss510           0.76      0.09     0.58     0.94       5361
## hu_maternal_loss1015          0.51      0.09     0.34     0.68       4913
## hu_maternal_loss1520          0.47      0.09     0.29     0.64       5080
## hu_maternal_loss2025          0.28      0.08     0.12     0.44       4974
## hu_maternal_loss2530          0.17      0.08     0.02     0.33       4773
## hu_maternal_loss3035          0.20      0.08     0.05     0.35       5380
## hu_maternal_loss3540          0.13      0.07    -0.01     0.28       5535
## hu_maternal_loss4045          0.29      0.08     0.14     0.44       6256
## hu_maternal_lossunclear       0.83      0.08     0.67     0.99       4622
## hu_older_siblings1           -0.01      0.06    -0.12     0.11       4497
## hu_older_siblings2           -0.08      0.07    -0.22     0.07       2490
## hu_older_siblings3           -0.13      0.10    -0.32     0.06       2217
## hu_older_siblings4           -0.13      0.12    -0.38     0.11       2010
## hu_older_siblings5P          -0.39      0.16    -0.70    -0.07       1996
## hu_nr.siblings                0.08      0.01     0.05     0.11       2341
## hu_last_born1                 0.02      0.05    -0.07     0.11      10200
##                           Rhat
## Intercept                 1.02
## paternalage               1.00
## birth_cohort1670M1700     1.02
## birth_cohort1700M1720     1.02
## birth_cohort1720M1760     1.02
## birth_cohort1760M1765     1.02
## birth_cohort1765M1770     1.02
## birth_cohort1770M1775     1.02
## birth_cohort1775M1780     1.02
## birth_cohort1780M1785     1.02
## birth_cohort1785M1790     1.02
## birth_cohort1790M1795     1.02
## birth_cohort1795M1800     1.02
## birth_cohort1800M1805     1.02
## birth_cohort1805M1810     1.02
## birth_cohort1810M1815     1.02
## birth_cohort1815M1820     1.02
## birth_cohort1820M1825     1.02
## birth_cohort1825M1830     1.02
## birth_cohort1830M1835     1.02
## birth_cohort1835M1840     1.02
## birth_cohort1840M1845     1.02
## birth_cohort1845M1850     1.02
## birth_cohort1850M1855     1.02
## birth_cohort1855M1860     1.02
## birth_cohort1860M1865     1.02
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.00
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## paternal_lossunclear      1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## maternal_lossunclear      1.00
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.00
## older_siblings4           1.00
## older_siblings5P          1.00
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.04
## hu_paternalage            1.00
## hu_birth_cohort1670M1700  1.03
## hu_birth_cohort1700M1720  1.03
## hu_birth_cohort1720M1760  1.04
## hu_birth_cohort1760M1765  1.04
## hu_birth_cohort1765M1770  1.04
## hu_birth_cohort1770M1775  1.04
## hu_birth_cohort1775M1780  1.04
## hu_birth_cohort1780M1785  1.04
## hu_birth_cohort1785M1790  1.04
## hu_birth_cohort1790M1795  1.04
## hu_birth_cohort1795M1800  1.04
## hu_birth_cohort1800M1805  1.04
## hu_birth_cohort1805M1810  1.04
## hu_birth_cohort1810M1815  1.04
## hu_birth_cohort1815M1820  1.04
## hu_birth_cohort1820M1825  1.04
## hu_birth_cohort1825M1830  1.04
## hu_birth_cohort1830M1835  1.04
## hu_birth_cohort1835M1840  1.04
## hu_birth_cohort1840M1845  1.04
## hu_birth_cohort1845M1850  1.04
## hu_birth_cohort1850M1855  1.04
## hu_birth_cohort1855M1860  1.04
## hu_birth_cohort1860M1865  1.04
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_paternal_lossunclear   1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_maternal_lossunclear   1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.00
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 6.69 3.735 12.02
paternalage 1.054 0.9693 1.147
birth_cohort1670M1700 1.037 0.5473 1.968
birth_cohort1700M1720 0.9782 0.5322 1.798
birth_cohort1720M1760 0.8659 0.4846 1.534
birth_cohort1760M1765 0.9069 0.5051 1.632
birth_cohort1765M1770 0.7831 0.4384 1.396
birth_cohort1770M1775 0.7817 0.4397 1.397
birth_cohort1775M1780 0.8479 0.4761 1.499
birth_cohort1780M1785 0.7798 0.439 1.391
birth_cohort1785M1790 0.8127 0.4561 1.446
birth_cohort1790M1795 0.8312 0.4679 1.482
birth_cohort1795M1800 0.7896 0.4464 1.405
birth_cohort1800M1805 0.7847 0.4433 1.396
birth_cohort1805M1810 0.7827 0.4393 1.391
birth_cohort1810M1815 0.8006 0.4506 1.424
birth_cohort1815M1820 0.7454 0.4208 1.326
birth_cohort1820M1825 0.7108 0.3972 1.265
birth_cohort1825M1830 0.7156 0.4035 1.275
birth_cohort1830M1835 0.7168 0.4037 1.273
birth_cohort1835M1840 0.6207 0.3492 1.097
birth_cohort1840M1845 0.534 0.3016 0.9524
birth_cohort1845M1850 0.379 0.214 0.6854
birth_cohort1850M1855 0.5315 0.2947 0.9599
birth_cohort1855M1860 0.7715 0.431 1.391
birth_cohort1860M1865 0.9013 0.5034 1.619
male1 1.082 1.052 1.112
maternalage.factor1420 0.9375 0.8142 1.077
maternalage.factor3550 0.986 0.9424 1.032
paternalage.mean 0.9283 0.8501 1.014
paternal_loss01 0.8562 0.752 0.9768
paternal_loss15 0.9365 0.8579 1.023
paternal_loss510 0.9288 0.863 1
paternal_loss1015 0.9998 0.9326 1.071
paternal_loss1520 0.9034 0.8444 0.9647
paternal_loss2025 0.8882 0.8326 0.9459
paternal_loss2530 0.966 0.9102 1.026
paternal_loss3035 0.961 0.9073 1.019
paternal_loss3540 0.9957 0.9407 1.054
paternal_loss4045 0.988 0.9293 1.051
paternal_lossunclear 0.9038 0.8418 0.9707
maternal_loss01 1.096 0.9565 1.251
maternal_loss15 0.9499 0.8735 1.031
maternal_loss510 1.021 0.9466 1.098
maternal_loss1015 0.9652 0.8999 1.035
maternal_loss1520 0.9804 0.9156 1.049
maternal_loss2025 0.9789 0.9177 1.044
maternal_loss2530 0.9326 0.8783 0.9903
maternal_loss3035 0.9568 0.9046 1.013
maternal_loss3540 0.9614 0.9129 1.012
maternal_loss4045 0.982 0.929 1.037
maternal_lossunclear 0.8769 0.8195 0.9397
older_siblings1 1.004 0.9611 1.049
older_siblings2 0.9418 0.8887 0.9988
older_siblings3 0.9242 0.8563 0.9974
older_siblings4 0.9395 0.8534 1.033
older_siblings5P 0.9369 0.8255 1.063
nr.siblings 1.002 0.99 1.014
last_born1 0.9864 0.9499 1.025
hu_Intercept 0.3762 0.09703 1.555
hu_paternalage 1.338 1.081 1.665
hu_birth_cohort1670M1700 2.005 0.4108 9.566
hu_birth_cohort1700M1720 0.7999 0.1875 3.239
hu_birth_cohort1720M1760 1.596 0.3877 6.019
hu_birth_cohort1760M1765 1.56 0.3692 6.007
hu_birth_cohort1765M1770 1.272 0.3062 4.933
hu_birth_cohort1770M1775 1.48 0.3644 5.619
hu_birth_cohort1775M1780 1.379 0.3395 5.29
hu_birth_cohort1780M1785 1.245 0.2984 4.725
hu_birth_cohort1785M1790 1.08 0.2632 4.063
hu_birth_cohort1790M1795 1.211 0.2936 4.566
hu_birth_cohort1795M1800 0.9722 0.2383 3.665
hu_birth_cohort1800M1805 0.8864 0.2151 3.345
hu_birth_cohort1805M1810 1.17 0.2866 4.422
hu_birth_cohort1810M1815 1.001 0.2432 3.772
hu_birth_cohort1815M1820 0.7746 0.186 2.924
hu_birth_cohort1820M1825 0.9092 0.2224 3.372
hu_birth_cohort1825M1830 0.8654 0.2122 3.262
hu_birth_cohort1830M1835 0.8595 0.2101 3.232
hu_birth_cohort1835M1840 1.011 0.2473 3.783
hu_birth_cohort1840M1845 1.205 0.2927 4.475
hu_birth_cohort1845M1850 2.066 0.5052 7.636
hu_birth_cohort1850M1855 4.859 1.175 18.21
hu_birth_cohort1855M1860 10.37 2.495 39.48
hu_birth_cohort1860M1865 8.909 2.143 33.32
hu_male1 1.417 1.322 1.517
hu_maternalage.factor1420 1.133 0.7995 1.617
hu_maternalage.factor3550 1.038 0.9317 1.159
hu_paternalage.mean 0.847 0.6766 1.057
hu_paternal_loss01 2.199 1.627 2.972
hu_paternal_loss15 1.805 1.452 2.241
hu_paternal_loss510 1.354 1.12 1.63
hu_paternal_loss1015 1.382 1.154 1.653
hu_paternal_loss1520 1.217 1.027 1.444
hu_paternal_loss2025 1.176 0.9983 1.382
hu_paternal_loss2530 1.086 0.9271 1.279
hu_paternal_loss3035 1.021 0.87 1.191
hu_paternal_loss3540 1.047 0.8973 1.219
hu_paternal_loss4045 1.043 0.8812 1.236
hu_paternal_lossunclear 2.1 1.772 2.498
hu_maternal_loss01 5.147 3.788 7.052
hu_maternal_loss15 2.163 1.768 2.654
hu_maternal_loss510 2.135 1.781 2.565
hu_maternal_loss1015 1.664 1.4 1.978
hu_maternal_loss1520 1.594 1.341 1.893
hu_maternal_loss2025 1.323 1.124 1.558
hu_maternal_loss2530 1.185 1.017 1.384
hu_maternal_loss3035 1.22 1.052 1.417
hu_maternal_loss3540 1.14 0.9909 1.317
hu_maternal_loss4045 1.337 1.152 1.546
hu_maternal_lossunclear 2.293 1.951 2.685
hu_older_siblings1 0.9922 0.8875 1.111
hu_older_siblings2 0.9263 0.7992 1.071
hu_older_siblings3 0.8774 0.725 1.06
hu_older_siblings4 0.8749 0.6868 1.112
hu_older_siblings5P 0.6798 0.4945 0.9293
hu_nr.siblings 1.084 1.054 1.117
hu_last_born1 1.019 0.93 1.118

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 3.52 [1.4;7.02] [1.95;5.74]
estimate father 35y 3.29 [1.16;6.89] [1.71;5.55]
percentage change -6.76 [-23.07;6.41] [-17.23;2.28]
OR/IRR 1.05 [0.97;1.15] [1;1.11]
OR hurdle 1.34 [1.08;1.66] [1.16;1.55]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r22_relaxed_exclusion_censoring.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r23: Student’s t and half-Cauchy priors

To demonstrate the robustness of our prior choice we use Student’s t priors (fatter tails than normal priors) for our population-level effects and a half-Cauchy prior for our group-level effect for the family.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ student_t(5,0,10)
## sd ~ cauchy(0,5)
## b_hu ~ student_t(5,0,10)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1097 1.00
## sd(hu_Intercept)     0.48      0.04     0.39     0.56        913 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.65      0.08     1.50     1.80       1626
## paternalage                   0.07      0.05    -0.04     0.17        896
## birth_cohort1760M1765         0.00      0.06    -0.14     0.12       3000
## birth_cohort1765M1770        -0.12      0.06    -0.23     0.00       1296
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00       1119
## birth_cohort1775M1780        -0.03      0.06    -0.13     0.09       1038
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.01       1144
## birth_cohort1785M1790        -0.10      0.05    -0.20     0.01       1024
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03        903
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        838
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        813
## birth_cohort1805M1810        -0.14      0.05    -0.23    -0.04        881
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        758
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        718
## birth_cohort1820M1825        -0.19      0.05    -0.28    -0.09        772
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        683
## birth_cohort1830M1835        -0.18      0.05    -0.28    -0.09        810
## male1                         0.08      0.02     0.04     0.11       3000
## maternalage.factor1420       -0.05      0.09    -0.24     0.14       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.05    -0.18     0.04        902
## paternal_loss01              -0.15      0.07    -0.30    -0.01       3000
## paternal_loss15              -0.04      0.05    -0.13     0.06       3000
## paternal_loss510             -0.07      0.04    -0.15     0.02       1493
## paternal_loss1015             0.01      0.04    -0.07     0.08       1440
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1270
## paternal_loss2025            -0.12      0.04    -0.19    -0.04       1360
## paternal_loss2530            -0.01      0.03    -0.08     0.06       1287
## paternal_loss3035            -0.03      0.03    -0.09     0.04       1453
## paternal_loss3540            -0.01      0.03    -0.07     0.06       1482
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.10      0.08    -0.05     0.26       3000
## maternal_loss15              -0.02      0.05    -0.11     0.07       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       3000
## maternal_loss1015             0.03      0.04    -0.06     0.11       3000
## maternal_loss1520             0.00      0.04    -0.08     0.08       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       3000
## maternal_loss2530            -0.02      0.03    -0.09     0.05       3000
## maternal_loss3035            -0.05      0.03    -0.11     0.01       3000
## maternal_loss3540            -0.03      0.03    -0.09     0.03       3000
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.02     0.08       1604
## older_siblings2              -0.05      0.04    -0.12     0.02       1083
## older_siblings3              -0.07      0.05    -0.16     0.02        930
## older_siblings4              -0.09      0.06    -0.21     0.02        914
## older_siblings5P             -0.09      0.08    -0.24     0.05        900
## nr.siblings                   0.01      0.01     0.00     0.02       1167
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                 -0.33      0.19    -0.69     0.06       1531
## hu_paternalage                0.26      0.14    -0.02     0.54        818
## hu_birth_cohort1760M1765     -0.05      0.17    -0.38     0.30       3000
## hu_birth_cohort1765M1770     -0.31      0.15    -0.60    -0.01       1359
## hu_birth_cohort1770M1775     -0.07      0.14    -0.34     0.20       1221
## hu_birth_cohort1775M1780     -0.20      0.14    -0.47     0.08       1111
## hu_birth_cohort1780M1785     -0.28      0.15    -0.56     0.00       1160
## hu_birth_cohort1785M1790     -0.42      0.14    -0.69    -0.14       1184
## hu_birth_cohort1790M1795     -0.31      0.14    -0.58    -0.06       1151
## hu_birth_cohort1795M1800     -0.46      0.13    -0.71    -0.21        956
## hu_birth_cohort1800M1805     -0.54      0.13    -0.78    -0.29       1068
## hu_birth_cohort1805M1810     -0.27      0.13    -0.51    -0.02        984
## hu_birth_cohort1810M1815     -0.44      0.13    -0.69    -0.19        951
## hu_birth_cohort1815M1820     -0.70      0.12    -0.93    -0.47        889
## hu_birth_cohort1820M1825     -0.52      0.12    -0.75    -0.29        858
## hu_birth_cohort1825M1830     -0.54      0.12    -0.77    -0.31        869
## hu_birth_cohort1830M1835     -0.55      0.12    -0.79    -0.32        947
## hu_male1                      0.27      0.04     0.19     0.36       3000
## hu_maternalage.factor1420     0.24      0.24    -0.22     0.71       3000
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.28       3000
## hu_paternalage.mean          -0.18      0.15    -0.47     0.11        832
## hu_paternal_loss01            0.57      0.18     0.20     0.93       3000
## hu_paternal_loss15            0.53      0.13     0.27     0.79       3000
## hu_paternal_loss510           0.19      0.11    -0.02     0.42       3000
## hu_paternal_loss1015          0.16      0.10    -0.04     0.36       2119
## hu_paternal_loss1520          0.10      0.10    -0.09     0.30       1962
## hu_paternal_loss2025          0.15      0.10    -0.04     0.34       2042
## hu_paternal_loss2530          0.06      0.09    -0.12     0.24       1828
## hu_paternal_loss3035         -0.02      0.09    -0.21     0.15       1968
## hu_paternal_loss3540         -0.02      0.09    -0.18     0.16       2103
## hu_paternal_loss4045          0.14      0.10    -0.05     0.34       3000
## hu_maternal_loss01            1.58      0.19     1.22     1.97       3000
## hu_maternal_loss15            0.58      0.12     0.35     0.82       3000
## hu_maternal_loss510           0.48      0.11     0.27     0.70       3000
## hu_maternal_loss1015          0.47      0.11     0.25     0.69       3000
## hu_maternal_loss1520          0.31      0.11     0.10     0.53       3000
## hu_maternal_loss2025          0.26      0.10     0.05     0.46       3000
## hu_maternal_loss2530          0.19      0.09     0.01     0.37       3000
## hu_maternal_loss3035          0.22      0.09     0.05     0.39       3000
## hu_maternal_loss3540          0.07      0.08    -0.09     0.22       3000
## hu_maternal_loss4045          0.28      0.09     0.11     0.45       3000
## hu_older_siblings1           -0.01      0.07    -0.15     0.14       3000
## hu_older_siblings2           -0.15      0.10    -0.34     0.04       1077
## hu_older_siblings3           -0.19      0.13    -0.43     0.06        905
## hu_older_siblings4           -0.22      0.16    -0.54     0.09        873
## hu_older_siblings5P          -0.56      0.21    -0.96    -0.15        799
## hu_nr.siblings                0.10      0.02     0.07     0.14       1027
## hu_last_born1                 0.08      0.06    -0.04     0.20       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.00
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.01
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.00
## birth_cohort1795M1800     1.00
## birth_cohort1800M1805     1.00
## birth_cohort1805M1810     1.00
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.00
## birth_cohort1820M1825     1.00
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.00
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.00
## older_siblings4           1.00
## older_siblings5P          1.00
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.01
## hu_birth_cohort1815M1820  1.00
## hu_birth_cohort1820M1825  1.00
## hu_birth_cohort1825M1830  1.01
## hu_birth_cohort1830M1835  1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.00
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.223 4.491 6.054
paternalage 1.068 0.9598 1.183
birth_cohort1760M1765 0.9958 0.8734 1.126
birth_cohort1765M1770 0.8878 0.7917 0.9967
birth_cohort1770M1775 0.8914 0.7959 1.003
birth_cohort1775M1780 0.9749 0.8757 1.09
birth_cohort1780M1785 0.8971 0.8028 1.009
birth_cohort1785M1790 0.9092 0.8175 1.015
birth_cohort1790M1795 0.9276 0.8375 1.034
birth_cohort1795M1800 0.8996 0.8162 0.9918
birth_cohort1800M1805 0.8933 0.81 0.9837
birth_cohort1805M1810 0.873 0.7914 0.9617
birth_cohort1810M1815 0.9077 0.8278 1.002
birth_cohort1815M1820 0.8677 0.7946 0.9491
birth_cohort1820M1825 0.8311 0.7581 0.9134
birth_cohort1825M1830 0.8105 0.7385 0.8884
birth_cohort1830M1835 0.8333 0.7563 0.9173
male1 1.081 1.046 1.116
maternalage.factor1420 0.9483 0.7875 1.146
maternalage.factor3550 0.997 0.9441 1.05
paternalage.mean 0.9336 0.8381 1.04
paternal_loss01 0.8574 0.7434 0.9861
paternal_loss15 0.9642 0.8763 1.066
paternal_loss510 0.9349 0.8602 1.017
paternal_loss1015 1.007 0.9322 1.087
paternal_loss1520 0.9115 0.8437 0.9831
paternal_loss2025 0.8882 0.8262 0.9582
paternal_loss2530 0.9921 0.9262 1.06
paternal_loss3035 0.9734 0.9112 1.038
paternal_loss3540 0.9917 0.93 1.059
paternal_loss4045 0.9916 0.9223 1.065
maternal_loss01 1.106 0.9499 1.296
maternal_loss15 0.9801 0.8927 1.073
maternal_loss510 1.072 0.9908 1.161
maternal_loss1015 1.027 0.9422 1.116
maternal_loss1520 1.003 0.9265 1.085
maternal_loss2025 1.005 0.9309 1.08
maternal_loss2530 0.9792 0.9151 1.049
maternal_loss3035 0.9503 0.8934 1.014
maternal_loss3540 0.9675 0.9131 1.027
maternal_loss4045 0.9716 0.9101 1.033
older_siblings1 1.027 0.9764 1.081
older_siblings2 0.9542 0.8897 1.024
older_siblings3 0.9302 0.8506 1.02
older_siblings4 0.9121 0.8113 1.024
older_siblings5P 0.91 0.7833 1.056
nr.siblings 1.01 0.996 1.024
last_born1 0.9576 0.913 1.003
hu_Intercept 0.7201 0.4994 1.064
hu_paternalage 1.294 0.9804 1.719
hu_birth_cohort1760M1765 0.9508 0.6854 1.345
hu_birth_cohort1765M1770 0.7335 0.549 0.9923
hu_birth_cohort1770M1775 0.9363 0.7122 1.218
hu_birth_cohort1775M1780 0.8198 0.628 1.084
hu_birth_cohort1780M1785 0.757 0.571 1.004
hu_birth_cohort1785M1790 0.6582 0.5038 0.8708
hu_birth_cohort1790M1795 0.7319 0.5606 0.9449
hu_birth_cohort1795M1800 0.6322 0.4902 0.8077
hu_birth_cohort1800M1805 0.5847 0.4572 0.7452
hu_birth_cohort1805M1810 0.7654 0.5991 0.9836
hu_birth_cohort1810M1815 0.6461 0.5019 0.8251
hu_birth_cohort1815M1820 0.4964 0.3938 0.6253
hu_birth_cohort1820M1825 0.5926 0.4735 0.7519
hu_birth_cohort1825M1830 0.5807 0.4615 0.7338
hu_birth_cohort1830M1835 0.575 0.4556 0.7244
hu_male1 1.315 1.206 1.427
hu_maternalage.factor1420 1.274 0.8023 2.04
hu_maternalage.factor3550 1.142 0.9905 1.318
hu_paternalage.mean 0.8382 0.6277 1.121
hu_paternal_loss01 1.774 1.225 2.534
hu_paternal_loss15 1.698 1.314 2.209
hu_paternal_loss510 1.214 0.9782 1.519
hu_paternal_loss1015 1.17 0.9578 1.433
hu_paternal_loss1520 1.108 0.9104 1.345
hu_paternal_loss2025 1.166 0.9644 1.407
hu_paternal_loss2530 1.061 0.8878 1.269
hu_paternal_loss3035 0.9757 0.8079 1.163
hu_paternal_loss3540 0.9845 0.8348 1.169
hu_paternal_loss4045 1.153 0.9557 1.411
hu_maternal_loss01 4.87 3.392 7.143
hu_maternal_loss15 1.791 1.414 2.275
hu_maternal_loss510 1.621 1.314 2.008
hu_maternal_loss1015 1.601 1.288 1.988
hu_maternal_loss1520 1.364 1.101 1.704
hu_maternal_loss2025 1.295 1.055 1.592
hu_maternal_loss2530 1.208 1.009 1.447
hu_maternal_loss3035 1.242 1.049 1.483
hu_maternal_loss3540 1.069 0.9138 1.25
hu_maternal_loss4045 1.32 1.121 1.572
hu_older_siblings1 0.9909 0.8571 1.149
hu_older_siblings2 0.8589 0.7084 1.043
hu_older_siblings3 0.8269 0.6502 1.066
hu_older_siblings4 0.7993 0.5854 1.09
hu_older_siblings5P 0.5689 0.3823 0.8605
hu_nr.siblings 1.109 1.07 1.149
hu_last_born1 1.085 0.9574 1.226

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.28 [1.92;2.68] [2.04;2.53]
estimate father 35y 2.09 [1.66;2.6] [1.8;2.4]
percentage change -8.39 [-25.46;10.78] [-19.66;4.02]
OR/IRR 1.07 [0.96;1.18] [1;1.14]
OR hurdle 1.29 [0.98;1.72] [1.08;1.56]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r23_student_cauchy_priors.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r24: Improper flat priors

To demonstrate the robustness of our prior choice we use improper flat priors. These priors should make the model’s results comparable to a frequentist maximum likelihood approach.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## sd ~ student_t(3, 0, 10)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1227 1.00
## sd(hu_Intercept)     0.47      0.05     0.38     0.56        766 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.65      0.08     1.50     1.81       1520
## paternalage                   0.07      0.05    -0.04     0.18        906
## birth_cohort1760M1765         0.00      0.07    -0.13     0.13       3000
## birth_cohort1765M1770        -0.12      0.06    -0.23     0.00       1281
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00       1097
## birth_cohort1775M1780        -0.03      0.05    -0.13     0.08       1124
## birth_cohort1780M1785        -0.11      0.06    -0.22     0.01       1046
## birth_cohort1785M1790        -0.09      0.06    -0.20     0.01        870
## birth_cohort1790M1795        -0.08      0.05    -0.18     0.03        861
## birth_cohort1795M1800        -0.11      0.05    -0.20    -0.01        859
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.01        786
## birth_cohort1805M1810        -0.14      0.05    -0.23    -0.04        855
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        797
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        755
## birth_cohort1820M1825        -0.18      0.05    -0.27    -0.09        820
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        763
## birth_cohort1830M1835        -0.18      0.05    -0.27    -0.08        705
## male1                         0.08      0.02     0.04     0.11       3000
## maternalage.factor1420       -0.05      0.09    -0.24     0.13       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## paternalage.mean             -0.07      0.06    -0.18     0.04        946
## paternal_loss01              -0.15      0.07    -0.29    -0.01       3000
## paternal_loss15              -0.03      0.05    -0.13     0.06       1815
## paternal_loss510             -0.07      0.04    -0.15     0.02       1557
## paternal_loss1015             0.01      0.04    -0.07     0.09       1552
## paternal_loss1520            -0.09      0.04    -0.17    -0.02       1582
## paternal_loss2025            -0.12      0.04    -0.19    -0.04       1772
## paternal_loss2530            -0.01      0.04    -0.08     0.06       1427
## paternal_loss3035            -0.03      0.03    -0.09     0.04       1391
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1505
## paternal_loss4045            -0.01      0.04    -0.08     0.06       3000
## maternal_loss01               0.10      0.08    -0.06     0.25       3000
## maternal_loss15              -0.02      0.05    -0.11     0.07       3000
## maternal_loss510              0.07      0.04    -0.01     0.15       3000
## maternal_loss1015             0.03      0.04    -0.06     0.11       3000
## maternal_loss1520             0.00      0.04    -0.08     0.09       3000
## maternal_loss2025             0.00      0.04    -0.07     0.08       3000
## maternal_loss2530            -0.02      0.04    -0.09     0.04       2292
## maternal_loss3035            -0.05      0.03    -0.12     0.01       2460
## maternal_loss3540            -0.03      0.03    -0.09     0.02       2191
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       3000
## older_siblings2              -0.05      0.04    -0.12     0.03       1064
## older_siblings3              -0.07      0.05    -0.17     0.02        961
## older_siblings4              -0.09      0.06    -0.21     0.03        940
## older_siblings5P             -0.09      0.08    -0.25     0.06        938
## nr.siblings                   0.01      0.01     0.00     0.02       1098
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                 -0.32      0.20    -0.72     0.07       1079
## hu_paternalage                0.27      0.15    -0.03     0.56        856
## hu_birth_cohort1760M1765     -0.06      0.17    -0.38     0.28       3000
## hu_birth_cohort1765M1770     -0.32      0.15    -0.61    -0.03       1133
## hu_birth_cohort1770M1775     -0.08      0.14    -0.36     0.19       1123
## hu_birth_cohort1775M1780     -0.21      0.14    -0.48     0.07       1168
## hu_birth_cohort1780M1785     -0.29      0.15    -0.59     0.00       1171
## hu_birth_cohort1785M1790     -0.43      0.15    -0.71    -0.15       1077
## hu_birth_cohort1790M1795     -0.33      0.14    -0.59    -0.07       1045
## hu_birth_cohort1795M1800     -0.47      0.13    -0.72    -0.22        966
## hu_birth_cohort1800M1805     -0.55      0.13    -0.80    -0.31        914
## hu_birth_cohort1805M1810     -0.28      0.13    -0.54    -0.04        898
## hu_birth_cohort1810M1815     -0.45      0.12    -0.70    -0.20        869
## hu_birth_cohort1815M1820     -0.72      0.12    -0.95    -0.48        806
## hu_birth_cohort1820M1825     -0.54      0.12    -0.76    -0.31        793
## hu_birth_cohort1825M1830     -0.56      0.12    -0.79    -0.33        834
## hu_birth_cohort1830M1835     -0.57      0.12    -0.81    -0.35        802
## hu_male1                      0.27      0.04     0.19     0.36       3000
## hu_maternalage.factor1420     0.24      0.23    -0.22     0.70       3000
## hu_maternalage.factor3550     0.13      0.07    -0.01     0.27       3000
## hu_paternalage.mean          -0.18      0.15    -0.49     0.12        855
## hu_paternal_loss01            0.57      0.18     0.23     0.93       3000
## hu_paternal_loss15            0.53      0.13     0.28     0.77       3000
## hu_paternal_loss510           0.19      0.11    -0.03     0.41       1767
## hu_paternal_loss1015          0.16      0.11    -0.05     0.36       1603
## hu_paternal_loss1520          0.10      0.10    -0.09     0.30       1572
## hu_paternal_loss2025          0.15      0.10    -0.04     0.34       1825
## hu_paternal_loss2530          0.06      0.09    -0.13     0.24       1456
## hu_paternal_loss3035         -0.02      0.09    -0.21     0.15       1577
## hu_paternal_loss3540         -0.01      0.09    -0.20     0.16       1553
## hu_paternal_loss4045          0.14      0.10    -0.06     0.34       3000
## hu_maternal_loss01            1.58      0.19     1.21     1.97       3000
## hu_maternal_loss15            0.59      0.12     0.35     0.83       3000
## hu_maternal_loss510           0.49      0.11     0.28     0.70       3000
## hu_maternal_loss1015          0.48      0.11     0.26     0.69       3000
## hu_maternal_loss1520          0.32      0.11     0.10     0.53       3000
## hu_maternal_loss2025          0.27      0.10     0.07     0.46       3000
## hu_maternal_loss2530          0.19      0.10     0.01     0.39       3000
## hu_maternal_loss3035          0.22      0.09     0.05     0.39       3000
## hu_maternal_loss3540          0.07      0.08    -0.09     0.23       3000
## hu_maternal_loss4045          0.28      0.09     0.12     0.45       3000
## hu_older_siblings1           -0.01      0.08    -0.16     0.14       1559
## hu_older_siblings2           -0.16      0.10    -0.36     0.04        940
## hu_older_siblings3           -0.20      0.13    -0.45     0.04        859
## hu_older_siblings4           -0.23      0.16    -0.55     0.09        829
## hu_older_siblings5P          -0.58      0.22    -1.01    -0.16        786
## hu_nr.siblings                0.10      0.02     0.07     0.14       1018
## hu_last_born1                 0.08      0.06    -0.04     0.20       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.01
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.00
## birth_cohort1790M1795     1.00
## birth_cohort1795M1800     1.00
## birth_cohort1800M1805     1.01
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.00
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.00
## male1                     1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.01
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.00
## hu_birth_cohort1815M1820  1.00
## hu_birth_cohort1820M1825  1.00
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.00
## hu_male1                  1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_paternalage.mean       1.01
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.01
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.01
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.01
## hu_older_siblings4        1.01
## hu_older_siblings5P       1.01
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 5.227 4.469 6.102
paternalage 1.067 0.9629 1.197
birth_cohort1760M1765 0.9957 0.8777 1.139
birth_cohort1765M1770 0.8883 0.7951 0.9953
birth_cohort1770M1775 0.8916 0.7952 1
birth_cohort1775M1780 0.9751 0.8754 1.087
birth_cohort1780M1785 0.8963 0.8026 1.006
birth_cohort1785M1790 0.9098 0.818 1.013
birth_cohort1790M1795 0.9269 0.837 1.029
birth_cohort1795M1800 0.8997 0.8169 0.9932
birth_cohort1800M1805 0.8939 0.8137 0.9859
birth_cohort1805M1810 0.8737 0.7907 0.9637
birth_cohort1810M1815 0.9085 0.8269 0.9959
birth_cohort1815M1820 0.8686 0.7908 0.9523
birth_cohort1820M1825 0.8321 0.7609 0.9122
birth_cohort1825M1830 0.8112 0.7418 0.8909
birth_cohort1830M1835 0.8345 0.7612 0.9195
male1 1.081 1.045 1.118
maternalage.factor1420 0.9477 0.7873 1.137
maternalage.factor3550 0.9965 0.9425 1.05
paternalage.mean 0.934 0.8345 1.041
paternal_loss01 0.859 0.7454 0.9939
paternal_loss15 0.966 0.874 1.065
paternal_loss510 0.9357 0.861 1.018
paternal_loss1015 1.008 0.9287 1.091
paternal_loss1520 0.9115 0.8472 0.9804
paternal_loss2025 0.888 0.8255 0.957
paternal_loss2530 0.9916 0.9254 1.064
paternal_loss3035 0.9733 0.9107 1.038
paternal_loss3540 0.9922 0.9325 1.056
paternal_loss4045 0.9915 0.923 1.066
maternal_loss01 1.106 0.9446 1.289
maternal_loss15 0.9807 0.8964 1.076
maternal_loss510 1.073 0.9909 1.162
maternal_loss1015 1.028 0.9428 1.113
maternal_loss1520 1.004 0.9217 1.091
maternal_loss2025 1.004 0.931 1.086
maternal_loss2530 0.9785 0.9119 1.046
maternal_loss3035 0.95 0.8911 1.015
maternal_loss3540 0.9672 0.9136 1.024
maternal_loss4045 0.9707 0.9128 1.035
older_siblings1 1.027 0.9722 1.083
older_siblings2 0.9537 0.8849 1.025
older_siblings3 0.9306 0.8457 1.021
older_siblings4 0.9142 0.81 1.03
older_siblings5P 0.9105 0.7764 1.061
nr.siblings 1.01 0.9952 1.024
last_born1 0.9573 0.9127 1.003
hu_Intercept 0.7249 0.4844 1.068
hu_paternalage 1.305 0.9704 1.754
hu_birth_cohort1760M1765 0.9403 0.6808 1.326
hu_birth_cohort1765M1770 0.7245 0.5449 0.9752
hu_birth_cohort1770M1775 0.9241 0.697 1.208
hu_birth_cohort1775M1780 0.8112 0.6157 1.076
hu_birth_cohort1780M1785 0.7486 0.5555 0.9974
hu_birth_cohort1785M1790 0.6495 0.49 0.8636
hu_birth_cohort1790M1795 0.7216 0.5522 0.9369
hu_birth_cohort1795M1800 0.6246 0.486 0.8028
hu_birth_cohort1800M1805 0.5759 0.4479 0.7352
hu_birth_cohort1805M1810 0.7541 0.5855 0.957
hu_birth_cohort1810M1815 0.6382 0.4985 0.8176
hu_birth_cohort1815M1820 0.4892 0.3852 0.617
hu_birth_cohort1820M1825 0.5846 0.4655 0.7328
hu_birth_cohort1825M1830 0.5736 0.4517 0.722
hu_birth_cohort1830M1835 0.5667 0.4452 0.7076
hu_male1 1.315 1.204 1.435
hu_maternalage.factor1420 1.265 0.8 2.007
hu_maternalage.factor3550 1.138 0.9871 1.314
hu_paternalage.mean 0.8324 0.6145 1.126
hu_paternal_loss01 1.769 1.255 2.522
hu_paternal_loss15 1.696 1.322 2.17
hu_paternal_loss510 1.212 0.9715 1.504
hu_paternal_loss1015 1.171 0.9505 1.435
hu_paternal_loss1520 1.109 0.9095 1.347
hu_paternal_loss2025 1.165 0.9627 1.402
hu_paternal_loss2530 1.064 0.8823 1.273
hu_paternal_loss3035 0.9774 0.8131 1.165
hu_paternal_loss3540 0.9856 0.8219 1.176
hu_paternal_loss4045 1.154 0.9458 1.408
hu_maternal_loss01 4.867 3.366 7.175
hu_maternal_loss15 1.801 1.423 2.288
hu_maternal_loss510 1.625 1.319 2.008
hu_maternal_loss1015 1.609 1.3 1.989
hu_maternal_loss1520 1.374 1.108 1.707
hu_maternal_loss2025 1.305 1.069 1.589
hu_maternal_loss2530 1.215 1.007 1.471
hu_maternal_loss3035 1.246 1.052 1.481
hu_maternal_loss3540 1.074 0.9171 1.258
hu_maternal_loss4045 1.323 1.122 1.564
hu_older_siblings1 0.9877 0.8518 1.154
hu_older_siblings2 0.8528 0.6962 1.039
hu_older_siblings3 0.8198 0.6359 1.045
hu_older_siblings4 0.7922 0.5767 1.099
hu_older_siblings5P 0.5601 0.3633 0.8548
hu_nr.siblings 1.11 1.069 1.153
hu_last_born1 1.084 0.9586 1.221

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.27 [1.91;2.65] [2.02;2.51]
estimate father 35y 2.06 [1.61;2.58] [1.76;2.4]
percentage change -8.9 [-26.92;11.29] [-20.63;4.21]
OR/IRR 1.06 [0.96;1.2] [1;1.14]
OR hurdle 1.31 [0.97;1.75] [1.09;1.58]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r24_uniform_priors.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r25: Adjust for migration status

In the three historical populations, records were kept in the parish. Although records were linked between parishes in all populations, except three out of four provinces in historical Sweden, migration might sometimes lead to censoring of records. Adjusting for migration may however constitute a partial adjustment for the outcome, as lower offspring fitness might make them more likely to migrate. Hence, we show the results of doing so as a robustness analysis. In all analyses, we adjusted for a “migrated”-dummy variable. Migration was differently defined depending on the population. In Québec, we had flags denoting immigrants and emigrants. Few immigrants were included in our analyses anyway, as we needed parental information for our analyses. Emigrants were people who left Québec. In historical Sweden, migration was logged as migration from the parish of birth. In the Krummhörn, we set migrated to true, when the parish of death/burial differed from the parish of birth/baptism.
No migration information was available in 20th-century Sweden, but records there weren’t kept in parishes, so this should not pose a problem.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: hurdle_poisson(log) 
## Formula: children ~ paternalage + migrated + maternalage.factor + birth_cohort + male + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##          hu ~ paternalage + migrated + maternalage.factor + birth_cohort + male + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents)
##    Data: model_data (Number of observations: 9447) 
## Samples: 6 chains, each with iter = 1000; warmup = 500; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## b_hu ~ normal(0,5)
## sd_hu ~ student_t(3, 0, 10)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 2186) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.23      0.01     0.20     0.25       1105 1.00
## sd(hu_Intercept)     0.70      0.06     0.59     0.81        821 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     2.09      0.20     1.70     2.47       1745
## paternalage                   0.07      0.05    -0.04     0.18        694
## migrated                     -0.44      0.18    -0.79    -0.08       1897
## maternalage.factor1420       -0.05      0.10    -0.23     0.14       3000
## maternalage.factor3550        0.00      0.03    -0.06     0.05       3000
## birth_cohort1760M1765         0.00      0.06    -0.12     0.12       1237
## birth_cohort1765M1770        -0.12      0.06    -0.23     0.00        963
## birth_cohort1770M1775        -0.11      0.06    -0.23     0.00        770
## birth_cohort1775M1780        -0.03      0.06    -0.13     0.08        727
## birth_cohort1780M1785        -0.11      0.06    -0.23     0.00        771
## birth_cohort1785M1790        -0.10      0.05    -0.20     0.01        646
## birth_cohort1790M1795        -0.08      0.05    -0.17     0.03        646
## birth_cohort1795M1800        -0.11      0.05    -0.21    -0.01        616
## birth_cohort1800M1805        -0.11      0.05    -0.21    -0.02        637
## birth_cohort1805M1810        -0.13      0.05    -0.23    -0.04        682
## birth_cohort1810M1815        -0.10      0.05    -0.19     0.00        601
## birth_cohort1815M1820        -0.14      0.05    -0.23    -0.05        554
## birth_cohort1820M1825        -0.18      0.05    -0.28    -0.09        546
## birth_cohort1825M1830        -0.21      0.05    -0.30    -0.12        539
## birth_cohort1830M1835        -0.18      0.05    -0.27    -0.09        563
## male1                         0.08      0.02     0.04     0.11       3000
## paternalage.mean             -0.07      0.06    -0.18     0.04        710
## paternal_loss01              -0.15      0.07    -0.30    -0.01       3000
## paternal_loss15              -0.04      0.05    -0.14     0.06       1733
## paternal_loss510             -0.07      0.04    -0.15     0.01       1757
## paternal_loss1015             0.01      0.04    -0.07     0.08       1597
## paternal_loss1520            -0.10      0.04    -0.17    -0.02       1727
## paternal_loss2025            -0.12      0.04    -0.20    -0.05       1562
## paternal_loss2530            -0.01      0.03    -0.08     0.05       1426
## paternal_loss3035            -0.03      0.03    -0.09     0.03       1529
## paternal_loss3540            -0.01      0.03    -0.07     0.05       1516
## paternal_loss4045            -0.01      0.04    -0.08     0.06       1968
## maternal_loss01               0.10      0.08    -0.05     0.25       3000
## maternal_loss15              -0.02      0.05    -0.11     0.07       2272
## maternal_loss510              0.07      0.04    -0.01     0.15       1912
## maternal_loss1015             0.03      0.04    -0.05     0.11       3000
## maternal_loss1520             0.00      0.04    -0.08     0.08       3000
## maternal_loss2025             0.01      0.04    -0.07     0.08       2258
## maternal_loss2530            -0.02      0.03    -0.09     0.05       2158
## maternal_loss3035            -0.05      0.03    -0.11     0.01       1987
## maternal_loss3540            -0.03      0.03    -0.09     0.03       2110
## maternal_loss4045            -0.03      0.03    -0.09     0.03       3000
## older_siblings1               0.03      0.03    -0.03     0.08       1427
## older_siblings2              -0.05      0.04    -0.12     0.02        847
## older_siblings3              -0.07      0.05    -0.16     0.02        794
## older_siblings4              -0.09      0.06    -0.20     0.03        819
## older_siblings5P             -0.10      0.08    -0.25     0.06        697
## nr.siblings                   0.01      0.01     0.00     0.02        944
## last_born1                   -0.04      0.02    -0.09     0.00       3000
## hu_Intercept                  5.80      0.47     4.90     6.73       1781
## hu_paternalage                0.11      0.18    -0.23     0.45        898
## hu_migrated                  -6.91      0.41    -7.77    -6.17       3000
## hu_maternalage.factor1420     0.12      0.29    -0.46     0.70       3000
## hu_maternalage.factor3550     0.03      0.09    -0.15     0.21       3000
## hu_birth_cohort1760M1765     -0.18      0.21    -0.60     0.23       3000
## hu_birth_cohort1765M1770     -0.34      0.19    -0.71     0.03       1210
## hu_birth_cohort1770M1775      0.03      0.18    -0.33     0.38       1056
## hu_birth_cohort1775M1780     -0.32      0.18    -0.68     0.02       1167
## hu_birth_cohort1780M1785     -0.53      0.19    -0.91    -0.16       1240
## hu_birth_cohort1785M1790     -0.38      0.18    -0.72    -0.03       1051
## hu_birth_cohort1790M1795     -0.34      0.17    -0.67    -0.01        918
## hu_birth_cohort1795M1800     -0.55      0.17    -0.88    -0.23        796
## hu_birth_cohort1800M1805     -0.69      0.16    -1.02    -0.38        844
## hu_birth_cohort1805M1810     -0.46      0.16    -0.79    -0.13        877
## hu_birth_cohort1810M1815     -0.36      0.15    -0.67    -0.07        709
## hu_birth_cohort1815M1820     -0.58      0.14    -0.87    -0.30        709
## hu_birth_cohort1820M1825     -0.43      0.15    -0.72    -0.13        755
## hu_birth_cohort1825M1830     -0.42      0.15    -0.69    -0.13        709
## hu_birth_cohort1830M1835     -0.37      0.15    -0.67    -0.08        680
## hu_male1                      0.25      0.06     0.14     0.36       3000
## hu_paternalage.mean           0.00      0.18    -0.36     0.34        923
## hu_paternal_loss01            0.48      0.23     0.04     0.94       3000
## hu_paternal_loss15            0.49      0.16     0.18     0.81       1636
## hu_paternal_loss510           0.17      0.14    -0.10     0.45       1304
## hu_paternal_loss1015          0.18      0.14    -0.09     0.44       1385
## hu_paternal_loss1520         -0.07      0.13    -0.33     0.20       1386
## hu_paternal_loss2025          0.09      0.12    -0.16     0.33       1256
## hu_paternal_loss2530          0.02      0.12    -0.22     0.25       1271
## hu_paternal_loss3035         -0.07      0.11    -0.29     0.16       1210
## hu_paternal_loss3540         -0.01      0.11    -0.23     0.22       1439
## hu_paternal_loss4045          0.07      0.13    -0.18     0.32       3000
## hu_maternal_loss01            1.51      0.23     1.06     1.96       3000
## hu_maternal_loss15            0.65      0.15     0.34     0.95       3000
## hu_maternal_loss510           0.62      0.14     0.35     0.89       3000
## hu_maternal_loss1015          0.63      0.13     0.37     0.90       2098
## hu_maternal_loss1520          0.37      0.14     0.10     0.64       3000
## hu_maternal_loss2025          0.28      0.13     0.02     0.54       3000
## hu_maternal_loss2530          0.28      0.12     0.04     0.52       1741
## hu_maternal_loss3035          0.31      0.11     0.10     0.53       3000
## hu_maternal_loss3540          0.18      0.10    -0.02     0.37       2019
## hu_maternal_loss4045          0.30      0.11     0.09     0.53       3000
## hu_older_siblings1            0.00      0.09    -0.18     0.17       3000
## hu_older_siblings2           -0.16      0.12    -0.39     0.06       1088
## hu_older_siblings3           -0.13      0.15    -0.44     0.16        895
## hu_older_siblings4            0.00      0.19    -0.37     0.37        952
## hu_older_siblings5P          -0.18      0.25    -0.67     0.30        883
## hu_nr.siblings                0.06      0.02     0.01     0.10       1051
## hu_last_born1                 0.06      0.08    -0.10     0.21       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## migrated                  1.00
## maternalage.factor1420    1.00
## maternalage.factor3550    1.00
## birth_cohort1760M1765     1.00
## birth_cohort1765M1770     1.00
## birth_cohort1770M1775     1.00
## birth_cohort1775M1780     1.00
## birth_cohort1780M1785     1.00
## birth_cohort1785M1790     1.01
## birth_cohort1790M1795     1.00
## birth_cohort1795M1800     1.00
## birth_cohort1800M1805     1.00
## birth_cohort1805M1810     1.00
## birth_cohort1810M1815     1.00
## birth_cohort1815M1820     1.00
## birth_cohort1820M1825     1.00
## birth_cohort1825M1830     1.00
## birth_cohort1830M1835     1.00
## male1                     1.00
## paternalage.mean          1.01
## paternal_loss01           1.00
## paternal_loss15           1.00
## paternal_loss510          1.00
## paternal_loss1015         1.00
## paternal_loss1520         1.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## paternal_loss3035         1.00
## paternal_loss3540         1.00
## paternal_loss4045         1.00
## maternal_loss01           1.00
## maternal_loss15           1.00
## maternal_loss510          1.00
## maternal_loss1015         1.00
## maternal_loss1520         1.00
## maternal_loss2025         1.00
## maternal_loss2530         1.00
## maternal_loss3035         1.00
## maternal_loss3540         1.00
## maternal_loss4045         1.00
## older_siblings1           1.00
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_migrated               1.00
## hu_maternalage.factor1420 1.00
## hu_maternalage.factor3550 1.00
## hu_birth_cohort1760M1765  1.00
## hu_birth_cohort1765M1770  1.00
## hu_birth_cohort1770M1775  1.00
## hu_birth_cohort1775M1780  1.00
## hu_birth_cohort1780M1785  1.00
## hu_birth_cohort1785M1790  1.00
## hu_birth_cohort1790M1795  1.00
## hu_birth_cohort1795M1800  1.00
## hu_birth_cohort1800M1805  1.00
## hu_birth_cohort1805M1810  1.00
## hu_birth_cohort1810M1815  1.00
## hu_birth_cohort1815M1820  1.00
## hu_birth_cohort1820M1825  1.01
## hu_birth_cohort1825M1830  1.00
## hu_birth_cohort1830M1835  1.01
## hu_male1                  1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.00
## hu_paternal_loss1015      1.00
## hu_paternal_loss1520      1.00
## hu_paternal_loss2025      1.00
## hu_paternal_loss2530      1.00
## hu_paternal_loss3035      1.00
## hu_paternal_loss3540      1.00
## hu_paternal_loss4045      1.00
## hu_maternal_loss01        1.00
## hu_maternal_loss15        1.00
## hu_maternal_loss510       1.00
## hu_maternal_loss1015      1.00
## hu_maternal_loss1520      1.00
## hu_maternal_loss2025      1.00
## hu_maternal_loss2530      1.00
## hu_maternal_loss3035      1.00
## hu_maternal_loss3540      1.00
## hu_maternal_loss4045      1.00
## hu_older_siblings1        1.00
## hu_older_siblings2        1.00
## hu_older_siblings3        1.00
## hu_older_siblings4        1.00
## hu_older_siblings5P       1.00
## hu_nr.siblings            1.00
## hu_last_born1             1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).

Table of fixed effects

Estimates are exp(b). When they are referring to the hurdle (hu) component, or a dichotomous outcome, they are odds ratios, when they are referring to a Poisson component, they are hazard ratios. In both cases, they are presented with 95% credibility intervals. To see the effects on the response scale (probability or number of children), consult the marginal effect plots.

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$`Odds/hazard ratio` = exp(fixed_eff$Estimate)
fixed_eff$`OR/HR low 95%` = exp(fixed_eff$`l-95% CI`)
fixed_eff$`OR/HR high 95%` = exp(fixed_eff$`u-95% CI`)
fixed_eff = fixed_eff %>% select(`Odds/hazard ratio`, `OR/HR low 95%`, `OR/HR high 95%`)
pander::pander(fixed_eff)
  Odds/hazard ratio OR/HR low 95% OR/HR high 95%
Intercept 8.07 5.459 11.77
paternalage 1.072 0.9635 1.192
migrated 0.6462 0.454 0.9233
maternalage.factor1420 0.9507 0.7942 1.149
maternalage.factor3550 0.997 0.9452 1.054
birth_cohort1760M1765 0.9979 0.8831 1.126
birth_cohort1765M1770 0.8874 0.7922 0.9958
birth_cohort1770M1775 0.8922 0.7958 1.004
birth_cohort1775M1780 0.9709 0.8747 1.085
birth_cohort1780M1785 0.897 0.7981 1.003
birth_cohort1785M1790 0.9076 0.8174 1.007
birth_cohort1790M1795 0.9275 0.8405 1.028
birth_cohort1795M1800 0.8967 0.8136 0.9899
birth_cohort1800M1805 0.8923 0.808 0.983
birth_cohort1805M1810 0.8738 0.7926 0.9636
birth_cohort1810M1815 0.9086 0.8295 0.9969
birth_cohort1815M1820 0.868 0.7934 0.9525
birth_cohort1820M1825 0.8317 0.759 0.9114
birth_cohort1825M1830 0.811 0.738 0.888
birth_cohort1830M1835 0.8333 0.7598 0.9163
male1 1.081 1.046 1.116
paternalage.mean 0.9318 0.8333 1.04
paternal_loss01 0.8576 0.7428 0.989
paternal_loss15 0.9606 0.87 1.058
paternal_loss510 0.9328 0.8603 1.009
paternal_loss1015 1.006 0.9297 1.087
paternal_loss1520 0.9069 0.8422 0.9761
paternal_loss2025 0.8854 0.8216 0.9508
paternal_loss2530 0.987 0.9237 1.053
paternal_loss3035 0.9708 0.9095 1.035
paternal_loss3540 0.9863 0.9286 1.051
paternal_loss4045 0.9891 0.9212 1.06
maternal_loss01 1.109 0.9496 1.283
maternal_loss15 0.9828 0.8955 1.075
maternal_loss510 1.074 0.9908 1.159
maternal_loss1015 1.029 0.9495 1.116
maternal_loss1520 1.003 0.9275 1.083
maternal_loss2025 1.007 0.9309 1.086
maternal_loss2530 0.9787 0.9152 1.05
maternal_loss3035 0.9525 0.8918 1.014
maternal_loss3540 0.9681 0.9135 1.027
maternal_loss4045 0.9716 0.9143 1.032
older_siblings1 1.026 0.9739 1.083
older_siblings2 0.9525 0.888 1.023
older_siblings3 0.9291 0.8491 1.022
older_siblings4 0.9118 0.8154 1.028
older_siblings5P 0.9068 0.7804 1.059
nr.siblings 1.01 0.9956 1.024
last_born1 0.9575 0.9145 1.002
hu_Intercept 330 134.9 835.2
hu_paternalage 1.115 0.7967 1.572
hu_migrated 0.0009989 0.0004209 0.002101
hu_maternalage.factor1420 1.133 0.6328 2.004
hu_maternalage.factor3550 1.031 0.8579 1.234
hu_birth_cohort1760M1765 0.8369 0.5512 1.26
hu_birth_cohort1765M1770 0.7126 0.4899 1.03
hu_birth_cohort1770M1775 1.033 0.7218 1.464
hu_birth_cohort1775M1780 0.7227 0.5083 1.025
hu_birth_cohort1780M1785 0.5902 0.4025 0.8543
hu_birth_cohort1785M1790 0.6825 0.4845 0.9674
hu_birth_cohort1790M1795 0.711 0.5096 0.9909
hu_birth_cohort1795M1800 0.5755 0.4154 0.7944
hu_birth_cohort1800M1805 0.5012 0.362 0.685
hu_birth_cohort1805M1810 0.6337 0.4553 0.8744
hu_birth_cohort1810M1815 0.6961 0.514 0.9357
hu_birth_cohort1815M1820 0.5609 0.4209 0.7376
hu_birth_cohort1820M1825 0.6509 0.4863 0.8807
hu_birth_cohort1825M1830 0.6602 0.5009 0.8771
hu_birth_cohort1830M1835 0.69 0.5095 0.9258
hu_male1 1.286 1.15 1.439
hu_paternalage.mean 0.9981 0.7008 1.4
hu_paternal_loss01 1.624 1.04 2.562
hu_paternal_loss15 1.63 1.198 2.251
hu_paternal_loss510 1.189 0.9054 1.562
hu_paternal_loss1015 1.192 0.9143 1.557
hu_paternal_loss1520 0.934 0.7213 1.219
hu_paternal_loss2025 1.093 0.856 1.391
hu_paternal_loss2530 1.016 0.8054 1.282
hu_paternal_loss3035 0.9325 0.7466 1.17
hu_paternal_loss3540 0.9937 0.7955 1.244
hu_paternal_loss4045 1.068 0.836 1.377
hu_maternal_loss01 4.543 2.9 7.103
hu_maternal_loss15 1.916 1.412 2.587
hu_maternal_loss510 1.863 1.425 2.431
hu_maternal_loss1015 1.884 1.45 2.459
hu_maternal_loss1520 1.445 1.101 1.891
hu_maternal_loss2025 1.322 1.021 1.708
hu_maternal_loss2530 1.32 1.044 1.676
hu_maternal_loss3035 1.368 1.103 1.701
hu_maternal_loss3540 1.191 0.9766 1.449
hu_maternal_loss4045 1.351 1.095 1.692
hu_older_siblings1 1 0.8372 1.19
hu_older_siblings2 0.8505 0.6764 1.067
hu_older_siblings3 0.8746 0.6465 1.176
hu_older_siblings4 1.003 0.6875 1.442
hu_older_siblings5P 0.8385 0.5127 1.353
hu_nr.siblings 1.06 1.014 1.106
hu_last_born1 1.059 0.9084 1.239

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 0.93 [0.63;1.32] [0.72;1.17]
estimate father 35y 0.9 [0.58;1.35] [0.68;1.19]
percentage change -1.98 [-28.8;31.32] [-20.51;19.12]
OR/IRR 1.07 [0.96;1.19] [1;1.15]
OR hurdle 1.11 [0.8;1.57] [0.9;1.4]

Marginal effect plots

In these marginal effect plots, we set all predictors except the one shown on the X axis to their mean and in the case of factors to their reference level. We then plot the estimated association between the X axis predictor and the outcome on the response scale (e.g. probability of survival/marriage or number of children).

plot.brmsMarginalEffects_shades(
    x = marginal_effects(model, re_formula = NA, probs = c(0.025,0.975)),
    y = marginal_effects(model, re_formula = NA, probs = c(0.1,0.9)), 
    ask = FALSE)

Coefficient plot

Here, we plotted the 95% posterior densities for the unexponentiated model coefficients (b_). The darkly shaded area represents the 50% credibility interval, the dark line represent the posterior mean estimate.

mcmc_areas(as.matrix(model$fit), regex_pars = "b_[^I]", point_est = "mean", prob = 0.50, prob_outer = 0.95) + ggtitle("Posterior densities with means and 50% intervals") + analysis_theme + theme(axis.text = element_text(size = 12), panel.grid = element_blank()) + xlab("Coefficient size")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

In posterior predictive checks, we test whether we can approximately reproduce the real data distribution from our model.

brms::pp_check(model, re_formula = NA, type = "dens_overlay")

brms::pp_check(model, re_formula = NA, type = "hist")

Rhat

Did the 6 chains converge?

stanplot(model, pars = "^b_[^I]", type = 'rhat')

Effective sample size over average sample size

stanplot(model, pars = "^b", type = 'neff_hist')

Trace plots

Trace plots are only shown in the case of nonconvergence.

if(any( summary(model)$fixed[,"Rhat"] > 1.1)) { # only do traceplots if not converged
    plot(model, N = 3, ask = FALSE)
}

File/cluster script name

This model was stored in the file: coefs/krmh/r25_migration_status.rds.

Click the following link to see the script used to generate this model:

opts_chunk$set(echo = FALSE)
clusterscript = str_replace(basename(model_filename), "\\.rds",".html")
cat("[Cluster script](" , clusterscript, ")", sep = "")

Cluster script

r26: Separate parental age contributions

In this model, we adjust for maternal age using a continuous variable. We also adjust for a dummy variable for teenage motherhood, to account for the nonlinearity of the maternal age effect. Moreover, we use separate random intercepts for mothers and fathers and adjust for the mother’s mean age at birth and the father’s mean age at birth. This model only converges in the 20th-century Sweden data, because there are sufficient numbers of divorces and remarriages and enough data to separate the parents’ contributions.

Robustness check comparison

Here we show the effect of paternal age for each episode.

Legend

In reference to m3, the main reported model, the robustness models were implemented as follows: r1 relaxed exclusion criteria (not in 20th-century Sweden), r2 had only birth cohort as a covariate, r3 adjusted for birth order as a continuous variable, r4 adjusted for number of dependent siblings instead of birth order, r5 interacted birth order with number of siblings, r6 did not adjust for birth order, r7 adjusted only for parental loss in the first 5 years, r8 adjusted for being the first-/last-born adult son, r9 adjusted for a continuous nonlinear thin-splate spline for birth year instead of 5-year bins, r10 added a group-level slope for paternal age, r11 included separate group-level effects for each parent instead of one per marriage, r12 added a moderation by anchor sex, r13 adjusted for paternal age at first birth, r14 compared a model with linear group fixed effects, r15 added a moderator by region and group-level effects by church parish (not in 20th-century Sweden), r16 was restricted to Skellefteå (only in historical Sweden), r17 simulated Down syndrome cases, r18 reversed hurdle Poisson and Poisson distribution for the respective populations, r19 used a normal distribution, r20 did not adjust for maternal age, r21 adjusted for maternal age as a continuous variable, r22 relaxed exclusion criteria and included 30 more years of birth cohorts, allowing for more potential censoring, r23 used Student’s t distributions for population-level priors and half-Cauchy priors for the family variance component, r24 used noninformative priors, which should lead to results comparable with maximum likelihood, r25 controlled for migration status (not in 20th-century Sweden), r26 separate parental age contributions (only in 20th-century Sweden).

Points show median estimates, the lines show 80% and 95% credibility intervals respectively.