Demographic data base (Sweden 1760-1880), 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, "ddb")
} 
# options for each chunk calling knit_child
opts_chunk$set(warning=FALSE, message = FALSE)

Analysis description

Data subset

The ddb.1 dataset contains only those participants where paternal age is known and the birthdate is between 1760 and 1880.

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: 84106) 
## 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: 24407) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.37      0.01     0.36     0.38       1148 1.00
## sd(hu_Intercept)     0.92      0.02     0.89     0.96       1079 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.35      0.08     1.20     1.50        189
## paternalage                  -0.05      0.02    -0.09    -0.01        899
## birth_cohort1750M1755        -0.12      0.10    -0.32     0.08        401
## birth_cohort1755M1760         0.05      0.09    -0.12     0.23        305
## birth_cohort1760M1765         0.12      0.08    -0.04     0.28        217
## birth_cohort1765M1770         0.11      0.08    -0.06     0.27        222
## birth_cohort1770M1775         0.06      0.08    -0.10     0.24        216
## birth_cohort1775M1780         0.06      0.08    -0.10     0.22        196
## birth_cohort1780M1785         0.16      0.08     0.01     0.32        195
## birth_cohort1785M1790         0.11      0.08    -0.05     0.27        190
## birth_cohort1790M1795         0.03      0.08    -0.12     0.18        180
## birth_cohort1795M1800         0.02      0.08    -0.13     0.17        181
## birth_cohort1800M1805        -0.03      0.08    -0.17     0.12        179
## birth_cohort1805M1810         0.00      0.07    -0.15     0.14        178
## birth_cohort1810M1815         0.01      0.07    -0.14     0.15        177
## birth_cohort1815M1820         0.07      0.07    -0.08     0.21        170
## birth_cohort1820M1825         0.08      0.07    -0.07     0.22        173
## birth_cohort1825M1830         0.04      0.07    -0.10     0.19        170
## birth_cohort1830M1835         0.07      0.07    -0.08     0.21        170
## birth_cohort1835M1840         0.06      0.07    -0.09     0.20        173
## birth_cohort1840M1845         0.03      0.07    -0.11     0.17        171
## birth_cohort1845M1850         0.03      0.07    -0.12     0.17        171
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.05      0.03     0.00     0.10       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       3000
## paternalage.mean              0.05      0.02     0.02     0.09        953
## paternal_loss01               0.03      0.04    -0.04     0.11       3000
## paternal_loss15               0.03      0.02    -0.02     0.07       1966
## paternal_loss510             -0.02      0.02    -0.06     0.02       1748
## paternal_loss1015            -0.02      0.02    -0.06     0.01       1640
## paternal_loss1520            -0.08      0.02    -0.11    -0.04       1550
## paternal_loss2025            -0.04      0.02    -0.07     0.00       1628
## paternal_loss2530            -0.02      0.01    -0.05     0.01       1606
## paternal_loss3035            -0.02      0.01    -0.05     0.01       1722
## paternal_loss3540             0.02      0.01     0.00     0.05       2126
## paternal_loss4045             0.03      0.01     0.00     0.05       2320
## paternal_lossunclear         -0.05      0.02    -0.09    -0.01       1945
## maternal_loss01               0.03      0.05    -0.07     0.12       3000
## maternal_loss15              -0.01      0.03    -0.06     0.04       3000
## maternal_loss510             -0.03      0.02    -0.07     0.02       1873
## maternal_loss1015            -0.05      0.02    -0.10    -0.01       3000
## maternal_loss1520            -0.05      0.02    -0.09    -0.01       1744
## maternal_loss2025            -0.07      0.02    -0.11    -0.04       1601
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1935
## maternal_loss3035            -0.02      0.01    -0.05     0.01       1820
## maternal_loss3540             0.00      0.01    -0.02     0.03       3000
## maternal_loss4045            -0.02      0.01    -0.04     0.00       3000
## maternal_lossunclear         -0.16      0.02    -0.20    -0.12       1998
## older_siblings1               0.02      0.01    -0.01     0.04       1482
## older_siblings2               0.03      0.01     0.00     0.06       1135
## older_siblings3               0.03      0.02     0.00     0.07        943
## older_siblings4               0.01      0.02    -0.03     0.05        987
## older_siblings5P              0.03      0.03    -0.02     0.08        830
## nr.siblings                   0.02      0.00     0.02     0.03       1024
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                  0.07      0.18    -0.28     0.42        292
## hu_paternalage                0.29      0.05     0.19     0.40       1010
## hu_birth_cohort1750M1755      0.04      0.25    -0.44     0.53        683
## hu_birth_cohort1755M1760     -0.03      0.22    -0.46     0.40        436
## hu_birth_cohort1760M1765     -0.09      0.20    -0.49     0.30        333
## hu_birth_cohort1765M1770     -0.29      0.20    -0.68     0.11        351
## hu_birth_cohort1770M1775     -0.19      0.21    -0.59     0.22        344
## hu_birth_cohort1775M1780      0.14      0.20    -0.24     0.53        321
## hu_birth_cohort1780M1785      0.07      0.20    -0.31     0.44        318
## hu_birth_cohort1785M1790      0.23      0.19    -0.14     0.60        302
## hu_birth_cohort1790M1795      0.39      0.18     0.04     0.72        302
## hu_birth_cohort1795M1800      0.24      0.18    -0.11     0.57        280
## hu_birth_cohort1800M1805      0.16      0.18    -0.19     0.49        273
## hu_birth_cohort1805M1810      0.13      0.17    -0.21     0.46        269
## hu_birth_cohort1810M1815      0.22      0.17    -0.11     0.55        259
## hu_birth_cohort1815M1820      0.06      0.17    -0.27     0.38        257
## hu_birth_cohort1820M1825     -0.07      0.17    -0.41     0.24        258
## hu_birth_cohort1825M1830     -0.10      0.17    -0.44     0.22        257
## hu_birth_cohort1830M1835     -0.10      0.17    -0.43     0.22        256
## hu_birth_cohort1835M1840     -0.15      0.17    -0.48     0.17        257
## hu_birth_cohort1840M1845     -0.14      0.17    -0.48     0.18        256
## hu_birth_cohort1845M1850     -0.13      0.17    -0.46     0.19        255
## hu_male1                      0.07      0.02     0.03     0.10       3000
## hu_maternalage.factor1020     0.13      0.08    -0.02     0.28       3000
## hu_maternalage.factor3559    -0.04      0.03    -0.09     0.01       3000
## hu_paternalage.mean          -0.31      0.05    -0.42    -0.21       1090
## hu_paternal_loss01            0.76      0.09     0.59     0.93       3000
## hu_paternal_loss15            0.61      0.06     0.49     0.73       1918
## hu_paternal_loss510           0.59      0.05     0.49     0.70       1660
## hu_paternal_loss1015          0.45      0.05     0.35     0.55       1757
## hu_paternal_loss1520          0.35      0.05     0.26     0.44       1724
## hu_paternal_loss2025          0.24      0.04     0.15     0.32       1706
## hu_paternal_loss2530          0.15      0.04     0.07     0.23       1462
## hu_paternal_loss3035          0.09      0.04     0.01     0.17       1814
## hu_paternal_loss3540          0.07      0.04    -0.01     0.15       1623
## hu_paternal_loss4045          0.00      0.04    -0.07     0.08       3000
## hu_paternal_lossunclear       1.24      0.05     1.14     1.34       1526
## hu_maternal_loss01            1.76      0.11     1.54     1.98       3000
## hu_maternal_loss15            0.95      0.07     0.82     1.08       3000
## hu_maternal_loss510           0.83      0.06     0.71     0.94       3000
## hu_maternal_loss1015          0.78      0.05     0.67     0.88       3000
## hu_maternal_loss1520          0.61      0.05     0.52     0.71       3000
## hu_maternal_loss2025          0.41      0.05     0.32     0.49       3000
## hu_maternal_loss2530          0.25      0.04     0.17     0.33       3000
## hu_maternal_loss3035          0.18      0.04     0.11     0.26       3000
## hu_maternal_loss3540          0.10      0.03     0.04     0.17       3000
## hu_maternal_loss4045          0.04      0.04    -0.03     0.11       3000
## hu_maternal_lossunclear       1.44      0.05     1.36     1.53       2096
## hu_older_siblings1           -0.06      0.03    -0.11     0.00       1705
## hu_older_siblings2           -0.07      0.04    -0.15     0.00       1140
## hu_older_siblings3           -0.12      0.05    -0.21    -0.02       1118
## hu_older_siblings4           -0.18      0.06    -0.30    -0.07       1066
## hu_older_siblings5P          -0.27      0.08    -0.42    -0.11        990
## hu_nr.siblings                0.03      0.01     0.01     0.04       1229
## hu_last_born1                 0.03      0.02    -0.01     0.08       3000
##                           Rhat
## Intercept                 1.03
## paternalage               1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.02
## birth_cohort1760M1765     1.02
## birth_cohort1765M1770     1.02
## birth_cohort1770M1775     1.02
## 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
## birth_cohort1835M1840     1.03
## birth_cohort1840M1845     1.03
## birth_cohort1845M1850     1.03
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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
## 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.01
## hu_paternalage            1.00
## hu_birth_cohort1750M1755  1.00
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## 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_birth_cohort1835M1840  1.01
## hu_birth_cohort1840M1845  1.01
## hu_birth_cohort1845M1850  1.01
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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 3.848 3.311 4.462
paternalage 0.9521 0.9182 0.9864
birth_cohort1750M1755 0.8904 0.7271 1.087
birth_cohort1755M1760 1.051 0.8836 1.254
birth_cohort1760M1765 1.13 0.9607 1.326
birth_cohort1765M1770 1.113 0.946 1.307
birth_cohort1770M1775 1.064 0.9071 1.266
birth_cohort1775M1780 1.062 0.9053 1.246
birth_cohort1780M1785 1.173 1.005 1.378
birth_cohort1785M1790 1.113 0.9532 1.304
birth_cohort1790M1795 1.025 0.8833 1.192
birth_cohort1795M1800 1.024 0.8824 1.19
birth_cohort1800M1805 0.9733 0.8398 1.131
birth_cohort1805M1810 0.9965 0.8641 1.154
birth_cohort1810M1815 1.006 0.8733 1.166
birth_cohort1815M1820 1.068 0.9269 1.236
birth_cohort1820M1825 1.081 0.936 1.248
birth_cohort1825M1830 1.043 0.9034 1.21
birth_cohort1830M1835 1.068 0.9271 1.235
birth_cohort1835M1840 1.057 0.9173 1.223
birth_cohort1840M1845 1.028 0.8971 1.19
birth_cohort1845M1850 1.026 0.8904 1.187
male1 1.041 1.028 1.055
maternalage.factor1020 1.05 0.9953 1.107
maternalage.factor3559 1.058 1.037 1.08
paternalage.mean 1.053 1.015 1.094
paternal_loss01 1.035 0.9655 1.113
paternal_loss15 1.026 0.9776 1.074
paternal_loss510 0.9775 0.9395 1.019
paternal_loss1015 0.9787 0.9431 1.015
paternal_loss1520 0.9261 0.8962 0.9584
paternal_loss2025 0.9651 0.9353 0.9956
paternal_loss2530 0.9773 0.9499 1.006
paternal_loss3035 0.9809 0.9538 1.008
paternal_loss3540 1.022 0.9965 1.049
paternal_loss4045 1.03 1.004 1.056
paternal_lossunclear 0.9469 0.9107 0.9868
maternal_loss01 1.025 0.9324 1.132
maternal_loss15 0.99 0.9387 1.046
maternal_loss510 0.9742 0.9322 1.017
maternal_loss1015 0.9468 0.907 0.9889
maternal_loss1520 0.9503 0.9165 0.9882
maternal_loss2025 0.9297 0.8987 0.9619
maternal_loss2530 0.9735 0.9441 1.003
maternal_loss3035 0.9782 0.9527 1.005
maternal_loss3540 1.003 0.9794 1.028
maternal_loss4045 0.9805 0.956 1.005
maternal_lossunclear 0.8503 0.8188 0.8837
older_siblings1 1.015 0.9948 1.037
older_siblings2 1.03 1.003 1.057
older_siblings3 1.034 1.001 1.069
older_siblings4 1.01 0.9699 1.05
older_siblings5P 1.029 0.9783 1.084
nr.siblings 1.022 1.017 1.027
last_born1 0.9825 0.965 0.9999
hu_Intercept 1.067 0.7594 1.515
hu_paternalage 1.338 1.213 1.487
hu_birth_cohort1750M1755 1.038 0.6453 1.701
hu_birth_cohort1755M1760 0.9748 0.6313 1.49
hu_birth_cohort1760M1765 0.9149 0.6145 1.347
hu_birth_cohort1765M1770 0.7517 0.507 1.112
hu_birth_cohort1770M1775 0.8303 0.5566 1.25
hu_birth_cohort1775M1780 1.156 0.7878 1.693
hu_birth_cohort1780M1785 1.07 0.7307 1.557
hu_birth_cohort1785M1790 1.257 0.8694 1.83
hu_birth_cohort1790M1795 1.479 1.042 2.062
hu_birth_cohort1795M1800 1.269 0.8954 1.77
hu_birth_cohort1800M1805 1.174 0.8249 1.626
hu_birth_cohort1805M1810 1.141 0.8116 1.589
hu_birth_cohort1810M1815 1.248 0.8957 1.731
hu_birth_cohort1815M1820 1.062 0.7627 1.457
hu_birth_cohort1820M1825 0.9292 0.662 1.277
hu_birth_cohort1825M1830 0.9013 0.6434 1.24
hu_birth_cohort1830M1835 0.9064 0.65 1.247
hu_birth_cohort1835M1840 0.8645 0.6163 1.186
hu_birth_cohort1840M1845 0.8708 0.6178 1.202
hu_birth_cohort1845M1850 0.8803 0.6321 1.208
hu_male1 1.071 1.035 1.108
hu_maternalage.factor1020 1.135 0.9758 1.322
hu_maternalage.factor3559 0.9618 0.9124 1.012
hu_paternalage.mean 0.7343 0.6603 0.811
hu_paternal_loss01 2.137 1.795 2.525
hu_paternal_loss15 1.848 1.64 2.085
hu_paternal_loss510 1.81 1.631 2.016
hu_paternal_loss1015 1.564 1.422 1.726
hu_paternal_loss1520 1.418 1.296 1.554
hu_paternal_loss2025 1.265 1.164 1.376
hu_paternal_loss2530 1.164 1.073 1.263
hu_paternal_loss3035 1.092 1.01 1.182
hu_paternal_loss3540 1.073 0.9935 1.161
hu_paternal_loss4045 1.004 0.9286 1.086
hu_paternal_lossunclear 3.461 3.14 3.815
hu_maternal_loss01 5.792 4.67 7.209
hu_maternal_loss15 2.587 2.269 2.959
hu_maternal_loss510 2.284 2.036 2.567
hu_maternal_loss1015 2.177 1.96 2.423
hu_maternal_loss1520 1.845 1.682 2.028
hu_maternal_loss2025 1.5 1.373 1.637
hu_maternal_loss2530 1.288 1.19 1.395
hu_maternal_loss3035 1.203 1.118 1.298
hu_maternal_loss3540 1.109 1.036 1.185
hu_maternal_loss4045 1.041 0.9692 1.114
hu_maternal_lossunclear 4.227 3.887 4.617
hu_older_siblings1 0.9446 0.8921 0.9985
hu_older_siblings2 0.9321 0.8625 1.002
hu_older_siblings3 0.8891 0.8076 0.9769
hu_older_siblings4 0.8323 0.7385 0.9334
hu_older_siblings5P 0.7658 0.6576 0.8918
hu_nr.siblings 1.027 1.014 1.041
hu_last_born1 1.035 0.987 1.086

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.42 [1.97;2.96] [2.12;2.76]
estimate father 35y 2 [1.58;2.48] [1.72;2.31]
percentage change -17.32 [-22.85;-11.8] [-20.98;-13.78]
OR/IRR 0.95 [0.92;0.99] [0.93;0.97]
OR hurdle 1.34 [1.21;1.49] [1.25;1.43]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.38       1158 1.01
## sd(hu_Intercept)     0.89      0.02     0.85     0.92       1175 1.00
## 
## Population-Level Effects: 
##                          Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                    1.39      0.08     1.23     1.54        313
## paternalage                 -0.03      0.01    -0.05    -0.02       3000
## birth_cohort1750M1755       -0.14      0.12    -0.37     0.09        816
## birth_cohort1755M1760        0.10      0.09    -0.08     0.28        504
## birth_cohort1760M1765        0.16      0.09    -0.01     0.32        397
## birth_cohort1765M1770        0.12      0.09    -0.05     0.30        374
## birth_cohort1770M1775        0.08      0.09    -0.09     0.25        380
## birth_cohort1775M1780        0.07      0.08    -0.10     0.23        357
## birth_cohort1780M1785        0.18      0.08     0.01     0.35        333
## birth_cohort1785M1790        0.13      0.08    -0.04     0.29        309
## birth_cohort1790M1795        0.01      0.08    -0.14     0.17        305
## birth_cohort1795M1800        0.02      0.08    -0.14     0.17        290
## birth_cohort1800M1805       -0.03      0.08    -0.17     0.13        295
## birth_cohort1805M1810       -0.01      0.08    -0.16     0.14        295
## birth_cohort1810M1815        0.02      0.08    -0.12     0.17        288
## birth_cohort1815M1820        0.07      0.08    -0.07     0.22        280
## birth_cohort1820M1825        0.10      0.07    -0.04     0.25        283
## birth_cohort1825M1830        0.07      0.07    -0.08     0.22        280
## birth_cohort1830M1835        0.10      0.07    -0.05     0.25        274
## birth_cohort1835M1840        0.10      0.08    -0.04     0.25        273
## birth_cohort1840M1845        0.09      0.08    -0.06     0.24        276
## birth_cohort1845M1850        0.10      0.07    -0.04     0.25        276
## paternalage.mean             0.05      0.01     0.03     0.07       2420
## hu_Intercept                 0.43      0.19     0.05     0.81        321
## hu_paternalage               0.32      0.02     0.28     0.36       3000
## hu_birth_cohort1750M1755     0.37      0.29    -0.18     0.95        826
## hu_birth_cohort1755M1760     0.06      0.24    -0.43     0.54        549
## hu_birth_cohort1760M1765    -0.08      0.23    -0.54     0.38        454
## hu_birth_cohort1765M1770    -0.34      0.23    -0.78     0.11        396
## hu_birth_cohort1770M1775    -0.10      0.22    -0.54     0.34        399
## hu_birth_cohort1775M1780     0.05      0.22    -0.38     0.47        397
## hu_birth_cohort1780M1785     0.01      0.22    -0.43     0.44        383
## hu_birth_cohort1785M1790     0.19      0.21    -0.22     0.61        328
## hu_birth_cohort1790M1795     0.38      0.20    -0.02     0.77        308
## hu_birth_cohort1795M1800     0.20      0.19    -0.18     0.58        301
## hu_birth_cohort1800M1805     0.10      0.19    -0.29     0.48        309
## hu_birth_cohort1805M1810     0.04      0.19    -0.34     0.41        307
## hu_birth_cohort1810M1815     0.08      0.19    -0.30     0.46        285
## hu_birth_cohort1815M1820    -0.09      0.19    -0.47     0.27        299
## hu_birth_cohort1820M1825    -0.21      0.19    -0.57     0.16        300
## hu_birth_cohort1825M1830    -0.22      0.19    -0.59     0.14        281
## hu_birth_cohort1830M1835    -0.20      0.19    -0.58     0.16        283
## hu_birth_cohort1835M1840    -0.24      0.19    -0.60     0.12        283
## hu_birth_cohort1840M1845    -0.24      0.19    -0.61     0.13        281
## hu_birth_cohort1845M1850    -0.19      0.19    -0.56     0.16        295
## hu_paternalage.mean         -0.27      0.03    -0.33    -0.22       3000
##                          Rhat
## Intercept                1.02
## paternalage              1.00
## birth_cohort1750M1755    1.01
## birth_cohort1755M1760    1.01
## 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
## paternalage.mean         1.00
## hu_Intercept             1.01
## hu_paternalage           1.00
## hu_birth_cohort1750M1755 1.01
## hu_birth_cohort1755M1760 1.00
## hu_birth_cohort1760M1765 1.01
## hu_birth_cohort1765M1770 1.01
## hu_birth_cohort1770M1775 1.01
## hu_birth_cohort1775M1780 1.00
## 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_birth_cohort1835M1840 1.01
## hu_birth_cohort1840M1845 1.01
## hu_birth_cohort1845M1850 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 4.003 3.416 4.658
paternalage 0.9657 0.9523 0.979
birth_cohort1750M1755 0.8675 0.692 1.09
birth_cohort1755M1760 1.103 0.9201 1.325
birth_cohort1760M1765 1.17 0.993 1.381
birth_cohort1765M1770 1.133 0.955 1.346
birth_cohort1770M1775 1.086 0.9129 1.287
birth_cohort1775M1780 1.067 0.9042 1.265
birth_cohort1780M1785 1.196 1.011 1.413
birth_cohort1785M1790 1.137 0.9643 1.336
birth_cohort1790M1795 1.014 0.8661 1.188
birth_cohort1795M1800 1.017 0.8714 1.189
birth_cohort1800M1805 0.975 0.8397 1.134
birth_cohort1805M1810 0.9887 0.8551 1.152
birth_cohort1810M1815 1.021 0.8832 1.191
birth_cohort1815M1820 1.073 0.9312 1.249
birth_cohort1820M1825 1.109 0.9599 1.287
birth_cohort1825M1830 1.069 0.9233 1.24
birth_cohort1830M1835 1.105 0.9559 1.286
birth_cohort1835M1840 1.11 0.9605 1.29
birth_cohort1840M1845 1.092 0.9436 1.266
birth_cohort1845M1850 1.104 0.9571 1.281
paternalage.mean 1.055 1.034 1.076
hu_Intercept 1.536 1.052 2.245
hu_paternalage 1.381 1.325 1.438
hu_birth_cohort1750M1755 1.453 0.8336 2.594
hu_birth_cohort1755M1760 1.066 0.6507 1.714
hu_birth_cohort1760M1765 0.9241 0.5841 1.456
hu_birth_cohort1765M1770 0.711 0.4597 1.118
hu_birth_cohort1770M1775 0.9091 0.5813 1.407
hu_birth_cohort1775M1780 1.048 0.6806 1.602
hu_birth_cohort1780M1785 1.009 0.6529 1.559
hu_birth_cohort1785M1790 1.215 0.8027 1.835
hu_birth_cohort1790M1795 1.457 0.9783 2.153
hu_birth_cohort1795M1800 1.227 0.8328 1.778
hu_birth_cohort1800M1805 1.11 0.7518 1.621
hu_birth_cohort1805M1810 1.04 0.7092 1.513
hu_birth_cohort1810M1815 1.086 0.739 1.578
hu_birth_cohort1815M1820 0.9143 0.6272 1.304
hu_birth_cohort1820M1825 0.8137 0.563 1.168
hu_birth_cohort1825M1830 0.8051 0.552 1.15
hu_birth_cohort1830M1835 0.8153 0.558 1.17
hu_birth_cohort1835M1840 0.7899 0.5465 1.133
hu_birth_cohort1840M1845 0.79 0.5424 1.14
hu_birth_cohort1845M1850 0.8247 0.5714 1.176
hu_paternalage.mean 0.7614 0.7214 0.8043

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.92 [1.48;2.44] [1.63;2.25]
estimate father 35y 1.53 [1.15;1.99] [1.28;1.82]
percentage change -20.42 [-23.68;-17.37] [-22.48;-18.39]
OR/IRR 0.97 [0.95;0.98] [0.96;0.97]
OR hurdle 1.38 [1.33;1.44] [1.35;1.42]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37       1105 1.01
## sd(hu_Intercept)     0.82      0.02     0.79     0.85       1204 1.00
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.35      0.08     1.20     1.52        108
## paternalage                   0.00      0.02    -0.05     0.04       1180
## birth_cohort1750M1755        -0.18      0.11    -0.41     0.05        461
## birth_cohort1755M1760         0.08      0.09    -0.11     0.26        245
## birth_cohort1760M1765         0.14      0.09    -0.03     0.30        150
## birth_cohort1765M1770         0.09      0.09    -0.08     0.26        145
## birth_cohort1770M1775         0.05      0.09    -0.13     0.22        141
## birth_cohort1775M1780         0.03      0.09    -0.15     0.19        133
## birth_cohort1780M1785         0.14      0.09    -0.03     0.30        151
## birth_cohort1785M1790         0.11      0.08    -0.06     0.27        132
## birth_cohort1790M1795         0.01      0.08    -0.15     0.17        120
## birth_cohort1795M1800         0.01      0.08    -0.15     0.16        119
## birth_cohort1800M1805        -0.04      0.08    -0.20     0.12        112
## birth_cohort1805M1810        -0.02      0.08    -0.18     0.13        112
## birth_cohort1810M1815         0.00      0.08    -0.15     0.15        110
## birth_cohort1815M1820         0.05      0.08    -0.10     0.20        109
## birth_cohort1820M1825         0.07      0.08    -0.08     0.22        108
## birth_cohort1825M1830         0.03      0.08    -0.12     0.18        110
## birth_cohort1830M1835         0.06      0.08    -0.09     0.20        109
## birth_cohort1835M1840         0.05      0.08    -0.10     0.20        109
## birth_cohort1840M1845         0.03      0.08    -0.12     0.18        109
## birth_cohort1845M1850         0.04      0.08    -0.11     0.19        110
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.03      0.03    -0.03     0.08       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       2516
## paternalage.mean              0.01      0.02    -0.03     0.05       1211
## paternal_loss01               0.06      0.04    -0.02     0.13       3000
## paternal_loss15               0.02      0.02    -0.02     0.07       1148
## paternal_loss510             -0.02      0.02    -0.06     0.02        842
## paternal_loss1015            -0.02      0.02    -0.06     0.02        813
## paternal_loss1520            -0.07      0.02    -0.11    -0.04        888
## paternal_loss2025            -0.03      0.02    -0.06     0.00        910
## paternal_loss2530            -0.02      0.01    -0.05     0.01        866
## paternal_loss3035            -0.02      0.01    -0.04     0.01        908
## paternal_loss3540             0.02      0.01     0.00     0.05       1264
## paternal_loss4045             0.03      0.01     0.00     0.05       1593
## maternal_loss01               0.07      0.05    -0.04     0.18       3000
## maternal_loss15               0.00      0.03    -0.05     0.06       2231
## maternal_loss510             -0.02      0.02    -0.07     0.03       1383
## maternal_loss1015            -0.04      0.02    -0.08     0.01       1614
## maternal_loss1520            -0.03      0.02    -0.07     0.00       1661
## maternal_loss2025            -0.07      0.02    -0.11    -0.04       1754
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1852
## maternal_loss3035            -0.02      0.01    -0.05     0.01       1579
## maternal_loss3540             0.00      0.01    -0.02     0.03       1796
## maternal_loss4045            -0.02      0.01    -0.04     0.00       3000
## older_siblings               -0.01      0.01    -0.02     0.00       1394
## nr.siblings                   0.03      0.00     0.02     0.04       1255
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                 -0.02      0.21    -0.42     0.38        143
## hu_paternalage                0.12      0.06     0.00     0.24       1033
## hu_birth_cohort1750M1755      0.36      0.29    -0.22     0.93        384
## hu_birth_cohort1755M1760      0.07      0.25    -0.42     0.57        238
## hu_birth_cohort1760M1765     -0.05      0.24    -0.51     0.40        203
## hu_birth_cohort1765M1770     -0.34      0.23    -0.79     0.09        183
## hu_birth_cohort1770M1775     -0.11      0.24    -0.56     0.34        191
## hu_birth_cohort1775M1780      0.04      0.23    -0.40     0.48        170
## hu_birth_cohort1780M1785     -0.01      0.23    -0.46     0.43        162
## hu_birth_cohort1785M1790      0.13      0.22    -0.29     0.55        156
## hu_birth_cohort1790M1795      0.31      0.21    -0.10     0.70        145
## hu_birth_cohort1795M1800      0.12      0.21    -0.29     0.50        146
## hu_birth_cohort1800M1805      0.03      0.21    -0.36     0.43        139
## hu_birth_cohort1805M1810     -0.01      0.20    -0.41     0.37        144
## hu_birth_cohort1810M1815      0.06      0.20    -0.33     0.44        142
## hu_birth_cohort1815M1820     -0.11      0.20    -0.49     0.27        139
## hu_birth_cohort1820M1825     -0.21      0.20    -0.60     0.16        137
## hu_birth_cohort1825M1830     -0.21      0.20    -0.58     0.17        137
## hu_birth_cohort1830M1835     -0.19      0.20    -0.57     0.18        137
## hu_birth_cohort1835M1840     -0.21      0.20    -0.60     0.17        136
## hu_birth_cohort1840M1845     -0.20      0.20    -0.58     0.18        136
## hu_birth_cohort1845M1850     -0.16      0.20    -0.54     0.22        137
## hu_male1                      0.04      0.02     0.01     0.08       3000
## hu_maternalage.factor1020     0.06      0.09    -0.11     0.24       3000
## hu_maternalage.factor3559     0.07      0.03     0.01     0.13       3000
## hu_paternalage.mean          -0.15      0.06    -0.27    -0.02       1095
## hu_paternal_loss01            0.87      0.09     0.68     1.06       3000
## hu_paternal_loss15            0.67      0.06     0.54     0.79       1283
## hu_paternal_loss510           0.69      0.05     0.58     0.79        997
## hu_paternal_loss1015          0.52      0.05     0.43     0.62        919
## hu_paternal_loss1520          0.42      0.05     0.33     0.51       1019
## hu_paternal_loss2025          0.32      0.04     0.23     0.41       1325
## hu_paternal_loss2530          0.23      0.04     0.15     0.31        827
## hu_paternal_loss3035          0.16      0.04     0.08     0.24       1000
## hu_paternal_loss3540          0.12      0.04     0.05     0.19       1397
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       3000
## hu_maternal_loss01            1.86      0.12     1.63     2.09       3000
## hu_maternal_loss15            1.02      0.07     0.88     1.15       3000
## hu_maternal_loss510           0.86      0.06     0.75     0.97       3000
## hu_maternal_loss1015          0.80      0.06     0.70     0.91       3000
## hu_maternal_loss1520          0.67      0.05     0.57     0.76       3000
## hu_maternal_loss2025          0.46      0.05     0.37     0.55       3000
## hu_maternal_loss2530          0.31      0.04     0.23     0.39       3000
## hu_maternal_loss3035          0.24      0.04     0.17     0.32       2036
## hu_maternal_loss3540          0.14      0.03     0.08     0.21       2019
## hu_maternal_loss4045          0.07      0.03     0.00     0.14       3000
## hu_older_siblings            -0.04      0.01    -0.07    -0.01       1074
## hu_nr.siblings                0.06      0.01     0.04     0.07       1223
## hu_last_born1                 0.01      0.03    -0.04     0.06       3000
##                           Rhat
## Intercept                 1.06
## paternalage               1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.03
## birth_cohort1760M1765     1.05
## birth_cohort1765M1770     1.05
## birth_cohort1770M1775     1.05
## birth_cohort1775M1780     1.06
## birth_cohort1780M1785     1.05
## birth_cohort1785M1790     1.06
## birth_cohort1790M1795     1.06
## birth_cohort1795M1800     1.06
## birth_cohort1800M1805     1.06
## birth_cohort1805M1810     1.07
## birth_cohort1810M1815     1.07
## birth_cohort1815M1820     1.07
## birth_cohort1820M1825     1.07
## birth_cohort1825M1830     1.07
## birth_cohort1830M1835     1.07
## birth_cohort1835M1840     1.07
## birth_cohort1840M1845     1.07
## birth_cohort1845M1850     1.07
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.00
## paternal_loss2025         1.00
## paternal_loss2530         1.00
## 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
## older_siblings            1.00
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.03
## hu_paternalage            1.01
## hu_birth_cohort1750M1755  1.01
## hu_birth_cohort1755M1760  1.02
## hu_birth_cohort1760M1765  1.02
## hu_birth_cohort1765M1770  1.02
## hu_birth_cohort1770M1775  1.02
## 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_birth_cohort1835M1840  1.03
## hu_birth_cohort1840M1845  1.03
## hu_birth_cohort1845M1850  1.03
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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.00
## hu_paternal_loss2530      1.01
## 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_siblings         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 3.856 3.309 4.551
paternalage 0.9974 0.9549 1.041
birth_cohort1750M1755 0.8383 0.6667 1.047
birth_cohort1755M1760 1.079 0.8984 1.294
birth_cohort1760M1765 1.146 0.9669 1.352
birth_cohort1765M1770 1.092 0.9186 1.297
birth_cohort1770M1775 1.047 0.8802 1.248
birth_cohort1775M1780 1.032 0.865 1.215
birth_cohort1780M1785 1.147 0.9715 1.354
birth_cohort1785M1790 1.117 0.9452 1.31
birth_cohort1790M1795 1.01 0.8609 1.184
birth_cohort1795M1800 1.009 0.8598 1.178
birth_cohort1800M1805 0.9621 0.8219 1.124
birth_cohort1805M1810 0.9757 0.8372 1.133
birth_cohort1810M1815 1 0.8583 1.158
birth_cohort1815M1820 1.052 0.9045 1.217
birth_cohort1820M1825 1.074 0.9229 1.244
birth_cohort1825M1830 1.03 0.8851 1.193
birth_cohort1830M1835 1.057 0.9094 1.224
birth_cohort1835M1840 1.056 0.9075 1.225
birth_cohort1840M1845 1.031 0.8827 1.196
birth_cohort1845M1850 1.042 0.894 1.211
male1 1.041 1.027 1.055
maternalage.factor1020 1.028 0.9708 1.088
maternalage.factor3559 1.061 1.039 1.084
paternalage.mean 1.01 0.9657 1.056
paternal_loss01 1.059 0.9827 1.136
paternal_loss15 1.024 0.9774 1.073
paternal_loss510 0.9785 0.9378 1.019
paternal_loss1015 0.9796 0.9432 1.016
paternal_loss1520 0.9281 0.8972 0.9603
paternal_loss2025 0.9719 0.9422 1.003
paternal_loss2530 0.9794 0.9508 1.009
paternal_loss3035 0.9849 0.9588 1.012
paternal_loss3540 1.022 0.9956 1.049
paternal_loss4045 1.029 1.002 1.055
maternal_loss01 1.071 0.9591 1.191
maternal_loss15 1.004 0.95 1.059
maternal_loss510 0.9797 0.9358 1.026
maternal_loss1015 0.9655 0.9258 1.01
maternal_loss1520 0.9657 0.9287 1.005
maternal_loss2025 0.9323 0.8999 0.9648
maternal_loss2530 0.9737 0.9447 1.004
maternal_loss3035 0.98 0.9544 1.006
maternal_loss3540 1.003 0.979 1.026
maternal_loss4045 0.9814 0.9592 1.004
older_siblings 0.9912 0.9812 1.001
nr.siblings 1.03 1.024 1.036
last_born1 0.9809 0.9612 0.9999
hu_Intercept 0.9778 0.6543 1.462
hu_paternalage 1.128 0.9954 1.277
hu_birth_cohort1750M1755 1.435 0.805 2.54
hu_birth_cohort1755M1760 1.078 0.6577 1.765
hu_birth_cohort1760M1765 0.9509 0.6026 1.497
hu_birth_cohort1765M1770 0.7117 0.4542 1.093
hu_birth_cohort1770M1775 0.8959 0.5696 1.4
hu_birth_cohort1775M1780 1.045 0.6683 1.615
hu_birth_cohort1780M1785 0.9886 0.6342 1.541
hu_birth_cohort1785M1790 1.141 0.7469 1.73
hu_birth_cohort1790M1795 1.364 0.9088 2.011
hu_birth_cohort1795M1800 1.123 0.749 1.655
hu_birth_cohort1800M1805 1.032 0.697 1.531
hu_birth_cohort1805M1810 0.9887 0.6665 1.45
hu_birth_cohort1810M1815 1.063 0.7182 1.555
hu_birth_cohort1815M1820 0.8982 0.6157 1.306
hu_birth_cohort1820M1825 0.8114 0.5501 1.179
hu_birth_cohort1825M1830 0.8117 0.5599 1.189
hu_birth_cohort1830M1835 0.826 0.5671 1.202
hu_birth_cohort1835M1840 0.8097 0.5508 1.185
hu_birth_cohort1840M1845 0.8196 0.5574 1.196
hu_birth_cohort1845M1850 0.8512 0.5822 1.24
hu_male1 1.046 1.006 1.086
hu_maternalage.factor1020 1.062 0.8924 1.271
hu_maternalage.factor3559 1.072 1.013 1.135
hu_paternalage.mean 0.8638 0.7646 0.979
hu_paternal_loss01 2.381 1.984 2.885
hu_paternal_loss15 1.951 1.722 2.204
hu_paternal_loss510 1.989 1.793 2.21
hu_paternal_loss1015 1.684 1.532 1.856
hu_paternal_loss1520 1.528 1.396 1.668
hu_paternal_loss2025 1.38 1.265 1.507
hu_paternal_loss2530 1.254 1.158 1.358
hu_paternal_loss3035 1.172 1.087 1.266
hu_paternal_loss3540 1.126 1.047 1.213
hu_paternal_loss4045 1.04 0.9622 1.124
hu_maternal_loss01 6.408 5.085 8.088
hu_maternal_loss15 2.781 2.413 3.173
hu_maternal_loss510 2.367 2.116 2.649
hu_maternal_loss1015 2.231 2.007 2.488
hu_maternal_loss1520 1.952 1.776 2.149
hu_maternal_loss2025 1.578 1.444 1.73
hu_maternal_loss2530 1.367 1.255 1.481
hu_maternal_loss3035 1.276 1.185 1.374
hu_maternal_loss3540 1.153 1.079 1.234
hu_maternal_loss4045 1.077 1.004 1.151
hu_older_siblings 0.961 0.9344 0.99
hu_nr.siblings 1.058 1.041 1.076
hu_last_born1 1.012 0.9606 1.066

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.34 [1.82;2.93] [1.98;2.72]
estimate father 35y 2.2 [1.7;2.77] [1.85;2.58]
percentage change -6.02 [-12.94;1.64] [-10.49;-1.35]
OR/IRR 1 [0.95;1.04] [0.97;1.03]
OR hurdle 1.13 [1;1.28] [1.04;1.22]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.35      0.01     0.34     0.37       1254    1
## sd(hu_Intercept)     0.85      0.02     0.82     0.89        978    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.31      0.08     1.15     1.46        351
## paternalage                  -0.04      0.01    -0.06    -0.02       3000
## birth_cohort1750M1755        -0.17      0.12    -0.40     0.05       1088
## birth_cohort1755M1760         0.09      0.09    -0.10     0.27        562
## birth_cohort1760M1765         0.15      0.09    -0.02     0.32        424
## birth_cohort1765M1770         0.10      0.09    -0.07     0.27        388
## birth_cohort1770M1775         0.06      0.09    -0.11     0.24        417
## birth_cohort1775M1780         0.05      0.08    -0.12     0.21        390
## birth_cohort1780M1785         0.16      0.09    -0.01     0.32        398
## birth_cohort1785M1790         0.12      0.08    -0.03     0.28        353
## birth_cohort1790M1795         0.02      0.08    -0.14     0.18        363
## birth_cohort1795M1800         0.02      0.08    -0.13     0.18        336
## birth_cohort1800M1805        -0.02      0.08    -0.17     0.13        354
## birth_cohort1805M1810        -0.01      0.08    -0.16     0.14        331
## birth_cohort1810M1815         0.02      0.08    -0.13     0.17        336
## birth_cohort1815M1820         0.07      0.07    -0.08     0.21        326
## birth_cohort1820M1825         0.08      0.08    -0.06     0.23        326
## birth_cohort1825M1830         0.04      0.08    -0.10     0.19        323
## birth_cohort1830M1835         0.07      0.08    -0.07     0.22        319
## birth_cohort1835M1840         0.07      0.08    -0.08     0.22        321
## birth_cohort1840M1845         0.05      0.08    -0.10     0.20        314
## birth_cohort1845M1850         0.05      0.08    -0.09     0.20        321
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.04      0.03    -0.02     0.10       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       3000
## paternalage.mean              0.05      0.01     0.02     0.07       3000
## paternal_loss01               0.07      0.04     0.00     0.14       3000
## paternal_loss15               0.02      0.03    -0.03     0.07       3000
## paternal_loss510             -0.02      0.02    -0.06     0.02       2390
## paternal_loss1015            -0.02      0.02    -0.06     0.02       1974
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       2105
## paternal_loss2025            -0.03      0.02    -0.06     0.00       1924
## paternal_loss2530            -0.02      0.02    -0.05     0.01       2067
## paternal_loss3035            -0.02      0.01    -0.04     0.01       2040
## paternal_loss3540             0.02      0.01     0.00     0.05       2308
## paternal_loss4045             0.03      0.01     0.00     0.05       3000
## maternal_loss01               0.08      0.05    -0.03     0.19       3000
## maternal_loss15               0.00      0.03    -0.05     0.06       3000
## maternal_loss510             -0.02      0.02    -0.07     0.03       3000
## maternal_loss1015            -0.04      0.02    -0.08     0.01       3000
## maternal_loss1520            -0.03      0.02    -0.07     0.01       3000
## maternal_loss2025            -0.07      0.02    -0.10    -0.03       3000
## maternal_loss2530            -0.03      0.02    -0.06     0.00       3000
## maternal_loss3035            -0.02      0.01    -0.05     0.01       3000
## maternal_loss3540             0.00      0.01    -0.02     0.03       3000
## maternal_loss4045            -0.02      0.01    -0.04     0.01       3000
## nr.siblings                   0.02      0.00     0.02     0.03       2149
## dependent_sibs_f5y            0.01      0.00     0.00     0.02       3000
## hu_Intercept                 -0.16      0.20    -0.55     0.21        328
## hu_paternalage               -0.02      0.03    -0.08     0.03       3000
## hu_birth_cohort1750M1755      0.36      0.29    -0.19     0.93        962
## hu_birth_cohort1755M1760      0.10      0.25    -0.39     0.57        593
## hu_birth_cohort1760M1765     -0.04      0.22    -0.47     0.40        480
## hu_birth_cohort1765M1770     -0.33      0.22    -0.76     0.10        431
## hu_birth_cohort1770M1775     -0.09      0.23    -0.54     0.35        449
## hu_birth_cohort1775M1780      0.08      0.22    -0.33     0.51        404
## hu_birth_cohort1780M1785      0.03      0.21    -0.39     0.44        389
## hu_birth_cohort1785M1790      0.17      0.20    -0.23     0.57        350
## hu_birth_cohort1790M1795      0.34      0.20    -0.05     0.73        316
## hu_birth_cohort1795M1800      0.14      0.19    -0.24     0.52        340
## hu_birth_cohort1800M1805      0.06      0.19    -0.32     0.42        324
## hu_birth_cohort1805M1810      0.01      0.19    -0.35     0.38        312
## hu_birth_cohort1810M1815      0.09      0.19    -0.27     0.45        305
## hu_birth_cohort1815M1820     -0.09      0.18    -0.44     0.26        296
## hu_birth_cohort1820M1825     -0.21      0.18    -0.56     0.15        287
## hu_birth_cohort1825M1830     -0.20      0.18    -0.55     0.16        294
## hu_birth_cohort1830M1835     -0.17      0.18    -0.52     0.18        289
## hu_birth_cohort1835M1840     -0.19      0.18    -0.53     0.17        294
## hu_birth_cohort1840M1845     -0.18      0.18    -0.53     0.18        292
## hu_birth_cohort1845M1850     -0.15      0.18    -0.49     0.21        286
## hu_male1                      0.04      0.02     0.01     0.08       3000
## hu_maternalage.factor1020     0.13      0.09    -0.04     0.30       3000
## hu_maternalage.factor3559     0.10      0.03     0.04     0.16       3000
## hu_paternalage.mean           0.00      0.03    -0.06     0.06       3000
## hu_paternal_loss01            0.91      0.09     0.73     1.09       3000
## hu_paternal_loss15            0.67      0.06     0.55     0.80       3000
## hu_paternal_loss510           0.69      0.06     0.58     0.79       3000
## hu_paternal_loss1015          0.52      0.05     0.42     0.62       2377
## hu_paternal_loss1520          0.43      0.05     0.34     0.52       2257
## hu_paternal_loss2025          0.32      0.04     0.24     0.40       2260
## hu_paternal_loss2530          0.22      0.04     0.14     0.30       2301
## hu_paternal_loss3035          0.15      0.04     0.07     0.23       2441
## hu_paternal_loss3540          0.11      0.04     0.03     0.19       3000
## hu_paternal_loss4045          0.03      0.04    -0.04     0.11       3000
## hu_maternal_loss01            1.91      0.12     1.68     2.14       3000
## hu_maternal_loss15            1.05      0.07     0.91     1.19       3000
## hu_maternal_loss510           0.86      0.06     0.75     0.97       3000
## hu_maternal_loss1015          0.81      0.05     0.71     0.91       3000
## hu_maternal_loss1520          0.68      0.05     0.58     0.78       3000
## hu_maternal_loss2025          0.47      0.05     0.38     0.56       3000
## hu_maternal_loss2530          0.32      0.04     0.24     0.40       3000
## hu_maternal_loss3035          0.25      0.04     0.17     0.32       3000
## hu_maternal_loss3540          0.14      0.03     0.08     0.22       3000
## hu_maternal_loss4045          0.07      0.04     0.00     0.14       3000
## hu_nr.siblings                0.01      0.01     0.00     0.02       3000
## hu_dependent_sibs_f5y         0.09      0.01     0.07     0.11       3000
##                           Rhat
## Intercept                 1.02
## paternalage               1.00
## birth_cohort1750M1755     1.00
## birth_cohort1755M1760     1.01
## birth_cohort1760M1765     1.01
## birth_cohort1765M1770     1.02
## birth_cohort1770M1775     1.01
## birth_cohort1775M1780     1.01
## birth_cohort1780M1785     1.01
## birth_cohort1785M1790     1.02
## birth_cohort1790M1795     1.02
## birth_cohort1795M1800     1.01
## birth_cohort1800M1805     1.01
## 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
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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
## nr.siblings               1.00
## dependent_sibs_f5y        1.00
## hu_Intercept              1.01
## hu_paternalage            1.00
## hu_birth_cohort1750M1755  1.00
## hu_birth_cohort1755M1760  1.00
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## 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_birth_cohort1835M1840  1.01
## hu_birth_cohort1840M1845  1.01
## hu_birth_cohort1845M1850  1.01
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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 3.707 3.17 4.309
paternalage 0.961 0.9413 0.9811
birth_cohort1750M1755 0.8401 0.6683 1.051
birth_cohort1755M1760 1.096 0.9062 1.308
birth_cohort1760M1765 1.161 0.9777 1.381
birth_cohort1765M1770 1.103 0.9338 1.305
birth_cohort1770M1775 1.062 0.8931 1.267
birth_cohort1775M1780 1.048 0.8891 1.235
birth_cohort1780M1785 1.168 0.9903 1.379
birth_cohort1785M1790 1.133 0.9681 1.328
birth_cohort1790M1795 1.024 0.8735 1.201
birth_cohort1795M1800 1.023 0.8775 1.197
birth_cohort1800M1805 0.9761 0.8414 1.142
birth_cohort1805M1810 0.9904 0.854 1.155
birth_cohort1810M1815 1.016 0.8777 1.18
birth_cohort1815M1820 1.068 0.9253 1.238
birth_cohort1820M1825 1.086 0.9412 1.261
birth_cohort1825M1830 1.043 0.9036 1.209
birth_cohort1830M1835 1.071 0.9287 1.245
birth_cohort1835M1840 1.071 0.9276 1.241
birth_cohort1840M1845 1.046 0.9058 1.216
birth_cohort1845M1850 1.055 0.9156 1.226
male1 1.041 1.027 1.055
maternalage.factor1020 1.039 0.9781 1.102
maternalage.factor3559 1.064 1.043 1.087
paternalage.mean 1.049 1.024 1.073
paternal_loss01 1.072 0.9996 1.152
paternal_loss15 1.022 0.9713 1.073
paternal_loss510 0.9791 0.9408 1.021
paternal_loss1015 0.9808 0.9449 1.018
paternal_loss1520 0.9294 0.8966 0.9606
paternal_loss2025 0.9715 0.9415 1.003
paternal_loss2530 0.9795 0.9504 1.008
paternal_loss3035 0.9843 0.9579 1.011
paternal_loss3540 1.022 0.9966 1.049
paternal_loss4045 1.028 1.002 1.054
maternal_loss01 1.08 0.9716 1.204
maternal_loss15 1.002 0.9466 1.061
maternal_loss510 0.9801 0.9354 1.027
maternal_loss1015 0.9649 0.9244 1.008
maternal_loss1520 0.9673 0.9304 1.005
maternal_loss2025 0.934 0.9026 0.9677
maternal_loss2530 0.975 0.9458 1.005
maternal_loss3035 0.98 0.954 1.006
maternal_loss3540 1.003 0.9798 1.028
maternal_loss4045 0.981 0.9572 1.006
nr.siblings 1.023 1.019 1.027
dependent_sibs_f5y 1.012 1.005 1.02
hu_Intercept 0.8517 0.5769 1.239
hu_paternalage 0.9771 0.9227 1.035
hu_birth_cohort1750M1755 1.439 0.8303 2.537
hu_birth_cohort1755M1760 1.106 0.6757 1.768
hu_birth_cohort1760M1765 0.9618 0.6266 1.493
hu_birth_cohort1765M1770 0.716 0.4688 1.107
hu_birth_cohort1770M1775 0.9159 0.5839 1.425
hu_birth_cohort1775M1780 1.082 0.7155 1.658
hu_birth_cohort1780M1785 1.026 0.6768 1.545
hu_birth_cohort1785M1790 1.183 0.7984 1.766
hu_birth_cohort1790M1795 1.403 0.954 2.08
hu_birth_cohort1795M1800 1.147 0.7893 1.682
hu_birth_cohort1800M1805 1.057 0.7292 1.528
hu_birth_cohort1805M1810 1.012 0.7065 1.464
hu_birth_cohort1810M1815 1.092 0.7604 1.57
hu_birth_cohort1815M1820 0.9173 0.6425 1.302
hu_birth_cohort1820M1825 0.8133 0.5729 1.162
hu_birth_cohort1825M1830 0.8195 0.5762 1.175
hu_birth_cohort1830M1835 0.8401 0.5935 1.203
hu_birth_cohort1835M1840 0.8293 0.5861 1.188
hu_birth_cohort1840M1845 0.8356 0.5908 1.194
hu_birth_cohort1845M1850 0.8647 0.611 1.234
hu_male1 1.045 1.005 1.087
hu_maternalage.factor1020 1.142 0.9593 1.355
hu_maternalage.factor3559 1.104 1.043 1.171
hu_paternalage.mean 1.001 0.9388 1.067
hu_paternal_loss01 2.479 2.065 2.988
hu_paternal_loss15 1.963 1.741 2.222
hu_paternal_loss510 1.985 1.782 2.21
hu_paternal_loss1015 1.683 1.52 1.852
hu_paternal_loss1520 1.531 1.405 1.679
hu_paternal_loss2025 1.378 1.267 1.498
hu_paternal_loss2530 1.249 1.149 1.355
hu_paternal_loss3035 1.164 1.076 1.258
hu_paternal_loss3540 1.117 1.034 1.206
hu_paternal_loss4045 1.033 0.9581 1.116
hu_maternal_loss01 6.726 5.344 8.523
hu_maternal_loss15 2.848 2.479 3.28
hu_maternal_loss510 2.366 2.119 2.647
hu_maternal_loss1015 2.25 2.027 2.496
hu_maternal_loss1520 1.975 1.793 2.187
hu_maternal_loss2025 1.595 1.464 1.747
hu_maternal_loss2530 1.375 1.267 1.492
hu_maternal_loss3035 1.28 1.189 1.378
hu_maternal_loss3540 1.156 1.08 1.24
hu_maternal_loss4045 1.073 0.9993 1.156
hu_nr.siblings 1.014 1.003 1.025
hu_dependent_sibs_f5y 1.096 1.072 1.12

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.25 [1.79;2.76] [1.94;2.59]
estimate father 35y 2.19 [1.75;2.68] [1.9;2.51]
percentage change -2.58 [-6.01;1.07] [-4.77;-0.29]
OR/IRR 0.96 [0.94;0.98] [0.95;0.97]
OR hurdle 0.98 [0.92;1.04] [0.94;1.02]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37       1031    1
## sd(hu_Intercept)     0.82      0.02     0.79     0.85        854    1
## 
## Population-Level Effects: 
##                                 Estimate Est.Error l-95% CI u-95% CI
## Intercept                           1.31      0.08     1.15     1.45
## paternalage                        -0.05      0.02    -0.09    -0.02
## birth_cohort1750M1755              -0.17      0.12    -0.39     0.06
## birth_cohort1755M1760               0.10      0.10    -0.09     0.29
## birth_cohort1760M1765               0.15      0.08     0.00     0.33
## birth_cohort1765M1770               0.11      0.09    -0.05     0.28
## birth_cohort1770M1775               0.07      0.09    -0.10     0.24
## birth_cohort1775M1780               0.05      0.08    -0.10     0.22
## birth_cohort1780M1785               0.16      0.08     0.00     0.34
## birth_cohort1785M1790               0.13      0.08    -0.02     0.30
## birth_cohort1790M1795               0.03      0.08    -0.11     0.20
## birth_cohort1795M1800               0.03      0.08    -0.11     0.19
## birth_cohort1800M1805              -0.02      0.08    -0.16     0.14
## birth_cohort1805M1810               0.00      0.07    -0.14     0.15
## birth_cohort1810M1815               0.02      0.07    -0.12     0.17
## birth_cohort1815M1820               0.07      0.07    -0.06     0.22
## birth_cohort1820M1825               0.09      0.07    -0.05     0.24
## birth_cohort1825M1830               0.05      0.07    -0.08     0.20
## birth_cohort1830M1835               0.07      0.07    -0.06     0.22
## birth_cohort1835M1840               0.07      0.07    -0.06     0.23
## birth_cohort1840M1845               0.05      0.07    -0.08     0.21
## birth_cohort1845M1850               0.06      0.07    -0.07     0.21
## male1                               0.04      0.01     0.03     0.05
## maternalage.factor1020              0.04      0.03    -0.02     0.10
## maternalage.factor3559              0.07      0.01     0.04     0.09
## paternalage.mean                    0.06      0.02     0.02     0.10
## paternal_loss01                     0.06      0.04    -0.01     0.13
## paternal_loss15                     0.03      0.02    -0.02     0.08
## paternal_loss510                   -0.02      0.02    -0.06     0.02
## paternal_loss1015                  -0.02      0.02    -0.06     0.02
## paternal_loss1520                  -0.07      0.02    -0.11    -0.04
## paternal_loss2025                  -0.03      0.02    -0.06     0.00
## paternal_loss2530                  -0.02      0.01    -0.05     0.01
## paternal_loss3035                  -0.01      0.01    -0.04     0.01
## paternal_loss3540                   0.02      0.01     0.00     0.05
## paternal_loss4045                   0.03      0.01     0.00     0.05
## maternal_loss01                     0.07      0.06    -0.04     0.18
## maternal_loss15                     0.00      0.03    -0.05     0.06
## maternal_loss510                   -0.02      0.02    -0.07     0.02
## maternal_loss1015                  -0.04      0.02    -0.08     0.01
## maternal_loss1520                  -0.03      0.02    -0.07     0.01
## maternal_loss2025                  -0.07      0.02    -0.10    -0.03
## maternal_loss2530                  -0.03      0.01    -0.05     0.00
## maternal_loss3035                  -0.02      0.01    -0.05     0.01
## maternal_loss3540                   0.00      0.01    -0.02     0.03
## maternal_loss4045                  -0.02      0.01    -0.04     0.00
## older_siblings1                     0.03      0.02    -0.01     0.07
## older_siblings2                     0.04      0.02    -0.01     0.09
## older_siblings3                     0.05      0.03    -0.02     0.12
## older_siblings4                    -0.04      0.05    -0.12     0.05
## older_siblings5P                    0.02      0.04    -0.07     0.11
## nr.siblings                         0.02      0.00     0.02     0.03
## last_born1                         -0.02      0.01    -0.04     0.00
## older_siblings1:nr.siblings         0.00      0.00    -0.01     0.00
## older_siblings2:nr.siblings         0.00      0.00    -0.01     0.01
## older_siblings3:nr.siblings         0.00      0.00    -0.01     0.01
## older_siblings4:nr.siblings         0.01      0.01     0.00     0.02
## older_siblings5P:nr.siblings        0.00      0.00    -0.01     0.01
## hu_Intercept                       -0.06      0.20    -0.43     0.34
## hu_paternalage                      0.04      0.06    -0.07     0.14
## hu_birth_cohort1750M1755            0.34      0.28    -0.25     0.90
## hu_birth_cohort1755M1760            0.08      0.24    -0.40     0.54
## hu_birth_cohort1760M1765           -0.05      0.23    -0.52     0.37
## hu_birth_cohort1765M1770           -0.35      0.22    -0.79     0.09
## hu_birth_cohort1770M1775           -0.11      0.23    -0.59     0.32
## hu_birth_cohort1775M1780            0.05      0.22    -0.39     0.45
## hu_birth_cohort1780M1785           -0.02      0.22    -0.47     0.40
## hu_birth_cohort1785M1790            0.13      0.21    -0.30     0.52
## hu_birth_cohort1790M1795            0.31      0.20    -0.11     0.67
## hu_birth_cohort1795M1800            0.11      0.19    -0.30     0.47
## hu_birth_cohort1800M1805            0.03      0.19    -0.39     0.39
## hu_birth_cohort1805M1810           -0.02      0.19    -0.43     0.34
## hu_birth_cohort1810M1815            0.06      0.19    -0.34     0.40
## hu_birth_cohort1815M1820           -0.11      0.19    -0.51     0.23
## hu_birth_cohort1820M1825           -0.21      0.19    -0.62     0.12
## hu_birth_cohort1825M1830           -0.21      0.18    -0.61     0.13
## hu_birth_cohort1830M1835           -0.20      0.19    -0.61     0.14
## hu_birth_cohort1835M1840           -0.22      0.19    -0.62     0.12
## hu_birth_cohort1840M1845           -0.21      0.19    -0.61     0.13
## hu_birth_cohort1845M1850           -0.17      0.19    -0.57     0.17
## hu_male1                            0.04      0.02     0.00     0.08
## hu_maternalage.factor1020           0.04      0.09    -0.14     0.22
## hu_maternalage.factor3559           0.06      0.03     0.01     0.12
## hu_paternalage.mean                -0.06      0.06    -0.17     0.05
## hu_paternal_loss01                  0.86      0.09     0.67     1.03
## hu_paternal_loss15                  0.67      0.06     0.54     0.79
## hu_paternal_loss510                 0.69      0.05     0.58     0.79
## hu_paternal_loss1015                0.52      0.05     0.43     0.62
## hu_paternal_loss1520                0.42      0.05     0.33     0.51
## hu_paternal_loss2025                0.32      0.04     0.24     0.40
## hu_paternal_loss2530                0.23      0.04     0.14     0.30
## hu_paternal_loss3035                0.16      0.04     0.09     0.23
## hu_paternal_loss3540                0.12      0.04     0.05     0.19
## hu_paternal_loss4045                0.04      0.04    -0.04     0.12
## hu_maternal_loss01                  1.85      0.12     1.61     2.08
## hu_maternal_loss15                  1.02      0.07     0.88     1.16
## hu_maternal_loss510                 0.86      0.06     0.76     0.98
## hu_maternal_loss1015                0.81      0.05     0.70     0.91
## hu_maternal_loss1520                0.67      0.05     0.58     0.77
## hu_maternal_loss2025                0.46      0.04     0.37     0.54
## hu_maternal_loss2530                0.31      0.04     0.23     0.39
## hu_maternal_loss3035                0.25      0.04     0.17     0.32
## hu_maternal_loss3540                0.14      0.03     0.08     0.21
## hu_maternal_loss4045                0.08      0.03     0.01     0.15
## hu_older_siblings1                 -0.08      0.05    -0.17     0.02
## hu_older_siblings2                  0.07      0.07    -0.07     0.20
## hu_older_siblings3                  0.05      0.09    -0.13     0.23
## hu_older_siblings4                  0.04      0.12    -0.21     0.28
## hu_older_siblings5P                -0.11      0.12    -0.36     0.12
## hu_nr.siblings                      0.05      0.01     0.03     0.07
## hu_last_born1                       0.00      0.03    -0.05     0.06
## hu_older_siblings1:nr.siblings      0.01      0.01    -0.01     0.03
## hu_older_siblings2:nr.siblings     -0.02      0.01    -0.04     0.00
## hu_older_siblings3:nr.siblings     -0.02      0.01    -0.04     0.01
## hu_older_siblings4:nr.siblings     -0.02      0.02    -0.05     0.01
## hu_older_siblings5P:nr.siblings     0.00      0.01    -0.03     0.02
##                                 Eff.Sample Rhat
## Intercept                              187 1.02
## paternalage                           1071 1.00
## birth_cohort1750M1755                  595 1.01
## birth_cohort1755M1760                  299 1.02
## birth_cohort1760M1765                  225 1.02
## birth_cohort1765M1770                  224 1.02
## birth_cohort1770M1775                  219 1.02
## birth_cohort1775M1780                  217 1.02
## birth_cohort1780M1785                  224 1.02
## birth_cohort1785M1790                  216 1.02
## birth_cohort1790M1795                  194 1.02
## birth_cohort1795M1800                  187 1.02
## birth_cohort1800M1805                  183 1.03
## birth_cohort1805M1810                  184 1.02
## birth_cohort1810M1815                  184 1.02
## birth_cohort1815M1820                  176 1.03
## birth_cohort1820M1825                  179 1.03
## birth_cohort1825M1830                  177 1.03
## birth_cohort1830M1835                  174 1.03
## birth_cohort1835M1840                  176 1.03
## birth_cohort1840M1845                  174 1.03
## birth_cohort1845M1850                  175 1.03
## male1                                 3000 1.00
## maternalage.factor1020                3000 1.00
## maternalage.factor3559                2118 1.00
## paternalage.mean                      1162 1.00
## paternal_loss01                       1864 1.00
## paternal_loss15                       1454 1.00
## paternal_loss510                      1354 1.00
## paternal_loss1015                     1247 1.00
## paternal_loss1520                     1064 1.00
## paternal_loss2025                     1192 1.00
## paternal_loss2530                     1233 1.00
## paternal_loss3035                     1324 1.00
## paternal_loss3540                     1517 1.00
## paternal_loss4045                     1782 1.00
## maternal_loss01                       3000 1.00
## maternal_loss15                       1932 1.00
## maternal_loss510                      1796 1.00
## maternal_loss1015                     1711 1.00
## maternal_loss1520                     1960 1.00
## maternal_loss2025                     1890 1.00
## maternal_loss2530                     1720 1.00
## maternal_loss3035                     1855 1.00
## maternal_loss3540                     2211 1.00
## maternal_loss4045                     3000 1.00
## older_siblings1                       1496 1.00
## older_siblings2                       1084 1.00
## older_siblings3                       1177 1.00
## older_siblings4                       1173 1.00
## older_siblings5P                      1148 1.00
## nr.siblings                           2319 1.00
## last_born1                            3000 1.00
## older_siblings1:nr.siblings           3000 1.00
## older_siblings2:nr.siblings           3000 1.00
## older_siblings3:nr.siblings           3000 1.00
## older_siblings4:nr.siblings           1596 1.00
## older_siblings5P:nr.siblings          1873 1.00
## hu_Intercept                            47 1.08
## hu_paternalage                        1146 1.00
## hu_birth_cohort1750M1755               427 1.03
## hu_birth_cohort1755M1760                48 1.06
## hu_birth_cohort1760M1765                57 1.07
## hu_birth_cohort1765M1770               157 1.07
## hu_birth_cohort1770M1775                59 1.06
## hu_birth_cohort1775M1780                78 1.07
## hu_birth_cohort1780M1785                36 1.07
## hu_birth_cohort1785M1790                23 1.08
## hu_birth_cohort1790M1795                31 1.09
## hu_birth_cohort1795M1800                29 1.10
## hu_birth_cohort1800M1805                30 1.09
## hu_birth_cohort1805M1810                30 1.09
## hu_birth_cohort1810M1815                29 1.09
## hu_birth_cohort1815M1820                30 1.09
## hu_birth_cohort1820M1825                29 1.09
## hu_birth_cohort1825M1830                25 1.10
## hu_birth_cohort1830M1835                29 1.09
## hu_birth_cohort1835M1840                29 1.10
## hu_birth_cohort1840M1845                42 1.09
## hu_birth_cohort1845M1850                29 1.10
## hu_male1                              3000 1.00
## hu_maternalage.factor1020             3000 1.00
## hu_maternalage.factor3559             3000 1.00
## hu_paternalage.mean                   1165 1.00
## hu_paternal_loss01                    3000 1.00
## hu_paternal_loss15                    1574 1.00
## hu_paternal_loss510                   3000 1.00
## hu_paternal_loss1015                  1329 1.00
## hu_paternal_loss1520                  1206 1.00
## hu_paternal_loss2025                  1121 1.00
## hu_paternal_loss2530                  1206 1.00
## hu_paternal_loss3035                  1274 1.00
## hu_paternal_loss3540                  1470 1.00
## hu_paternal_loss4045                  3000 1.00
## hu_maternal_loss01                    3000 1.00
## hu_maternal_loss15                    3000 1.00
## hu_maternal_loss510                   3000 1.00
## hu_maternal_loss1015                  3000 1.00
## hu_maternal_loss1520                  3000 1.00
## hu_maternal_loss2025                  3000 1.00
## hu_maternal_loss2530                  3000 1.00
## hu_maternal_loss3035                  3000 1.00
## hu_maternal_loss3540                  2099 1.00
## hu_maternal_loss4045                  3000 1.00
## hu_older_siblings1                    1914 1.00
## hu_older_siblings2                    1842 1.00
## hu_older_siblings3                    1454 1.01
## hu_older_siblings4                    1602 1.00
## hu_older_siblings5P                   1310 1.00
## hu_nr.siblings                        1932 1.00
## hu_last_born1                         3000 1.00
## hu_older_siblings1:nr.siblings        2379 1.00
## hu_older_siblings2:nr.siblings        2459 1.00
## hu_older_siblings3:nr.siblings        2140 1.00
## hu_older_siblings4:nr.siblings        2091 1.00
## hu_older_siblings5P:nr.siblings       1869 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 3.703 3.153 4.265
paternalage 0.9473 0.9109 0.9845
birth_cohort1750M1755 0.8474 0.676 1.063
birth_cohort1755M1760 1.105 0.9182 1.335
birth_cohort1760M1765 1.166 0.9983 1.389
birth_cohort1765M1770 1.111 0.9484 1.328
birth_cohort1770M1775 1.068 0.906 1.273
birth_cohort1775M1780 1.054 0.9026 1.251
birth_cohort1780M1785 1.174 1.005 1.4
birth_cohort1785M1790 1.14 0.9814 1.345
birth_cohort1790M1795 1.031 0.8922 1.218
birth_cohort1795M1800 1.029 0.8915 1.205
birth_cohort1800M1805 0.9806 0.8502 1.147
birth_cohort1805M1810 0.9956 0.8694 1.164
birth_cohort1810M1815 1.02 0.8892 1.191
birth_cohort1815M1820 1.076 0.9396 1.252
birth_cohort1820M1825 1.094 0.9554 1.276
birth_cohort1825M1830 1.05 0.9204 1.223
birth_cohort1830M1835 1.077 0.9413 1.252
birth_cohort1835M1840 1.076 0.9422 1.255
birth_cohort1840M1845 1.053 0.9219 1.231
birth_cohort1845M1850 1.061 0.93 1.234
male1 1.041 1.027 1.054
maternalage.factor1020 1.036 0.9772 1.103
maternalage.factor3559 1.067 1.044 1.092
paternalage.mean 1.062 1.019 1.105
paternal_loss01 1.063 0.9902 1.14
paternal_loss15 1.028 0.9769 1.079
paternal_loss510 0.9815 0.941 1.024
paternal_loss1015 0.9812 0.9463 1.02
paternal_loss1520 0.9303 0.8987 0.9629
paternal_loss2025 0.9729 0.942 1.004
paternal_loss2530 0.9797 0.9509 1.008
paternal_loss3035 0.9854 0.9591 1.014
paternal_loss3540 1.022 0.9966 1.048
paternal_loss4045 1.029 1.003 1.055
maternal_loss01 1.07 0.9587 1.193
maternal_loss15 1.003 0.9493 1.06
maternal_loss510 0.981 0.936 1.025
maternal_loss1015 0.9647 0.9239 1.009
maternal_loss1520 0.9661 0.9304 1.005
maternal_loss2025 0.9328 0.901 0.9661
maternal_loss2530 0.9739 0.9467 1.004
maternal_loss3035 0.9796 0.9542 1.006
maternal_loss3540 1.002 0.9778 1.026
maternal_loss4045 0.9806 0.9578 1.005
older_siblings1 1.031 0.9945 1.069
older_siblings2 1.038 0.9905 1.09
older_siblings3 1.052 0.9838 1.124
older_siblings4 0.9639 0.8847 1.053
older_siblings5P 1.018 0.9338 1.111
nr.siblings 1.025 1.019 1.031
last_born1 0.9796 0.9612 0.9984
older_siblings1:nr.siblings 0.9969 0.9903 1.004
older_siblings2:nr.siblings 0.9982 0.991 1.006
older_siblings3:nr.siblings 0.9972 0.9883 1.007
older_siblings4:nr.siblings 1.007 0.9954 1.019
older_siblings5P:nr.siblings 1.001 0.9916 1.01
hu_Intercept 0.9398 0.6508 1.402
hu_paternalage 1.036 0.9309 1.152
hu_birth_cohort1750M1755 1.411 0.7827 2.467
hu_birth_cohort1755M1760 1.079 0.6696 1.712
hu_birth_cohort1760M1765 0.9465 0.597 1.454
hu_birth_cohort1765M1770 0.707 0.4523 1.09
hu_birth_cohort1770M1775 0.8934 0.5563 1.377
hu_birth_cohort1775M1780 1.046 0.6746 1.569
hu_birth_cohort1780M1785 0.9843 0.6249 1.495
hu_birth_cohort1785M1790 1.135 0.7394 1.689
hu_birth_cohort1790M1795 1.36 0.8975 1.953
hu_birth_cohort1795M1800 1.116 0.7411 1.592
hu_birth_cohort1800M1805 1.026 0.6749 1.471
hu_birth_cohort1805M1810 0.9847 0.6502 1.398
hu_birth_cohort1810M1815 1.058 0.7112 1.488
hu_birth_cohort1815M1820 0.8968 0.602 1.26
hu_birth_cohort1820M1825 0.807 0.5353 1.131
hu_birth_cohort1825M1830 0.8076 0.5429 1.138
hu_birth_cohort1830M1835 0.8211 0.5453 1.152
hu_birth_cohort1835M1840 0.8045 0.5389 1.131
hu_birth_cohort1840M1845 0.814 0.5407 1.14
hu_birth_cohort1845M1850 0.8463 0.5643 1.186
hu_male1 1.045 1.004 1.088
hu_maternalage.factor1020 1.045 0.8731 1.247
hu_maternalage.factor3559 1.065 1.006 1.128
hu_paternalage.mean 0.94 0.8443 1.051
hu_paternal_loss01 2.356 1.962 2.806
hu_paternal_loss15 1.947 1.723 2.194
hu_paternal_loss510 1.992 1.785 2.211
hu_paternal_loss1015 1.684 1.531 1.852
hu_paternal_loss1520 1.526 1.397 1.672
hu_paternal_loss2025 1.376 1.265 1.493
hu_paternal_loss2530 1.252 1.154 1.351
hu_paternal_loss3035 1.171 1.09 1.26
hu_paternal_loss3540 1.126 1.046 1.212
hu_paternal_loss4045 1.041 0.9624 1.124
hu_maternal_loss01 6.368 5.019 8.025
hu_maternal_loss15 2.781 2.413 3.183
hu_maternal_loss510 2.374 2.128 2.663
hu_maternal_loss1015 2.242 2.016 2.491
hu_maternal_loss1520 1.96 1.78 2.167
hu_maternal_loss2025 1.582 1.454 1.723
hu_maternal_loss2530 1.369 1.262 1.481
hu_maternal_loss3035 1.278 1.183 1.372
hu_maternal_loss3540 1.156 1.08 1.233
hu_maternal_loss4045 1.08 1.009 1.156
hu_older_siblings1 0.9241 0.8406 1.02
hu_older_siblings2 1.068 0.9341 1.221
hu_older_siblings3 1.047 0.8771 1.254
hu_older_siblings4 1.046 0.8142 1.326
hu_older_siblings5P 0.8924 0.7012 1.129
hu_nr.siblings 1.05 1.033 1.068
hu_last_born1 1.004 0.952 1.06
hu_older_siblings1:nr.siblings 1.009 0.9907 1.029
hu_older_siblings2:nr.siblings 0.9808 0.9592 1.003
hu_older_siblings3:nr.siblings 0.9842 0.9578 1.01
hu_older_siblings4:nr.siblings 0.9812 0.9494 1.013
hu_older_siblings5P:nr.siblings 0.9966 0.9697 1.024

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.22 [1.75;2.74] [1.88;2.56]
estimate father 35y 2.07 [1.61;2.58] [1.76;2.4]
percentage change -6.8 [-12.77;-0.16] [-10.81;-2.37]
OR/IRR 0.95 [0.91;0.98] [0.92;0.97]
OR hurdle 1.04 [0.93;1.15] [0.96;1.11]

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/ddb/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: 56663) 
## Samples: 6 chains, each with iter = 1500; warmup = 300; thin = 1; 
##          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: 
## ~idParents (Number of levels: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37       2585    1
## sd(hu_Intercept)     0.82      0.02     0.78     0.85       2535    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.33      0.08     1.17     1.48        225
## paternalage                  -0.04      0.01    -0.06    -0.02       4101
## birth_cohort1750M1755        -0.18      0.12    -0.41     0.05        828
## birth_cohort1755M1760         0.08      0.09    -0.10     0.27        422
## birth_cohort1760M1765         0.14      0.09    -0.03     0.31        287
## birth_cohort1765M1770         0.09      0.09    -0.08     0.27        266
## birth_cohort1770M1775         0.05      0.09    -0.12     0.22        268
## birth_cohort1775M1780         0.03      0.09    -0.13     0.20        259
## birth_cohort1780M1785         0.14      0.09    -0.02     0.31        253
## birth_cohort1785M1790         0.12      0.08    -0.04     0.28        244
## birth_cohort1790M1795         0.02      0.08    -0.14     0.17        219
## birth_cohort1795M1800         0.01      0.08    -0.14     0.16        213
## birth_cohort1800M1805        -0.03      0.08    -0.19     0.12        213
## birth_cohort1805M1810        -0.02      0.08    -0.17     0.13        205
## birth_cohort1810M1815         0.01      0.08    -0.14     0.16        204
## birth_cohort1815M1820         0.06      0.08    -0.09     0.21        200
## birth_cohort1820M1825         0.08      0.07    -0.07     0.22        197
## birth_cohort1825M1830         0.04      0.08    -0.11     0.18        199
## birth_cohort1830M1835         0.06      0.08    -0.09     0.21        197
## birth_cohort1835M1840         0.06      0.08    -0.09     0.20        195
## birth_cohort1840M1845         0.04      0.08    -0.11     0.18        197
## birth_cohort1845M1850         0.05      0.08    -0.10     0.19        198
## male1                         0.04      0.01     0.03     0.05       7200
## maternalage.factor1020        0.03      0.03    -0.03     0.09       7200
## maternalage.factor3559        0.06      0.01     0.04     0.08       7200
## paternalage.mean              0.05      0.01     0.02     0.07       4358
## paternal_loss01               0.06      0.04    -0.01     0.14       7200
## paternal_loss15               0.02      0.02    -0.03     0.07       5072
## paternal_loss510             -0.02      0.02    -0.06     0.02       4062
## paternal_loss1015            -0.02      0.02    -0.06     0.02       4105
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       3874
## paternal_loss2025            -0.03      0.02    -0.06     0.00       3732
## paternal_loss2530            -0.02      0.01    -0.05     0.01       3820
## paternal_loss3035            -0.01      0.01    -0.04     0.01       3826
## paternal_loss3540             0.02      0.01     0.00     0.05       4656
## paternal_loss4045             0.03      0.01     0.00     0.06       7200
## maternal_loss01               0.07      0.05    -0.04     0.17       7200
## maternal_loss15               0.00      0.03    -0.06     0.06       7200
## maternal_loss510             -0.02      0.02    -0.06     0.03       4941
## maternal_loss1015            -0.04      0.02    -0.08     0.01       5500
## maternal_loss1520            -0.03      0.02    -0.07     0.00       5932
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       5166
## maternal_loss2530            -0.03      0.02    -0.06     0.00       4850
## maternal_loss3035            -0.02      0.01    -0.05     0.01       5114
## maternal_loss3540             0.00      0.01    -0.02     0.03       5554
## maternal_loss4045            -0.02      0.01    -0.04     0.00       7200
## nr.siblings                   0.03      0.00     0.02     0.03       4511
## hu_Intercept                 -0.05      0.20    -0.44     0.33        282
## hu_paternalage               -0.03      0.03    -0.09     0.03       4468
## hu_birth_cohort1750M1755      0.34      0.29    -0.22     0.91        850
## hu_birth_cohort1755M1760      0.06      0.24    -0.41     0.53        481
## hu_birth_cohort1760M1765     -0.07      0.23    -0.51     0.37        354
## hu_birth_cohort1765M1770     -0.36      0.23    -0.79     0.08        371
## hu_birth_cohort1770M1775     -0.12      0.23    -0.56     0.33        377
## hu_birth_cohort1775M1780      0.03      0.22    -0.40     0.47        367
## hu_birth_cohort1780M1785     -0.03      0.22    -0.46     0.41        341
## hu_birth_cohort1785M1790      0.12      0.21    -0.28     0.52        311
## hu_birth_cohort1790M1795      0.29      0.20    -0.09     0.69        295
## hu_birth_cohort1795M1800      0.10      0.20    -0.28     0.49        279
## hu_birth_cohort1800M1805      0.02      0.19    -0.36     0.40        274
## hu_birth_cohort1805M1810     -0.03      0.19    -0.40     0.35        277
## hu_birth_cohort1810M1815      0.05      0.19    -0.31     0.43        269
## hu_birth_cohort1815M1820     -0.12      0.19    -0.47     0.26        266
## hu_birth_cohort1820M1825     -0.22      0.19    -0.58     0.15        264
## hu_birth_cohort1825M1830     -0.22      0.19    -0.58     0.15        259
## hu_birth_cohort1830M1835     -0.21      0.19    -0.56     0.17        262
## hu_birth_cohort1835M1840     -0.23      0.19    -0.58     0.15        261
## hu_birth_cohort1840M1845     -0.21      0.19    -0.57     0.16        260
## hu_birth_cohort1845M1850     -0.18      0.19    -0.53     0.20        262
## hu_male1                      0.04      0.02     0.01     0.08       7200
## hu_maternalage.factor1020     0.06      0.09    -0.11     0.24       7200
## hu_maternalage.factor3559     0.07      0.03     0.01     0.13       7200
## hu_paternalage.mean           0.00      0.03    -0.06     0.07       4621
## hu_paternal_loss01            0.87      0.09     0.68     1.05       7200
## hu_paternal_loss15            0.67      0.06     0.55     0.80       4880
## hu_paternal_loss510           0.69      0.05     0.58     0.79       4602
## hu_paternal_loss1015          0.52      0.05     0.42     0.62       4145
## hu_paternal_loss1520          0.42      0.05     0.33     0.51       3598
## hu_paternal_loss2025          0.32      0.04     0.23     0.41       3827
## hu_paternal_loss2530          0.22      0.04     0.14     0.30       3738
## hu_paternal_loss3035          0.16      0.04     0.08     0.24       4102
## hu_paternal_loss3540          0.12      0.04     0.04     0.19       4052
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       7200
## hu_maternal_loss01            1.85      0.12     1.63     2.09       7200
## hu_maternal_loss15            1.02      0.07     0.89     1.16       7200
## hu_maternal_loss510           0.86      0.06     0.76     0.98       7200
## hu_maternal_loss1015          0.81      0.05     0.70     0.92       7200
## hu_maternal_loss1520          0.67      0.05     0.57     0.77       7200
## hu_maternal_loss2025          0.46      0.05     0.37     0.55       4712
## hu_maternal_loss2530          0.31      0.04     0.23     0.39       7200
## hu_maternal_loss3035          0.24      0.04     0.17     0.32       7200
## hu_maternal_loss3540          0.14      0.04     0.07     0.21       7200
## hu_maternal_loss4045          0.07      0.04     0.01     0.14       7200
## hu_nr.siblings                0.04      0.00     0.03     0.05       6365
##                           Rhat
## Intercept                 1.02
## paternalage               1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.01
## 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.03
## birth_cohort1820M1825     1.02
## birth_cohort1825M1830     1.02
## birth_cohort1830M1835     1.03
## birth_cohort1835M1840     1.03
## birth_cohort1840M1845     1.02
## birth_cohort1845M1850     1.02
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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
## nr.siblings               1.00
## hu_Intercept              1.02
## hu_paternalage            1.00
## hu_birth_cohort1750M1755  1.00
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.01
## hu_birth_cohort1780M1785  1.01
## hu_birth_cohort1785M1790  1.02
## hu_birth_cohort1790M1795  1.02
## hu_birth_cohort1795M1800  1.02
## hu_birth_cohort1800M1805  1.02
## hu_birth_cohort1805M1810  1.02
## hu_birth_cohort1810M1815  1.02
## hu_birth_cohort1815M1820  1.02
## hu_birth_cohort1820M1825  1.02
## hu_birth_cohort1825M1830  1.02
## hu_birth_cohort1830M1835  1.02
## hu_birth_cohort1835M1840  1.02
## hu_birth_cohort1840M1845  1.02
## hu_birth_cohort1845M1850  1.02
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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 3.775 3.238 4.398
paternalage 0.9613 0.9414 0.9818
birth_cohort1750M1755 0.8386 0.6654 1.049
birth_cohort1755M1760 1.086 0.9044 1.304
birth_cohort1760M1765 1.152 0.9705 1.361
birth_cohort1765M1770 1.098 0.9274 1.304
birth_cohort1770M1775 1.054 0.8859 1.249
birth_cohort1775M1780 1.035 0.8763 1.222
birth_cohort1780M1785 1.155 0.9784 1.364
birth_cohort1785M1790 1.123 0.9561 1.318
birth_cohort1790M1795 1.015 0.8691 1.189
birth_cohort1795M1800 1.014 0.8697 1.178
birth_cohort1800M1805 0.9672 0.831 1.126
birth_cohort1805M1810 0.9808 0.8478 1.139
birth_cohort1810M1815 1.006 0.8675 1.168
birth_cohort1815M1820 1.06 0.9144 1.229
birth_cohort1820M1825 1.08 0.9328 1.251
birth_cohort1825M1830 1.036 0.8936 1.198
birth_cohort1830M1835 1.062 0.9169 1.228
birth_cohort1835M1840 1.061 0.9165 1.225
birth_cohort1840M1845 1.037 0.8952 1.2
birth_cohort1845M1850 1.046 0.9043 1.21
male1 1.041 1.027 1.055
maternalage.factor1020 1.029 0.968 1.091
maternalage.factor3559 1.06 1.038 1.083
paternalage.mean 1.048 1.023 1.073
paternal_loss01 1.066 0.9936 1.145
paternal_loss15 1.023 0.9729 1.071
paternal_loss510 0.9796 0.9399 1.02
paternal_loss1015 0.9808 0.946 1.017
paternal_loss1520 0.929 0.8982 0.9615
paternal_loss2025 0.9719 0.9423 1.002
paternal_loss2530 0.9799 0.9518 1.009
paternal_loss3035 0.9854 0.9592 1.013
paternal_loss3540 1.023 0.997 1.049
paternal_loss4045 1.029 1.003 1.057
maternal_loss01 1.073 0.9639 1.188
maternal_loss15 1 0.9462 1.058
maternal_loss510 0.9805 0.9383 1.025
maternal_loss1015 0.9652 0.9249 1.007
maternal_loss1520 0.9662 0.931 1.004
maternal_loss2025 0.932 0.9009 0.9646
maternal_loss2530 0.9736 0.9449 1.003
maternal_loss3035 0.9792 0.9526 1.006
maternal_loss3540 1.002 0.9782 1.028
maternal_loss4045 0.9807 0.9578 1.005
nr.siblings 1.026 1.023 1.029
hu_Intercept 0.9538 0.6446 1.385
hu_paternalage 0.9734 0.9168 1.032
hu_birth_cohort1750M1755 1.408 0.8031 2.476
hu_birth_cohort1755M1760 1.058 0.6626 1.701
hu_birth_cohort1760M1765 0.9337 0.6032 1.447
hu_birth_cohort1765M1770 0.6988 0.4557 1.088
hu_birth_cohort1770M1775 0.885 0.5717 1.393
hu_birth_cohort1775M1780 1.034 0.6716 1.599
hu_birth_cohort1780M1785 0.9736 0.6308 1.514
hu_birth_cohort1785M1790 1.123 0.758 1.683
hu_birth_cohort1790M1795 1.341 0.9114 1.999
hu_birth_cohort1795M1800 1.104 0.7562 1.639
hu_birth_cohort1800M1805 1.017 0.7011 1.487
hu_birth_cohort1805M1810 0.9719 0.6731 1.422
hu_birth_cohort1810M1815 1.048 0.7335 1.533
hu_birth_cohort1815M1820 0.8888 0.6235 1.295
hu_birth_cohort1820M1825 0.8007 0.5615 1.166
hu_birth_cohort1825M1830 0.799 0.5616 1.166
hu_birth_cohort1830M1835 0.8132 0.5698 1.183
hu_birth_cohort1835M1840 0.7957 0.56 1.162
hu_birth_cohort1840M1845 0.807 0.5662 1.174
hu_birth_cohort1845M1850 0.8361 0.5887 1.218
hu_male1 1.045 1.006 1.086
hu_maternalage.factor1020 1.063 0.8921 1.275
hu_maternalage.factor3559 1.073 1.015 1.137
hu_paternalage.mean 1 0.9372 1.069
hu_paternal_loss01 2.377 1.976 2.848
hu_paternal_loss15 1.956 1.727 2.218
hu_paternal_loss510 1.994 1.791 2.211
hu_paternal_loss1015 1.684 1.528 1.854
hu_paternal_loss1520 1.526 1.394 1.67
hu_paternal_loss2025 1.377 1.264 1.5
hu_paternal_loss2530 1.251 1.153 1.355
hu_paternal_loss3035 1.17 1.083 1.266
hu_paternal_loss3540 1.125 1.043 1.212
hu_paternal_loss4045 1.039 0.9615 1.122
hu_maternal_loss01 6.368 5.08 8.069
hu_maternal_loss15 2.785 2.433 3.196
hu_maternal_loss510 2.374 2.129 2.666
hu_maternal_loss1015 2.237 2.011 2.498
hu_maternal_loss1520 1.956 1.777 2.158
hu_maternal_loss2025 1.58 1.445 1.726
hu_maternal_loss2530 1.368 1.264 1.481
hu_maternal_loss3035 1.277 1.185 1.378
hu_maternal_loss3540 1.154 1.077 1.237
hu_maternal_loss4045 1.078 1.005 1.155
hu_nr.siblings 1.039 1.03 1.048

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.22 [1.75;2.79] [1.91;2.58]
estimate father 35y 2.17 [1.71;2.73] [1.86;2.52]
percentage change -2.34 [-5.78;1.32] [-4.59;0.01]
OR/IRR 0.96 [0.94;0.98] [0.95;0.97]
OR hurdle 0.97 [0.92;1.03] [0.94;1.01]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.37       1045    1
## sd(hu_Intercept)     0.87      0.02     0.84     0.91        935    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.39      0.08     1.22     1.54        263
## paternalage                  -0.07      0.02    -0.11    -0.04        854
## birth_cohort1750M1755        -0.17      0.11    -0.39     0.05        709
## birth_cohort1755M1760         0.09      0.09    -0.09     0.27        368
## birth_cohort1760M1765         0.15      0.08    -0.02     0.32        287
## birth_cohort1765M1770         0.10      0.08    -0.06     0.26        279
## birth_cohort1770M1775         0.05      0.09    -0.11     0.23        286
## birth_cohort1775M1780         0.04      0.08    -0.11     0.21        253
## birth_cohort1780M1785         0.15      0.08    -0.01     0.31        263
## birth_cohort1785M1790         0.11      0.08    -0.04     0.27        246
## birth_cohort1790M1795         0.01      0.08    -0.13     0.16        229
## birth_cohort1795M1800         0.01      0.07    -0.12     0.16        217
## birth_cohort1800M1805        -0.03      0.07    -0.18     0.12        215
## birth_cohort1805M1810        -0.02      0.07    -0.15     0.13        207
## birth_cohort1810M1815         0.01      0.07    -0.13     0.15        207
## birth_cohort1815M1820         0.06      0.07    -0.07     0.21        208
## birth_cohort1820M1825         0.08      0.07    -0.05     0.23        206
## birth_cohort1825M1830         0.04      0.07    -0.09     0.19        202
## birth_cohort1830M1835         0.06      0.07    -0.07     0.21        199
## birth_cohort1835M1840         0.07      0.07    -0.07     0.22        200
## birth_cohort1840M1845         0.04      0.07    -0.09     0.19        200
## birth_cohort1845M1850         0.05      0.07    -0.08     0.20        200
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.03      0.03    -0.03     0.09       3000
## maternalage.factor3559        0.06      0.01     0.04     0.09       3000
## paternalage.mean              0.07      0.02     0.03     0.11        876
## paternal_loss01               0.03      0.04    -0.05     0.11       3000
## paternal_losslater           -0.04      0.02    -0.09     0.00       2389
## maternal_loss01               0.07      0.06    -0.05     0.18       3000
## maternal_losslater           -0.03      0.03    -0.08     0.03       2549
## older_siblings1               0.02      0.01     0.00     0.04       1505
## older_siblings2               0.03      0.01     0.00     0.06        902
## older_siblings3               0.04      0.02     0.01     0.08        890
## older_siblings4               0.02      0.02    -0.03     0.06        857
## older_siblings5P              0.04      0.03    -0.02     0.09        827
## nr.siblings                   0.02      0.00     0.02     0.03        874
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                  1.15      0.22     0.71     1.56        136
## hu_paternalage                0.34      0.05     0.24     0.45        629
## hu_birth_cohort1750M1755      0.39      0.29    -0.17     0.96        289
## hu_birth_cohort1755M1760      0.07      0.25    -0.42     0.57        203
## hu_birth_cohort1760M1765     -0.06      0.23    -0.52     0.40        143
## hu_birth_cohort1765M1770     -0.34      0.23    -0.79     0.14        144
## hu_birth_cohort1770M1775     -0.10      0.23    -0.56     0.35        147
## hu_birth_cohort1775M1780      0.01      0.23    -0.42     0.46        135
## hu_birth_cohort1780M1785     -0.01      0.22    -0.43     0.44        145
## hu_birth_cohort1785M1790      0.18      0.22    -0.24     0.62        130
## hu_birth_cohort1790M1795      0.40      0.21     0.00     0.81        118
## hu_birth_cohort1795M1800      0.21      0.20    -0.18     0.64        116
## hu_birth_cohort1800M1805      0.10      0.20    -0.28     0.51        114
## hu_birth_cohort1805M1810      0.04      0.20    -0.33     0.45        113
## hu_birth_cohort1810M1815      0.09      0.20    -0.28     0.49        113
## hu_birth_cohort1815M1820     -0.09      0.19    -0.46     0.31        109
## hu_birth_cohort1820M1825     -0.21      0.20    -0.58     0.20        108
## hu_birth_cohort1825M1830     -0.22      0.19    -0.59     0.19        108
## hu_birth_cohort1830M1835     -0.21      0.19    -0.57     0.20        110
## hu_birth_cohort1835M1840     -0.24      0.19    -0.62     0.15        112
## hu_birth_cohort1840M1845     -0.24      0.19    -0.61     0.16        109
## hu_birth_cohort1845M1850     -0.20      0.19    -0.57     0.21        109
## hu_male1                      0.04      0.02     0.00     0.08       3000
## hu_maternalage.factor1020     0.07      0.09    -0.10     0.23       3000
## hu_maternalage.factor3559     0.07      0.03     0.01     0.12       3000
## hu_paternalage.mean          -0.30      0.06    -0.41    -0.18        642
## hu_paternal_loss01            0.19      0.10     0.00     0.38       3000
## hu_paternal_losslater        -0.31      0.06    -0.42    -0.21       3000
## hu_maternal_loss01            0.86      0.13     0.61     1.11       3000
## hu_maternal_losslater        -0.62      0.07    -0.75    -0.48       3000
## hu_older_siblings1           -0.06      0.03    -0.12     0.00       1218
## hu_older_siblings2           -0.07      0.04    -0.15     0.01        858
## hu_older_siblings3           -0.10      0.05    -0.21     0.00        606
## hu_older_siblings4           -0.15      0.06    -0.27    -0.02        614
## hu_older_siblings5P          -0.23      0.08    -0.40    -0.07        597
## hu_nr.siblings                0.04      0.01     0.03     0.06        832
## hu_last_born1                 0.01      0.03    -0.05     0.06       3000
##                           Rhat
## Intercept                 1.02
## paternalage               1.01
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     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.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
## birth_cohort1835M1840     1.03
## birth_cohort1840M1845     1.03
## birth_cohort1845M1850     1.03
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.01
## 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.02
## hu_paternalage            1.01
## hu_birth_cohort1750M1755  1.01
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.02
## hu_birth_cohort1765M1770  1.02
## hu_birth_cohort1770M1775  1.02
## hu_birth_cohort1775M1780  1.02
## hu_birth_cohort1780M1785  1.02
## hu_birth_cohort1785M1790  1.02
## hu_birth_cohort1790M1795  1.02
## hu_birth_cohort1795M1800  1.02
## hu_birth_cohort1800M1805  1.02
## hu_birth_cohort1805M1810  1.02
## hu_birth_cohort1810M1815  1.02
## hu_birth_cohort1815M1820  1.03
## hu_birth_cohort1820M1825  1.03
## hu_birth_cohort1825M1830  1.03
## hu_birth_cohort1830M1835  1.02
## hu_birth_cohort1835M1840  1.02
## hu_birth_cohort1840M1845  1.03
## hu_birth_cohort1845M1850  1.03
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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 4.005 3.39 4.686
paternalage 0.9298 0.8971 0.965
birth_cohort1750M1755 0.8442 0.6754 1.047
birth_cohort1755M1760 1.092 0.9163 1.308
birth_cohort1760M1765 1.158 0.9834 1.373
birth_cohort1765M1770 1.1 0.9407 1.293
birth_cohort1770M1775 1.055 0.8918 1.254
birth_cohort1775M1780 1.043 0.8924 1.229
birth_cohort1780M1785 1.161 0.9949 1.364
birth_cohort1785M1790 1.122 0.9621 1.314
birth_cohort1790M1795 1.012 0.8787 1.177
birth_cohort1795M1800 1.014 0.8828 1.177
birth_cohort1800M1805 0.967 0.836 1.123
birth_cohort1805M1810 0.9831 0.859 1.144
birth_cohort1810M1815 1.011 0.8796 1.167
birth_cohort1815M1820 1.064 0.9305 1.236
birth_cohort1820M1825 1.083 0.9472 1.258
birth_cohort1825M1830 1.04 0.9098 1.208
birth_cohort1830M1835 1.066 0.9322 1.239
birth_cohort1835M1840 1.068 0.9356 1.242
birth_cohort1840M1845 1.045 0.9145 1.215
birth_cohort1845M1850 1.052 0.9196 1.221
male1 1.041 1.027 1.055
maternalage.factor1020 1.032 0.9712 1.092
maternalage.factor3559 1.065 1.042 1.089
paternalage.mean 1.075 1.035 1.116
paternal_loss01 1.032 0.9538 1.113
paternal_losslater 0.9563 0.9163 0.9983
maternal_loss01 1.068 0.9528 1.193
maternal_losslater 0.9741 0.9237 1.03
older_siblings1 1.019 0.9968 1.041
older_siblings2 1.033 1.005 1.061
older_siblings3 1.043 1.007 1.08
older_siblings4 1.018 0.9737 1.062
older_siblings5P 1.036 0.9801 1.095
nr.siblings 1.023 1.018 1.029
last_born1 0.9787 0.9608 0.9968
hu_Intercept 3.147 2.04 4.78
hu_paternalage 1.411 1.268 1.575
hu_birth_cohort1750M1755 1.482 0.8408 2.608
hu_birth_cohort1755M1760 1.071 0.6581 1.775
hu_birth_cohort1760M1765 0.9445 0.5964 1.494
hu_birth_cohort1765M1770 0.7115 0.4546 1.155
hu_birth_cohort1770M1775 0.9061 0.5732 1.424
hu_birth_cohort1775M1780 1.012 0.6587 1.584
hu_birth_cohort1780M1785 0.9898 0.6482 1.552
hu_birth_cohort1785M1790 1.202 0.7827 1.859
hu_birth_cohort1790M1795 1.486 1.001 2.257
hu_birth_cohort1795M1800 1.233 0.8353 1.887
hu_birth_cohort1800M1805 1.106 0.7588 1.66
hu_birth_cohort1805M1810 1.038 0.7157 1.561
hu_birth_cohort1810M1815 1.09 0.7575 1.634
hu_birth_cohort1815M1820 0.9125 0.6324 1.362
hu_birth_cohort1820M1825 0.8118 0.561 1.216
hu_birth_cohort1825M1830 0.8048 0.5542 1.204
hu_birth_cohort1830M1835 0.8112 0.5662 1.22
hu_birth_cohort1835M1840 0.7842 0.5399 1.166
hu_birth_cohort1840M1845 0.7852 0.5421 1.177
hu_birth_cohort1845M1850 0.819 0.5636 1.23
hu_male1 1.044 1.004 1.085
hu_maternalage.factor1020 1.072 0.9063 1.26
hu_maternalage.factor3559 1.07 1.012 1.133
hu_paternalage.mean 0.743 0.6633 0.8336
hu_paternal_loss01 1.211 1 1.46
hu_paternal_losslater 0.7315 0.6571 0.8139
hu_maternal_loss01 2.373 1.844 3.04
hu_maternal_losslater 0.5405 0.4742 0.6162
hu_older_siblings1 0.9415 0.8887 0.9975
hu_older_siblings2 0.9305 0.8576 1.005
hu_older_siblings3 0.9006 0.8138 0.9962
hu_older_siblings4 0.8638 0.7619 0.978
hu_older_siblings5P 0.7921 0.6725 0.9294
hu_nr.siblings 1.044 1.029 1.06
hu_last_born1 1.007 0.9554 1.058

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.98 [1.53;2.53] [1.67;2.35]
estimate father 35y 1.51 [1.14;1.97] [1.24;1.81]
percentage change -24.13 [-30.14;-18.17] [-28.08;-20.15]
OR/IRR 0.93 [0.9;0.97] [0.91;0.95]
OR hurdle 1.41 [1.27;1.57] [1.31;1.51]

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/ddb/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: 56663) 
## Samples: 6 chains, each with iter = 1500; warmup = 300; thin = 1; 
##          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: 
## ~idParents (Number of levels: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.37       2582    1
## sd(hu_Intercept)     0.90      0.02     0.86     0.93       2513    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.33      0.08     1.18     1.48        279
## paternalage                  -0.05      0.02    -0.09    -0.02       1658
## birth.cohort1750M1755        -0.18      0.11    -0.40     0.04        884
## birth.cohort1755M1760         0.08      0.09    -0.09     0.27        443
## birth.cohort1760M1765         0.14      0.08    -0.02     0.30        342
## birth.cohort1765M1770         0.09      0.08    -0.08     0.25        328
## birth.cohort1770M1775         0.05      0.08    -0.11     0.22        356
## birth.cohort1775M1780         0.04      0.08    -0.13     0.20        323
## birth.cohort1780M1785         0.14      0.08    -0.02     0.30        302
## birth.cohort1785M1790         0.11      0.08    -0.04     0.27        283
## birth.cohort1790M1795         0.02      0.08    -0.13     0.17        266
## birth.cohort1795M1800         0.01      0.07    -0.13     0.16        257
## birth.cohort1800M1805        -0.04      0.07    -0.18     0.11        256
## birth.cohort1805M1810        -0.02      0.07    -0.16     0.12        242
## birth.cohort1810M1815         0.00      0.07    -0.14     0.15        245
## birth.cohort1815M1820         0.06      0.07    -0.08     0.20        238
## birth.cohort1820M1825         0.07      0.07    -0.06     0.21        239
## birth.cohort1825M1830         0.03      0.07    -0.11     0.17        241
## birth.cohort1830M1835         0.06      0.07    -0.08     0.20        239
## birth.cohort1835M1840         0.06      0.07    -0.08     0.20        240
## birth.cohort1840M1845         0.04      0.07    -0.10     0.18        241
## birth.cohort1845M1850         0.04      0.07    -0.09     0.19        243
## first_born_adult_male        -0.01      0.01    -0.03     0.01       7200
## last_born_adult_male          0.00      0.01    -0.02     0.02       7200
## male1                         0.05      0.01     0.02     0.07       5624
## maternalage.factor1020        0.04      0.03    -0.02     0.09       7200
## maternalage.factor3559        0.06      0.01     0.04     0.08       7200
## paternalage.mean              0.06      0.02     0.02     0.10       1797
## paternal_loss01               0.06      0.04    -0.01     0.13       7200
## paternal_loss15               0.03      0.02    -0.02     0.07       3875
## paternal_loss510             -0.02      0.02    -0.06     0.02       3373
## paternal_loss1015            -0.02      0.02    -0.06     0.02       3317
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       3241
## paternal_loss2025            -0.03      0.02    -0.06     0.00       3089
## paternal_loss2530            -0.02      0.01    -0.05     0.01       2997
## paternal_loss3035            -0.02      0.01    -0.04     0.01       3337
## paternal_loss3540             0.02      0.01     0.00     0.05       3617
## paternal_loss4045             0.03      0.01     0.00     0.05       4488
## maternal_loss01               0.07      0.05    -0.04     0.17       5994
## maternal_loss15               0.00      0.03    -0.05     0.06       4775
## maternal_loss510             -0.02      0.02    -0.07     0.03       4125
## maternal_loss1015            -0.04      0.02    -0.08     0.01       4745
## maternal_loss1520            -0.04      0.02    -0.07     0.00       4207
## maternal_loss2025            -0.07      0.02    -0.10    -0.03       4246
## maternal_loss2530            -0.03      0.02    -0.06     0.00       4185
## maternal_loss3035            -0.02      0.01    -0.05     0.01       4089
## maternal_loss3540             0.00      0.01    -0.02     0.03       4561
## maternal_loss4045            -0.02      0.01    -0.04     0.00       7200
## older_siblings1               0.01      0.01    -0.01     0.04       2875
## older_siblings2               0.03      0.01     0.00     0.05       2019
## older_siblings3               0.03      0.02     0.00     0.07       1822
## older_siblings4               0.01      0.02    -0.03     0.05       1652
## older_siblings5P              0.02      0.03    -0.03     0.08       1628
## nr.siblings                   0.02      0.00     0.02     0.03       2211
## last_born1                   -0.02      0.01    -0.04     0.00       7200
## hu_Intercept                  0.24      0.22    -0.18     0.68        114
## hu_paternalage                0.15      0.06     0.04     0.27       2038
## hu_birth.cohort1750M1755      0.30      0.30    -0.30     0.90        280
## hu_birth.cohort1755M1760      0.16      0.26    -0.35     0.68        203
## hu_birth.cohort1760M1765     -0.03      0.25    -0.51     0.44        154
## hu_birth.cohort1765M1770     -0.24      0.25    -0.71     0.25        147
## hu_birth.cohort1770M1775     -0.07      0.25    -0.55     0.41        150
## hu_birth.cohort1775M1780      0.08      0.24    -0.38     0.54        134
## hu_birth.cohort1780M1785      0.04      0.24    -0.43     0.51        138
## hu_birth.cohort1785M1790      0.15      0.23    -0.29     0.60        119
## hu_birth.cohort1790M1795      0.34      0.22    -0.09     0.76        114
## hu_birth.cohort1795M1800      0.17      0.22    -0.26     0.58        109
## hu_birth.cohort1800M1805      0.07      0.21    -0.36     0.48        108
## hu_birth.cohort1805M1810      0.01      0.21    -0.42     0.40        106
## hu_birth.cohort1810M1815      0.10      0.21    -0.31     0.51        106
## hu_birth.cohort1815M1820     -0.07      0.21    -0.49     0.32        104
## hu_birth.cohort1820M1825     -0.16      0.21    -0.57     0.23        105
## hu_birth.cohort1825M1830     -0.18      0.21    -0.59     0.21        102
## hu_birth.cohort1830M1835     -0.16      0.21    -0.57     0.23        104
## hu_birth.cohort1835M1840     -0.16      0.21    -0.57     0.24        103
## hu_birth.cohort1840M1845     -0.12      0.21    -0.54     0.27        103
## hu_birth.cohort1845M1850     -0.06      0.21    -0.48     0.32        104
## hu_first_born_adult_male     -1.34      0.03    -1.41    -1.28       7200
## hu_last_born_adult_male      -1.15      0.03    -1.21    -1.08       7200
## hu_male1                      0.99      0.03     0.94     1.04       7200
## hu_maternalage.factor1020     0.06      0.10    -0.12     0.25       7200
## hu_maternalage.factor3559     0.10      0.03     0.04     0.16       7200
## hu_paternalage.mean          -0.18      0.06    -0.29    -0.06       1980
## hu_paternal_loss01            0.95      0.10     0.76     1.14       7200
## hu_paternal_loss15            0.73      0.07     0.60     0.86       3226
## hu_paternal_loss510           0.69      0.06     0.58     0.80       2799
## hu_paternal_loss1015          0.52      0.05     0.42     0.62       2884
## hu_paternal_loss1520          0.41      0.05     0.31     0.50       3202
## hu_paternal_loss2025          0.31      0.05     0.22     0.40       2547
## hu_paternal_loss2530          0.20      0.04     0.12     0.29       2762
## hu_paternal_loss3035          0.13      0.04     0.05     0.21       2811
## hu_paternal_loss3540          0.11      0.04     0.04     0.19       2981
## hu_paternal_loss4045          0.01      0.04    -0.07     0.09       7200
## hu_maternal_loss01            1.75      0.12     1.51     2.00       7200
## hu_maternal_loss15            1.07      0.07     0.93     1.22       5369
## hu_maternal_loss510           0.87      0.06     0.75     0.98       4492
## hu_maternal_loss1015          0.82      0.06     0.71     0.93       7200
## hu_maternal_loss1520          0.68      0.05     0.58     0.78       7200
## hu_maternal_loss2025          0.47      0.05     0.38     0.57       4675
## hu_maternal_loss2530          0.30      0.04     0.22     0.39       4424
## hu_maternal_loss3035          0.24      0.04     0.16     0.32       4563
## hu_maternal_loss3540          0.15      0.04     0.08     0.23       4968
## hu_maternal_loss4045          0.07      0.04     0.00     0.14       7200
## hu_older_siblings1           -0.19      0.03    -0.26    -0.13       3241
## hu_older_siblings2           -0.28      0.04    -0.36    -0.19       2366
## hu_older_siblings3           -0.37      0.06    -0.48    -0.26       1871
## hu_older_siblings4           -0.43      0.07    -0.57    -0.30       1969
## hu_older_siblings5P          -0.49      0.09    -0.66    -0.33       1808
## hu_nr.siblings                0.02      0.01     0.00     0.03       2125
## hu_last_born1                -0.01      0.03    -0.06     0.04       7200
##                           Rhat
## Intercept                 1.02
## paternalage               1.00
## birth.cohort1750M1755     1.00
## birth.cohort1755M1760     1.01
## birth.cohort1760M1765     1.01
## 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.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
## first_born_adult_male     1.00
## last_born_adult_male      1.00
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.02
## hu_paternalage            1.00
## hu_birth.cohort1750M1755  1.01
## hu_birth.cohort1755M1760  1.02
## hu_birth.cohort1760M1765  1.02
## hu_birth.cohort1765M1770  1.02
## hu_birth.cohort1770M1775  1.02
## hu_birth.cohort1775M1780  1.02
## hu_birth.cohort1780M1785  1.02
## hu_birth.cohort1785M1790  1.02
## hu_birth.cohort1790M1795  1.02
## hu_birth.cohort1795M1800  1.02
## hu_birth.cohort1800M1805  1.02
## hu_birth.cohort1805M1810  1.02
## hu_birth.cohort1810M1815  1.02
## hu_birth.cohort1815M1820  1.03
## hu_birth.cohort1820M1825  1.02
## hu_birth.cohort1825M1830  1.03
## hu_birth.cohort1830M1835  1.03
## hu_birth.cohort1835M1840  1.03
## hu_birth.cohort1840M1845  1.03
## hu_birth.cohort1845M1850  1.02
## hu_first_born_adult_male  1.00
## hu_last_born_adult_male   1.00
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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 3.785 3.254 4.389
paternalage 0.9465 0.9109 0.9838
birth.cohort1750M1755 0.8367 0.671 1.042
birth.cohort1755M1760 1.086 0.9094 1.307
birth.cohort1760M1765 1.148 0.9772 1.348
birth.cohort1765M1770 1.092 0.9273 1.28
birth.cohort1770M1775 1.051 0.8928 1.246
birth.cohort1775M1780 1.037 0.8825 1.218
birth.cohort1780M1785 1.152 0.9832 1.356
birth.cohort1785M1790 1.122 0.9608 1.31
birth.cohort1790M1795 1.015 0.8752 1.181
birth.cohort1795M1800 1.012 0.8759 1.174
birth.cohort1800M1805 0.9656 0.8367 1.119
birth.cohort1805M1810 0.9794 0.8503 1.133
birth.cohort1810M1815 1.004 0.8733 1.16
birth.cohort1815M1820 1.058 0.9208 1.221
birth.cohort1820M1825 1.076 0.9381 1.239
birth.cohort1825M1830 1.032 0.9003 1.188
birth.cohort1830M1835 1.059 0.9229 1.221
birth.cohort1835M1840 1.059 0.9225 1.22
birth.cohort1840M1845 1.036 0.9055 1.194
birth.cohort1845M1850 1.044 0.911 1.205
first_born_adult_male 0.9867 0.9665 1.007
last_born_adult_male 1.004 0.9838 1.025
male1 1.046 1.025 1.068
maternalage.factor1020 1.036 0.9781 1.098
maternalage.factor3559 1.065 1.043 1.088
paternalage.mean 1.063 1.023 1.105
paternal_loss01 1.061 0.9855 1.142
paternal_loss15 1.026 0.9763 1.076
paternal_loss510 0.9813 0.941 1.024
paternal_loss1015 0.9807 0.945 1.018
paternal_loss1520 0.9295 0.8986 0.9619
paternal_loss2025 0.9724 0.9428 1.003
paternal_loss2530 0.9793 0.9511 1.008
paternal_loss3035 0.9848 0.9581 1.012
paternal_loss3540 1.022 0.997 1.048
paternal_loss4045 1.028 1.002 1.055
maternal_loss01 1.069 0.9593 1.186
maternal_loss15 1.004 0.9482 1.062
maternal_loss510 0.9811 0.937 1.026
maternal_loss1015 0.965 0.9236 1.006
maternal_loss1520 0.9654 0.9289 1.003
maternal_loss2025 0.9326 0.9004 0.9657
maternal_loss2530 0.9738 0.9445 1.004
maternal_loss3035 0.9799 0.9541 1.007
maternal_loss3540 1.002 0.9778 1.027
maternal_loss4045 0.9805 0.9577 1.004
older_siblings1 1.014 0.9924 1.036
older_siblings2 1.026 0.9984 1.055
older_siblings3 1.032 0.9958 1.07
older_siblings4 1.008 0.9663 1.052
older_siblings5P 1.023 0.9677 1.081
nr.siblings 1.024 1.018 1.029
last_born1 0.9792 0.9615 0.9973
hu_Intercept 1.277 0.8324 1.978
hu_paternalage 1.166 1.044 1.308
hu_birth.cohort1750M1755 1.348 0.7393 2.451
hu_birth.cohort1755M1760 1.179 0.7056 1.967
hu_birth.cohort1760M1765 0.9684 0.6013 1.554
hu_birth.cohort1765M1770 0.7838 0.4893 1.281
hu_birth.cohort1770M1775 0.9315 0.5768 1.512
hu_birth.cohort1775M1780 1.081 0.6816 1.722
hu_birth.cohort1780M1785 1.038 0.6513 1.659
hu_birth.cohort1785M1790 1.159 0.7476 1.817
hu_birth.cohort1790M1795 1.403 0.9149 2.143
hu_birth.cohort1795M1800 1.183 0.7709 1.79
hu_birth.cohort1800M1805 1.068 0.6974 1.612
hu_birth.cohort1805M1810 1.005 0.6599 1.497
hu_birth.cohort1810M1815 1.109 0.732 1.657
hu_birth.cohort1815M1820 0.9288 0.6148 1.372
hu_birth.cohort1820M1825 0.8563 0.5655 1.264
hu_birth.cohort1825M1830 0.8368 0.5523 1.229
hu_birth.cohort1830M1835 0.8544 0.5638 1.261
hu_birth.cohort1835M1840 0.8564 0.5661 1.271
hu_birth.cohort1840M1845 0.8832 0.5816 1.309
hu_birth.cohort1845M1850 0.9371 0.6171 1.384
hu_first_born_adult_male 0.2606 0.2446 0.2776
hu_last_born_adult_male 0.3176 0.2981 0.3384
hu_male1 2.687 2.552 2.832
hu_maternalage.factor1020 1.061 0.8843 1.28
hu_maternalage.factor3559 1.104 1.038 1.174
hu_paternalage.mean 0.8381 0.7461 0.94
hu_paternal_loss01 2.585 2.134 3.131
hu_paternal_loss15 2.066 1.824 2.354
hu_paternal_loss510 1.998 1.792 2.231
hu_paternal_loss1015 1.682 1.52 1.858
hu_paternal_loss1520 1.504 1.369 1.654
hu_paternal_loss2025 1.358 1.243 1.486
hu_paternal_loss2530 1.224 1.127 1.332
hu_paternal_loss3035 1.14 1.053 1.237
hu_paternal_loss3540 1.12 1.037 1.213
hu_paternal_loss4045 1.014 0.9346 1.099
hu_maternal_loss01 5.758 4.536 7.384
hu_maternal_loss15 2.912 2.522 3.374
hu_maternal_loss510 2.378 2.112 2.677
hu_maternal_loss1015 2.269 2.027 2.542
hu_maternal_loss1520 1.971 1.781 2.184
hu_maternal_loss2025 1.604 1.46 1.76
hu_maternal_loss2530 1.356 1.246 1.475
hu_maternal_loss3035 1.274 1.179 1.379
hu_maternal_loss3540 1.164 1.084 1.252
hu_maternal_loss4045 1.07 0.9959 1.152
hu_older_siblings1 0.8236 0.7729 0.8778
hu_older_siblings2 0.7589 0.6958 0.8261
hu_older_siblings3 0.6916 0.6195 0.7701
hu_older_siblings4 0.6489 0.5669 0.739
hu_older_siblings5P 0.6137 0.5166 0.7225
hu_nr.siblings 1.016 1.001 1.031
hu_last_born1 0.9916 0.938 1.046

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.91 [2.77;3.06] [2.82;3.01]
estimate father 35y 2.59 [2.44;2.76] [2.49;2.7]
percentage change -11.03 [-16.11;-5.49] [-14.36;-7.46]
OR/IRR 0.95 [0.91;0.98] [0.92;0.97]
OR hurdle 1.16 [1.04;1.31] [1.08;1.26]

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/ddb/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 37 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: 56663) 
## 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)
## 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)        1.04      0.50     0.35     2.27        634 1.01
## sds(hu_sbyear_1)     1.52      0.79     0.57     3.47        881 1.01
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37       1280 1.00
## sd(hu_Intercept)     0.82      0.02     0.79     0.86       1007 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.37      0.03     1.31     1.43       1853
## paternalage                  -0.05      0.02    -0.09    -0.01        936
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.04      0.03    -0.02     0.10       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       3000
## paternalage.mean              0.06      0.02     0.02     0.10        943
## paternal_loss01               0.06      0.04    -0.01     0.13       3000
## paternal_loss15               0.02      0.02    -0.02     0.07       2403
## paternal_loss510             -0.02      0.02    -0.06     0.02       1784
## paternal_loss1015            -0.02      0.02    -0.05     0.02       1726
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       1646
## paternal_loss2025            -0.03      0.02    -0.06     0.00       1622
## paternal_loss2530            -0.02      0.01    -0.05     0.01       1753
## paternal_loss3035            -0.01      0.01    -0.04     0.01       1628
## paternal_loss3540             0.02      0.01     0.00     0.05       1688
## paternal_loss4045             0.03      0.01     0.00     0.05       3000
## maternal_loss01               0.07      0.05    -0.03     0.17       3000
## maternal_loss15               0.00      0.03    -0.05     0.06       3000
## maternal_loss510             -0.02      0.02    -0.06     0.03       2105
## maternal_loss1015            -0.03      0.02    -0.08     0.01       3000
## maternal_loss1520            -0.03      0.02    -0.07     0.01       2125
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       2102
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1993
## maternal_loss3035            -0.02      0.01    -0.05     0.01       2047
## maternal_loss3540             0.00      0.01    -0.02     0.03       3000
## maternal_loss4045            -0.02      0.01    -0.05     0.00       3000
## older_siblings1               0.02      0.01    -0.01     0.04       1558
## older_siblings2               0.03      0.01     0.00     0.05       1203
## older_siblings3               0.03      0.02     0.00     0.07       1111
## older_siblings4               0.01      0.02    -0.03     0.05       1074
## older_siblings5P              0.02      0.03    -0.03     0.08       1004
## nr.siblings                   0.02      0.00     0.02     0.03       1159
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## sbyear_1                      0.03      0.09    -0.16     0.20       1572
## hu_Intercept                 -0.19      0.07    -0.34    -0.04       3000
## hu_paternalage                0.05      0.05    -0.06     0.16        987
## hu_male1                      0.04      0.02     0.01     0.08       3000
## hu_maternalage.factor1020     0.05      0.09    -0.13     0.23       3000
## hu_maternalage.factor3559     0.07      0.03     0.01     0.13       3000
## hu_paternalage.mean          -0.08      0.06    -0.18     0.03       1029
## hu_paternal_loss01            0.87      0.09     0.69     1.04       3000
## hu_paternal_loss15            0.67      0.06     0.54     0.79       3000
## hu_paternal_loss510           0.69      0.05     0.59     0.79       1919
## hu_paternal_loss1015          0.52      0.05     0.43     0.62       1824
## hu_paternal_loss1520          0.43      0.04     0.34     0.51       1677
## hu_paternal_loss2025          0.32      0.04     0.24     0.40       1597
## hu_paternal_loss2530          0.22      0.04     0.14     0.31       1600
## hu_paternal_loss3035          0.16      0.04     0.08     0.24       1875
## hu_paternal_loss3540          0.12      0.04     0.04     0.19       2042
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       3000
## hu_maternal_loss01            1.85      0.12     1.61     2.08       3000
## hu_maternal_loss15            1.02      0.07     0.89     1.16       3000
## hu_maternal_loss510           0.86      0.06     0.75     0.98       3000
## hu_maternal_loss1015          0.81      0.06     0.70     0.91       3000
## hu_maternal_loss1520          0.67      0.05     0.57     0.78       3000
## hu_maternal_loss2025          0.46      0.05     0.37     0.55       3000
## hu_maternal_loss2530          0.31      0.04     0.23     0.40       3000
## hu_maternal_loss3035          0.25      0.04     0.17     0.32       3000
## hu_maternal_loss3540          0.14      0.04     0.07     0.21       3000
## hu_maternal_loss4045          0.08      0.04     0.01     0.14       3000
## hu_older_siblings1           -0.04      0.03    -0.10     0.02       3000
## hu_older_siblings2           -0.04      0.04    -0.12     0.04       1221
## hu_older_siblings3           -0.06      0.05    -0.15     0.04       1096
## hu_older_siblings4           -0.09      0.06    -0.21     0.04       1165
## hu_older_siblings5P          -0.15      0.08    -0.31     0.00       1034
## hu_nr.siblings                0.05      0.01     0.03     0.06       1244
## hu_last_born1                 0.01      0.03    -0.04     0.06       3000
## hu_sbyear_1                   0.01      0.16    -0.32     0.35       1531
##                           Rhat
## Intercept                 1.00
## paternalage               1.00
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    1.00
## paternalage.mean          1.00
## paternal_loss01           1.01
## 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
## sbyear_1                  1.00
## hu_Intercept              1.00
## hu_paternalage            1.00
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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
## hu_sbyear_1               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 3.936 3.723 4.172
paternalage 0.9499 0.9156 0.9859
male1 1.041 1.027 1.055
maternalage.factor1020 1.039 0.9795 1.102
maternalage.factor3559 1.066 1.043 1.088
paternalage.mean 1.06 1.02 1.101
paternal_loss01 1.064 0.9906 1.142
paternal_loss15 1.025 0.9773 1.075
paternal_loss510 0.9808 0.9433 1.022
paternal_loss1015 0.9802 0.9469 1.017
paternal_loss1520 0.9295 0.8997 0.9612
paternal_loss2025 0.9726 0.9436 1.003
paternal_loss2530 0.9795 0.9532 1.008
paternal_loss3035 0.9856 0.9601 1.014
paternal_loss3540 1.022 0.9984 1.049
paternal_loss4045 1.028 1.002 1.055
maternal_loss01 1.073 0.9671 1.19
maternal_loss15 1.003 0.9482 1.059
maternal_loss510 0.982 0.9383 1.029
maternal_loss1015 0.966 0.9272 1.009
maternal_loss1520 0.9674 0.9307 1.005
maternal_loss2025 0.9333 0.9031 0.9653
maternal_loss2530 0.9747 0.9461 1.005
maternal_loss3035 0.9812 0.9546 1.008
maternal_loss3540 1.002 0.978 1.026
maternal_loss4045 0.9798 0.9555 1.004
older_siblings1 1.016 0.9947 1.037
older_siblings2 1.028 1.001 1.056
older_siblings3 1.036 1.001 1.072
older_siblings4 1.01 0.9695 1.055
older_siblings5P 1.024 0.9696 1.08
nr.siblings 1.024 1.019 1.029
last_born1 0.9789 0.9606 0.9979
sbyear_1 1.033 0.8534 1.22
hu_Intercept 0.8295 0.7153 0.9587
hu_paternalage 1.051 0.9422 1.171
hu_male1 1.046 1.008 1.085
hu_maternalage.factor1020 1.053 0.8815 1.256
hu_maternalage.factor3559 1.072 1.013 1.136
hu_paternalage.mean 0.9271 0.8316 1.034
hu_paternal_loss01 2.378 1.999 2.842
hu_paternal_loss15 1.954 1.724 2.204
hu_paternal_loss510 1.991 1.801 2.211
hu_paternal_loss1015 1.686 1.538 1.862
hu_paternal_loss1520 1.533 1.402 1.668
hu_paternal_loss2025 1.38 1.268 1.499
hu_paternal_loss2530 1.252 1.153 1.359
hu_paternal_loss3035 1.172 1.085 1.266
hu_paternal_loss3540 1.128 1.046 1.215
hu_paternal_loss4045 1.042 0.965 1.129
hu_maternal_loss01 6.374 5.022 8.043
hu_maternal_loss15 2.78 2.427 3.197
hu_maternal_loss510 2.373 2.12 2.655
hu_maternal_loss1015 2.238 2.005 2.495
hu_maternal_loss1520 1.962 1.773 2.177
hu_maternal_loss2025 1.584 1.451 1.731
hu_maternal_loss2530 1.37 1.264 1.486
hu_maternal_loss3035 1.278 1.184 1.376
hu_maternal_loss3540 1.156 1.075 1.239
hu_maternal_loss4045 1.078 1.007 1.155
hu_older_siblings1 0.958 0.902 1.016
hu_older_siblings2 0.9602 0.8888 1.039
hu_older_siblings3 0.9439 0.8565 1.043
hu_older_siblings4 0.9141 0.8094 1.036
hu_older_siblings5P 0.859 0.7328 1.001
hu_nr.siblings 1.048 1.034 1.064
hu_last_born1 1.007 0.9562 1.058
hu_sbyear_1 1.006 0.7262 1.424

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.63 [2.51;2.75] [2.56;2.71]
estimate father 35y 2.45 [2.31;2.6] [2.36;2.55]
percentage change -7.04 [-12.4;-1.31] [-10.55;-3.23]
OR/IRR 0.95 [0.92;0.99] [0.93;0.97]
OR hurdle 1.05 [0.94;1.17] [0.98;1.13]

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/ddb/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)
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: 84106) 
## Samples: 6 chains, each with iter = 3500; warmup = 1500; thin = 5; 
##          total post-warmup samples = 2400
##    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: 24407) 
##                                  Estimate Est.Error l-95% CI u-95% CI
## sd(Intercept)                        0.91      0.08     0.85     0.98
## sd(paternalage)                      0.23      0.01     0.21     0.25
## sd(hu_Intercept)                     1.83      0.12     1.58     2.08
## sd(hu_paternalage)                   0.40      0.04     0.31     0.47
## cor(Intercept,paternalage)          -0.92      0.06    -0.94    -0.91
## cor(hu_Intercept,hu_paternalage)    -0.86      0.02    -0.89    -0.80
##                                  Eff.Sample Rhat
## sd(Intercept)                           105 1.04
## sd(paternalage)                         156 1.03
## sd(hu_Intercept)                        384 1.02
## sd(hu_paternalage)                      248 1.03
## cor(Intercept,paternalage)               98 1.04
## cor(hu_Intercept,hu_paternalage)        461 1.02
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.32      0.08     1.16     1.49        231
## paternalage                  -0.07      0.02    -0.10    -0.03       1150
## birth_cohort1750M1755        -0.11      0.11    -0.33     0.10        462
## birth_cohort1755M1760         0.06      0.10    -0.13     0.24        345
## birth_cohort1760M1765         0.14      0.09    -0.03     0.31        250
## birth_cohort1765M1770         0.12      0.09    -0.05     0.29        247
## birth_cohort1770M1775         0.07      0.09    -0.10     0.25        265
## birth_cohort1775M1780         0.06      0.09    -0.11     0.23        230
## birth_cohort1780M1785         0.16      0.09    -0.01     0.33        241
## birth_cohort1785M1790         0.10      0.08    -0.07     0.27        239
## birth_cohort1790M1795         0.03      0.08    -0.13     0.19        243
## birth_cohort1795M1800         0.03      0.08    -0.12     0.19        229
## birth_cohort1800M1805        -0.02      0.08    -0.17     0.14        223
## birth_cohort1805M1810         0.01      0.08    -0.14     0.16        226
## birth_cohort1810M1815         0.02      0.08    -0.13     0.17        224
## birth_cohort1815M1820         0.08      0.08    -0.07     0.23        218
## birth_cohort1820M1825         0.09      0.08    -0.06     0.24        222
## birth_cohort1825M1830         0.05      0.08    -0.09     0.20        214
## birth_cohort1830M1835         0.08      0.08    -0.07     0.23        216
## birth_cohort1835M1840         0.07      0.08    -0.08     0.23        216
## birth_cohort1840M1845         0.05      0.08    -0.10     0.20        214
## birth_cohort1845M1850         0.06      0.08    -0.09     0.21        215
## male1                         0.04      0.01     0.03     0.05       2032
## maternalage.factor1020        0.04      0.03    -0.02     0.10       1711
## maternalage.factor3559        0.06      0.01     0.03     0.08       1819
## paternalage.mean              0.07      0.02     0.03     0.11       1237
## paternal_loss01               0.01      0.04    -0.06     0.08       1568
## paternal_loss15               0.01      0.02    -0.04     0.06       1652
## paternal_loss510             -0.04      0.02    -0.08     0.01       1625
## paternal_loss1015            -0.03      0.02    -0.07     0.00       1400
## paternal_loss1520            -0.09      0.02    -0.12    -0.05       1616
## paternal_loss2025            -0.04      0.02    -0.08    -0.01       1696
## paternal_loss2530            -0.03      0.02    -0.06     0.00       1615
## paternal_loss3035            -0.03      0.01    -0.06     0.00       1528
## paternal_loss3540             0.02      0.01    -0.01     0.05       1697
## paternal_loss4045             0.03      0.01     0.00     0.05       1805
## paternal_lossunclear         -0.09      0.02    -0.12    -0.05       1393
## maternal_loss01               0.03      0.05    -0.07     0.14       2028
## maternal_loss15               0.00      0.03    -0.06     0.05       1634
## maternal_loss510             -0.02      0.02    -0.07     0.02       1853
## maternal_loss1015            -0.05      0.02    -0.10    -0.01       1522
## maternal_loss1520            -0.05      0.02    -0.10    -0.01       1482
## maternal_loss2025            -0.08      0.02    -0.12    -0.05       1554
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1201
## maternal_loss3035            -0.03      0.01    -0.06     0.00       1223
## maternal_loss3540             0.00      0.01    -0.03     0.02       1578
## maternal_loss4045            -0.03      0.01    -0.05     0.00       1488
## maternal_lossunclear         -0.11      0.02    -0.15    -0.08       1258
## older_siblings1               0.03      0.01     0.01     0.05       1445
## older_siblings2               0.05      0.01     0.02     0.07       1347
## older_siblings3               0.06      0.02     0.02     0.09       1116
## older_siblings4               0.04      0.02    -0.01     0.08       1139
## older_siblings5P              0.06      0.03     0.00     0.11       1164
## nr.siblings                   0.02      0.00     0.02     0.03       1309
## last_born1                   -0.02      0.01    -0.03     0.00       1955
## hu_Intercept                  0.14      0.19    -0.23     0.50        488
## hu_paternalage                0.42      0.05     0.32     0.53        639
## hu_birth_cohort1750M1755      0.00      0.25    -0.49     0.48        931
## hu_birth_cohort1755M1760     -0.10      0.23    -0.55     0.35        642
## hu_birth_cohort1760M1765     -0.16      0.21    -0.58     0.24        533
## hu_birth_cohort1765M1770     -0.38      0.21    -0.80     0.03        529
## hu_birth_cohort1770M1775     -0.29      0.22    -0.72     0.12        603
## hu_birth_cohort1775M1780      0.04      0.21    -0.37     0.45        552
## hu_birth_cohort1780M1785     -0.02      0.20    -0.41     0.37        485
## hu_birth_cohort1785M1790      0.16      0.20    -0.24     0.53        466
## hu_birth_cohort1790M1795      0.35      0.19     0.00     0.73        445
## hu_birth_cohort1795M1800      0.22      0.18    -0.14     0.58        435
## hu_birth_cohort1800M1805      0.14      0.18    -0.20     0.50        444
## hu_birth_cohort1805M1810      0.11      0.18    -0.24     0.47        447
## hu_birth_cohort1810M1815      0.20      0.18    -0.14     0.56        440
## hu_birth_cohort1815M1820      0.02      0.18    -0.31     0.38        423
## hu_birth_cohort1820M1825     -0.12      0.18    -0.46     0.23        413
## hu_birth_cohort1825M1830     -0.15      0.18    -0.49     0.20        412
## hu_birth_cohort1830M1835     -0.17      0.18    -0.51     0.18        400
## hu_birth_cohort1835M1840     -0.27      0.18    -0.61     0.09        422
## hu_birth_cohort1840M1845     -0.35      0.18    -0.68     0.01        411
## hu_birth_cohort1845M1850     -0.45      0.18    -0.77    -0.09        413
## hu_male1                      0.07      0.02     0.03     0.10       1867
## hu_maternalage.factor1020     0.11      0.08    -0.04     0.28       2037
## hu_maternalage.factor3559    -0.06      0.03    -0.11    -0.01       1956
## hu_paternalage.mean          -0.44      0.06    -0.55    -0.33        804
## hu_paternal_loss01            0.80      0.09     0.62     0.96       1908
## hu_paternal_loss15            0.67      0.06     0.55     0.79       1644
## hu_paternal_loss510           0.64      0.05     0.54     0.75       1950
## hu_paternal_loss1015          0.50      0.05     0.41     0.59       1328
## hu_paternal_loss1520          0.41      0.05     0.32     0.50       1502
## hu_paternal_loss2025          0.29      0.04     0.21     0.38       1341
## hu_paternal_loss2530          0.20      0.04     0.12     0.28       1403
## hu_paternal_loss3035          0.13      0.04     0.05     0.21       1475
## hu_paternal_loss3540          0.11      0.04     0.03     0.19       1685
## hu_paternal_loss4045          0.03      0.04    -0.05     0.11       1706
## hu_paternal_lossunclear       1.38      0.05     1.29     1.47       1401
## hu_maternal_loss01            1.75      0.11     1.54     1.98       1910
## hu_maternal_loss15            0.95      0.07     0.81     1.08       1994
## hu_maternal_loss510           0.84      0.06     0.73     0.96       1597
## hu_maternal_loss1015          0.81      0.06     0.70     0.92       2265
## hu_maternal_loss1520          0.66      0.05     0.55     0.76       1695
## hu_maternal_loss2025          0.45      0.05     0.36     0.54       1708
## hu_maternal_loss2530          0.29      0.04     0.20     0.37       1920
## hu_maternal_loss3035          0.22      0.04     0.14     0.30       1585
## hu_maternal_loss3540          0.13      0.04     0.05     0.20       1794
## hu_maternal_loss4045          0.06      0.04    -0.01     0.13       1814
## hu_maternal_lossunclear       1.24      0.04     1.16     1.31       1659
## hu_older_siblings1           -0.07      0.03    -0.12    -0.01       1322
## hu_older_siblings2           -0.09      0.04    -0.17    -0.02       1140
## hu_older_siblings3           -0.14      0.05    -0.23    -0.04        909
## hu_older_siblings4           -0.21      0.06    -0.33    -0.09        825
## hu_older_siblings5P          -0.29      0.08    -0.44    -0.13        723
## hu_nr.siblings                0.02      0.01     0.01     0.03       1077
## hu_last_born1                 0.03      0.02    -0.01     0.08       1923
##                           Rhat
## Intercept                 1.01
## paternalage               1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.01
## birth_cohort1760M1765     1.01
## birth_cohort1765M1770     1.01
## birth_cohort1770M1775     1.01
## birth_cohort1775M1780     1.02
## birth_cohort1780M1785     1.01
## birth_cohort1785M1790     1.01
## birth_cohort1790M1795     1.01
## birth_cohort1795M1800     1.02
## birth_cohort1800M1805     1.02
## birth_cohort1805M1810     1.01
## birth_cohort1810M1815     1.01
## birth_cohort1815M1820     1.02
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.02
## birth_cohort1830M1835     1.02
## birth_cohort1835M1840     1.02
## birth_cohort1840M1845     1.02
## birth_cohort1845M1850     1.02
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.01
## hu_paternalage            1.00
## hu_birth_cohort1750M1755  1.01
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.01
## hu_birth_cohort1780M1785  1.02
## hu_birth_cohort1785M1790  1.02
## hu_birth_cohort1790M1795  1.01
## hu_birth_cohort1795M1800  1.02
## hu_birth_cohort1800M1805  1.02
## hu_birth_cohort1805M1810  1.02
## hu_birth_cohort1810M1815  1.02
## hu_birth_cohort1815M1820  1.02
## hu_birth_cohort1820M1825  1.02
## hu_birth_cohort1825M1830  1.02
## hu_birth_cohort1830M1835  1.02
## hu_birth_cohort1835M1840  1.02
## hu_birth_cohort1840M1845  1.02
## hu_birth_cohort1845M1850  1.02
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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_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 3.76 3.185 4.426
paternalage 0.9354 0.9008 0.9731
birth_cohort1750M1755 0.8983 0.7192 1.108
birth_cohort1755M1760 1.061 0.8774 1.277
birth_cohort1760M1765 1.155 0.9698 1.364
birth_cohort1765M1770 1.127 0.9522 1.338
birth_cohort1770M1775 1.072 0.9063 1.285
birth_cohort1775M1780 1.058 0.8925 1.254
birth_cohort1780M1785 1.169 0.991 1.384
birth_cohort1785M1790 1.103 0.9327 1.304
birth_cohort1790M1795 1.028 0.8749 1.21
birth_cohort1795M1800 1.031 0.8873 1.213
birth_cohort1800M1805 0.983 0.8435 1.149
birth_cohort1805M1810 1.01 0.8673 1.171
birth_cohort1810M1815 1.021 0.8791 1.19
birth_cohort1815M1820 1.08 0.9328 1.252
birth_cohort1820M1825 1.091 0.9428 1.267
birth_cohort1825M1830 1.056 0.9113 1.225
birth_cohort1830M1835 1.08 0.9311 1.257
birth_cohort1835M1840 1.074 0.9246 1.252
birth_cohort1840M1845 1.052 0.9051 1.223
birth_cohort1845M1850 1.061 0.9161 1.237
male1 1.043 1.03 1.056
maternalage.factor1020 1.042 0.9793 1.107
maternalage.factor3559 1.058 1.035 1.079
paternalage.mean 1.075 1.034 1.118
paternal_loss01 1.009 0.9371 1.082
paternal_loss15 1.009 0.9607 1.059
paternal_loss510 0.9626 0.922 1.005
paternal_loss1015 0.9657 0.9308 1.001
paternal_loss1520 0.9149 0.8829 0.9482
paternal_loss2025 0.9572 0.9263 0.9897
paternal_loss2530 0.9675 0.9383 0.9968
paternal_loss3035 0.971 0.943 0.9984
paternal_loss3540 1.017 0.9896 1.046
paternal_loss4045 1.027 0.9999 1.054
paternal_lossunclear 0.9163 0.8834 0.9496
maternal_loss01 1.035 0.9341 1.148
maternal_loss15 0.9963 0.9436 1.052
maternal_loss510 0.9776 0.9322 1.023
maternal_loss1015 0.9494 0.9091 0.9913
maternal_loss1520 0.9474 0.9086 0.9881
maternal_loss2025 0.9208 0.8895 0.9545
maternal_loss2530 0.9685 0.9397 0.9985
maternal_loss3035 0.9737 0.9453 1.002
maternal_loss3540 0.9988 0.9738 1.025
maternal_loss4045 0.9752 0.9517 0.9991
maternal_lossunclear 0.8916 0.8645 0.9191
older_siblings1 1.025 1.005 1.047
older_siblings2 1.046 1.018 1.075
older_siblings3 1.057 1.02 1.094
older_siblings4 1.038 0.9949 1.082
older_siblings5P 1.06 1.004 1.118
nr.siblings 1.021 1.016 1.026
last_born1 0.9831 0.9658 1.001
hu_Intercept 1.151 0.7925 1.654
hu_paternalage 1.525 1.373 1.695
hu_birth_cohort1750M1755 1.002 0.6121 1.623
hu_birth_cohort1755M1760 0.9019 0.5797 1.423
hu_birth_cohort1760M1765 0.8488 0.5609 1.277
hu_birth_cohort1765M1770 0.6846 0.4509 1.031
hu_birth_cohort1770M1775 0.7463 0.4868 1.129
hu_birth_cohort1775M1780 1.044 0.6935 1.561
hu_birth_cohort1780M1785 0.9773 0.6605 1.455
hu_birth_cohort1785M1790 1.169 0.7906 1.703
hu_birth_cohort1790M1795 1.413 0.9981 2.076
hu_birth_cohort1795M1800 1.243 0.8718 1.787
hu_birth_cohort1800M1805 1.146 0.8162 1.647
hu_birth_cohort1805M1810 1.112 0.7865 1.6
hu_birth_cohort1810M1815 1.219 0.8715 1.749
hu_birth_cohort1815M1820 1.024 0.7333 1.458
hu_birth_cohort1820M1825 0.8838 0.6308 1.26
hu_birth_cohort1825M1830 0.8569 0.6111 1.227
hu_birth_cohort1830M1835 0.8409 0.5988 1.203
hu_birth_cohort1835M1840 0.7635 0.5445 1.094
hu_birth_cohort1840M1845 0.706 0.5055 1.011
hu_birth_cohort1845M1850 0.6404 0.4618 0.9145
hu_male1 1.07 1.034 1.108
hu_maternalage.factor1020 1.121 0.958 1.317
hu_maternalage.factor3559 0.941 0.8924 0.9925
hu_paternalage.mean 0.6434 0.5783 0.7197
hu_paternal_loss01 2.222 1.853 2.621
hu_paternal_loss15 1.954 1.727 2.211
hu_paternal_loss510 1.902 1.71 2.114
hu_paternal_loss1015 1.65 1.5 1.813
hu_paternal_loss1520 1.501 1.372 1.645
hu_paternal_loss2025 1.342 1.229 1.461
hu_paternal_loss2530 1.22 1.123 1.328
hu_paternal_loss3035 1.139 1.051 1.232
hu_paternal_loss3540 1.111 1.027 1.205
hu_paternal_loss4045 1.028 0.9493 1.117
hu_paternal_lossunclear 3.969 3.633 4.344
hu_maternal_loss01 5.763 4.661 7.251
hu_maternal_loss15 2.583 2.253 2.945
hu_maternal_loss510 2.327 2.082 2.611
hu_maternal_loss1015 2.254 2.02 2.516
hu_maternal_loss1520 1.926 1.741 2.132
hu_maternal_loss2025 1.565 1.427 1.717
hu_maternal_loss2530 1.335 1.227 1.455
hu_maternal_loss3035 1.243 1.151 1.351
hu_maternal_loss3540 1.136 1.055 1.223
hu_maternal_loss4045 1.063 0.9875 1.14
hu_maternal_lossunclear 3.439 3.184 3.722
hu_older_siblings1 0.9329 0.8828 0.9882
hu_older_siblings2 0.9135 0.8475 0.9838
hu_older_siblings3 0.8713 0.7909 0.9624
hu_older_siblings4 0.8104 0.7195 0.9127
hu_older_siblings5P 0.7482 0.6411 0.8764
hu_nr.siblings 1.02 1.005 1.035
hu_last_born1 1.034 0.9875 1.083

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.51 [2.03;3.06] [2.18;2.86]
estimate father 35y 1.92 [1.5;2.4] [1.63;2.22]
percentage change -23.7 [-29.41;-17.92] [-27.4;-19.92]
OR/IRR 0.94 [0.9;0.97] [0.91;0.96]
OR hurdle 1.53 [1.37;1.69] [1.42;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/ddb/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: 56663) 
## 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: 14266) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.28      0.02     0.24     0.32        326 1.01
## sd(hu_Intercept)     0.48      0.08     0.32     0.63        299 1.02
## 
## ~idPere (Number of levels: 13910) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.02     0.17     0.26        317 1.01
## sd(hu_Intercept)     0.66      0.06     0.53     0.76        311 1.02
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.32      0.08     1.16     1.48       1974
## paternalage                  -0.05      0.02    -0.09    -0.01       5674
## birth_cohort1750M1755        -0.17      0.12    -0.40     0.06       3803
## birth_cohort1755M1760         0.09      0.09    -0.10     0.27       2936
## birth_cohort1760M1765         0.15      0.09    -0.02     0.32       2495
## birth_cohort1765M1770         0.09      0.09    -0.07     0.27       2193
## birth_cohort1770M1775         0.06      0.09    -0.11     0.23       2260
## birth_cohort1775M1780         0.04      0.09    -0.12     0.21       2307
## birth_cohort1780M1785         0.15      0.09    -0.02     0.32       2303
## birth_cohort1785M1790         0.12      0.08    -0.04     0.28       2191
## birth_cohort1790M1795         0.02      0.08    -0.14     0.18       2176
## birth_cohort1795M1800         0.02      0.08    -0.14     0.18       2038
## birth_cohort1800M1805        -0.03      0.08    -0.18     0.13       1975
## birth_cohort1805M1810        -0.02      0.08    -0.17     0.14       2034
## birth_cohort1810M1815         0.01      0.08    -0.14     0.16       1982
## birth_cohort1815M1820         0.06      0.08    -0.09     0.22       1963
## birth_cohort1820M1825         0.08      0.08    -0.07     0.23       1960
## birth_cohort1825M1830         0.04      0.08    -0.11     0.19       1892
## birth_cohort1830M1835         0.06      0.08    -0.08     0.21       1940
## birth_cohort1835M1840         0.06      0.08    -0.09     0.22       2005
## birth_cohort1840M1845         0.04      0.08    -0.11     0.19       1892
## birth_cohort1845M1850         0.05      0.08    -0.10     0.20       1977
## male1                         0.04      0.01     0.03     0.05       7200
## maternalage.factor1020        0.04      0.03    -0.02     0.09       7133
## maternalage.factor3559        0.06      0.01     0.04     0.08       7200
## paternalage.mean              0.06      0.02     0.02     0.10       5912
## paternal_loss01               0.06      0.04    -0.02     0.13       6919
## paternal_loss15               0.02      0.02    -0.03     0.06       6523
## paternal_loss510             -0.02      0.02    -0.06     0.02       6603
## paternal_loss1015            -0.02      0.02    -0.06     0.02       6139
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       6349
## paternal_loss2025            -0.03      0.02    -0.06     0.00       6554
## paternal_loss2530            -0.02      0.02    -0.05     0.01       6080
## paternal_loss3035            -0.02      0.01    -0.04     0.01       6209
## paternal_loss3540             0.02      0.01     0.00     0.05       5957
## paternal_loss4045             0.03      0.01     0.00     0.05       6396
## maternal_loss01               0.07      0.05    -0.04     0.17       7200
## maternal_loss15               0.00      0.03    -0.05     0.06       7200
## maternal_loss510             -0.02      0.02    -0.06     0.03       7178
## maternal_loss1015            -0.04      0.02    -0.08     0.01       7117
## maternal_loss1520            -0.03      0.02    -0.07     0.00       6846
## maternal_loss2025            -0.07      0.02    -0.10    -0.03       6617
## maternal_loss2530            -0.03      0.02    -0.06     0.00       6807
## maternal_loss3035            -0.02      0.01    -0.05     0.01       6683
## maternal_loss3540             0.00      0.01    -0.02     0.03       7050
## maternal_loss4045            -0.02      0.01    -0.04     0.00       6849
## older_siblings1               0.02      0.01    -0.01     0.04       6301
## older_siblings2               0.03      0.01     0.00     0.06       6049
## older_siblings3               0.04      0.02     0.00     0.07       5646
## older_siblings4               0.01      0.02    -0.03     0.05       5884
## older_siblings5P              0.03      0.03    -0.03     0.08       5614
## nr.siblings                   0.02      0.00     0.02     0.03       5794
## last_born1                   -0.02      0.01    -0.04     0.00       7200
## hu_Intercept                 -0.03      0.20    -0.41     0.36       2168
## hu_paternalage                0.05      0.06    -0.06     0.16       5640
## hu_birth_cohort1750M1755      0.34      0.29    -0.21     0.90       4010
## hu_birth_cohort1755M1760      0.05      0.24    -0.42     0.54       3007
## hu_birth_cohort1760M1765     -0.08      0.22    -0.53     0.36       2537
## hu_birth_cohort1765M1770     -0.38      0.22    -0.81     0.06       2729
## hu_birth_cohort1770M1775     -0.14      0.23    -0.59     0.30       2719
## hu_birth_cohort1775M1780      0.02      0.22    -0.41     0.45       2483
## hu_birth_cohort1780M1785     -0.05      0.22    -0.47     0.38       2343
## hu_birth_cohort1785M1790      0.10      0.21    -0.31     0.51       2381
## hu_birth_cohort1790M1795      0.28      0.20    -0.12     0.67       2286
## hu_birth_cohort1795M1800      0.08      0.19    -0.30     0.46       2238
## hu_birth_cohort1800M1805      0.00      0.19    -0.38     0.38       2268
## hu_birth_cohort1805M1810     -0.05      0.19    -0.41     0.33       2113
## hu_birth_cohort1810M1815      0.03      0.19    -0.35     0.40       2126
## hu_birth_cohort1815M1820     -0.14      0.19    -0.51     0.24       2082
## hu_birth_cohort1820M1825     -0.24      0.19    -0.61     0.13       2065
## hu_birth_cohort1825M1830     -0.24      0.19    -0.61     0.13       2048
## hu_birth_cohort1830M1835     -0.22      0.19    -0.59     0.15       2075
## hu_birth_cohort1835M1840     -0.24      0.19    -0.61     0.13       2043
## hu_birth_cohort1840M1845     -0.23      0.19    -0.60     0.14       2050
## hu_birth_cohort1845M1850     -0.19      0.19    -0.56     0.17       2054
## hu_male1                      0.05      0.02     0.01     0.08       7200
## hu_maternalage.factor1020     0.06      0.09    -0.12     0.23       7200
## hu_maternalage.factor3559     0.07      0.03     0.01     0.13       6884
## hu_paternalage.mean          -0.08      0.06    -0.19     0.04       5746
## hu_paternal_loss01            0.87      0.09     0.69     1.05       6951
## hu_paternal_loss15            0.67      0.06     0.55     0.80       6698
## hu_paternal_loss510           0.69      0.05     0.59     0.80       6636
## hu_paternal_loss1015          0.53      0.05     0.43     0.62       6571
## hu_paternal_loss1520          0.43      0.04     0.34     0.52       6410
## hu_paternal_loss2025          0.32      0.04     0.24     0.41       6568
## hu_paternal_loss2530          0.23      0.04     0.15     0.31       6359
## hu_paternal_loss3035          0.16      0.04     0.09     0.24       6942
## hu_paternal_loss3540          0.12      0.04     0.05     0.19       6736
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       6527
## hu_maternal_loss01            1.83      0.12     1.60     2.07       6797
## hu_maternal_loss15            1.01      0.07     0.87     1.14       7200
## hu_maternal_loss510           0.85      0.06     0.74     0.96       6934
## hu_maternal_loss1015          0.79      0.05     0.69     0.90       7200
## hu_maternal_loss1520          0.67      0.05     0.57     0.76       7180
## hu_maternal_loss2025          0.45      0.04     0.36     0.54       6835
## hu_maternal_loss2530          0.31      0.04     0.23     0.39       7200
## hu_maternal_loss3035          0.24      0.04     0.17     0.32       6867
## hu_maternal_loss3540          0.14      0.04     0.08     0.21       6826
## hu_maternal_loss4045          0.07      0.04     0.00     0.14       7002
## hu_older_siblings1           -0.04      0.03    -0.10     0.02       6457
## hu_older_siblings2           -0.04      0.04    -0.12     0.04       5996
## hu_older_siblings3           -0.05      0.05    -0.16     0.05       5804
## hu_older_siblings4           -0.09      0.06    -0.21     0.04       5815
## hu_older_siblings5P          -0.15      0.08    -0.32     0.01       5546
## hu_nr.siblings                0.05      0.01     0.03     0.06       5972
## hu_last_born1                 0.01      0.03    -0.04     0.06       7064
##                           Rhat
## Intercept                    1
## paternalage                  1
## birth_cohort1750M1755        1
## birth_cohort1755M1760        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
## birth_cohort1835M1840        1
## birth_cohort1840M1845        1
## birth_cohort1845M1850        1
## male1                        1
## maternalage.factor1020       1
## maternalage.factor3559       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_cohort1750M1755     1
## hu_birth_cohort1755M1760     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_birth_cohort1835M1840     1
## hu_birth_cohort1840M1845     1
## hu_birth_cohort1845M1850     1
## hu_male1                     1
## hu_maternalage.factor1020    1
## hu_maternalage.factor3559    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 3.75 3.189 4.403
paternalage 0.9493 0.9143 0.9856
birth_cohort1750M1755 0.8413 0.6695 1.057
birth_cohort1755M1760 1.095 0.9075 1.313
birth_cohort1760M1765 1.157 0.9767 1.375
birth_cohort1765M1770 1.098 0.929 1.303
birth_cohort1770M1775 1.062 0.8924 1.264
birth_cohort1775M1780 1.045 0.8834 1.238
birth_cohort1780M1785 1.157 0.9782 1.371
birth_cohort1785M1790 1.126 0.9594 1.327
birth_cohort1790M1795 1.02 0.8705 1.198
birth_cohort1795M1800 1.017 0.8731 1.194
birth_cohort1800M1805 0.9703 0.8323 1.135
birth_cohort1805M1810 0.985 0.8474 1.153
birth_cohort1810M1815 1.01 0.8685 1.177
birth_cohort1815M1820 1.063 0.9171 1.24
birth_cohort1820M1825 1.081 0.9325 1.261
birth_cohort1825M1830 1.037 0.8949 1.208
birth_cohort1830M1835 1.065 0.9187 1.238
birth_cohort1835M1840 1.065 0.9173 1.24
birth_cohort1840M1845 1.041 0.8973 1.213
birth_cohort1845M1850 1.049 0.9033 1.223
male1 1.041 1.027 1.055
maternalage.factor1020 1.037 0.9778 1.099
maternalage.factor3559 1.065 1.043 1.088
paternalage.mean 1.061 1.02 1.103
paternal_loss01 1.059 0.9847 1.133
paternal_loss15 1.018 0.9696 1.067
paternal_loss510 0.9782 0.939 1.02
paternal_loss1015 0.9784 0.943 1.015
paternal_loss1520 0.9283 0.8973 0.961
paternal_loss2025 0.9721 0.9428 1.003
paternal_loss2530 0.9791 0.9505 1.009
paternal_loss3035 0.9838 0.9572 1.012
paternal_loss3540 1.021 0.9954 1.048
paternal_loss4045 1.028 1.002 1.054
maternal_loss01 1.071 0.9615 1.19
maternal_loss15 1.003 0.9469 1.062
maternal_loss510 0.9817 0.9381 1.028
maternal_loss1015 0.9653 0.9247 1.008
maternal_loss1520 0.9672 0.9305 1.005
maternal_loss2025 0.9342 0.9029 0.9672
maternal_loss2530 0.9741 0.9454 1.004
maternal_loss3035 0.9803 0.9544 1.007
maternal_loss3540 1.003 0.9793 1.027
maternal_loss4045 0.9813 0.9584 1.005
older_siblings1 1.016 0.9945 1.037
older_siblings2 1.029 1.001 1.057
older_siblings3 1.036 1.002 1.073
older_siblings4 1.012 0.9704 1.055
older_siblings5P 1.027 0.9719 1.085
nr.siblings 1.024 1.018 1.029
last_born1 0.9798 0.9618 0.9984
hu_Intercept 0.9716 0.6624 1.43
hu_paternalage 1.052 0.9435 1.173
hu_birth_cohort1750M1755 1.4 0.808 2.466
hu_birth_cohort1755M1760 1.05 0.6594 1.707
hu_birth_cohort1760M1765 0.9227 0.5911 1.435
hu_birth_cohort1765M1770 0.6852 0.4463 1.058
hu_birth_cohort1770M1775 0.8711 0.5546 1.353
hu_birth_cohort1775M1780 1.016 0.666 1.567
hu_birth_cohort1780M1785 0.9554 0.6235 1.461
hu_birth_cohort1785M1790 1.102 0.7347 1.672
hu_birth_cohort1790M1795 1.321 0.89 1.947
hu_birth_cohort1795M1800 1.082 0.738 1.587
hu_birth_cohort1800M1805 0.9988 0.6849 1.465
hu_birth_cohort1805M1810 0.9556 0.6608 1.386
hu_birth_cohort1810M1815 1.028 0.708 1.495
hu_birth_cohort1815M1820 0.8731 0.599 1.272
hu_birth_cohort1820M1825 0.787 0.5425 1.139
hu_birth_cohort1825M1830 0.788 0.5435 1.139
hu_birth_cohort1830M1835 0.8018 0.5525 1.166
hu_birth_cohort1835M1840 0.7863 0.5424 1.139
hu_birth_cohort1840M1845 0.7966 0.5507 1.153
hu_birth_cohort1845M1850 0.828 0.57 1.19
hu_male1 1.046 1.006 1.087
hu_maternalage.factor1020 1.06 0.891 1.262
hu_maternalage.factor3559 1.073 1.014 1.136
hu_paternalage.mean 0.9257 0.8252 1.036
hu_paternal_loss01 2.389 1.991 2.86
hu_paternal_loss15 1.959 1.733 2.22
hu_paternal_loss510 1.998 1.803 2.226
hu_paternal_loss1015 1.693 1.539 1.863
hu_paternal_loss1520 1.536 1.406 1.677
hu_paternal_loss2025 1.384 1.275 1.502
hu_paternal_loss2530 1.255 1.159 1.358
hu_paternal_loss3035 1.176 1.089 1.268
hu_paternal_loss3540 1.129 1.05 1.214
hu_paternal_loss4045 1.04 0.9627 1.123
hu_maternal_loss01 6.248 4.969 7.915
hu_maternal_loss15 2.736 2.39 3.134
hu_maternal_loss510 2.344 2.099 2.619
hu_maternal_loss1015 2.213 1.993 2.455
hu_maternal_loss1520 1.946 1.764 2.149
hu_maternal_loss2025 1.568 1.436 1.714
hu_maternal_loss2530 1.363 1.256 1.477
hu_maternal_loss3035 1.274 1.184 1.372
hu_maternal_loss3540 1.154 1.079 1.237
hu_maternal_loss4045 1.075 1.002 1.152
hu_older_siblings1 0.9584 0.9009 1.018
hu_older_siblings2 0.9634 0.8894 1.042
hu_older_siblings3 0.9479 0.8559 1.049
hu_older_siblings4 0.9175 0.8096 1.04
hu_older_siblings5P 0.8595 0.7285 1.01
hu_nr.siblings 1.049 1.035 1.064
hu_last_born1 1.008 0.9577 1.062

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.22 [1.75;2.79] [1.9;2.58]
estimate father 35y 2.06 [1.61;2.6] [1.75;2.4]
percentage change -7.3 [-13.43;-0.8] [-11.17;-3.13]
OR/IRR 0.95 [0.91;0.99] [0.93;0.97]
OR hurdle 1.05 [0.94;1.17] [0.98;1.13]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.37        972    1
## sd(hu_Intercept)     0.82      0.02     0.79     0.85       1110    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.33      0.09     1.15     1.48        195
## paternalage                  -0.06      0.02    -0.09    -0.02        816
## male1                         0.03      0.03    -0.03     0.09       1469
## birth_cohort1750M1755        -0.17      0.12    -0.41     0.06        546
## birth_cohort1755M1760         0.09      0.10    -0.11     0.28        277
## birth_cohort1760M1765         0.15      0.09    -0.02     0.33        220
## birth_cohort1765M1770         0.09      0.09    -0.07     0.27        222
## birth_cohort1770M1775         0.06      0.09    -0.12     0.23        227
## birth_cohort1775M1780         0.04      0.09    -0.13     0.22        205
## birth_cohort1780M1785         0.15      0.09    -0.02     0.33        219
## birth_cohort1785M1790         0.12      0.09    -0.04     0.30        200
## birth_cohort1790M1795         0.02      0.08    -0.14     0.19        193
## birth_cohort1795M1800         0.02      0.08    -0.14     0.19        189
## birth_cohort1800M1805        -0.03      0.08    -0.18     0.14        189
## birth_cohort1805M1810        -0.01      0.08    -0.17     0.15        182
## birth_cohort1810M1815         0.01      0.08    -0.14     0.17        184
## birth_cohort1815M1820         0.06      0.08    -0.09     0.23        178
## birth_cohort1820M1825         0.08      0.08    -0.07     0.24        176
## birth_cohort1825M1830         0.04      0.08    -0.11     0.20        177
## birth_cohort1830M1835         0.06      0.08    -0.09     0.22        177
## birth_cohort1835M1840         0.06      0.08    -0.08     0.23        175
## birth_cohort1840M1845         0.04      0.08    -0.11     0.20        177
## birth_cohort1845M1850         0.05      0.08    -0.10     0.22        178
## maternalage.factor1020        0.04      0.03    -0.02     0.09       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       2162
## paternalage.mean              0.06      0.02     0.02     0.10        847
## paternal_loss01               0.06      0.04    -0.01     0.13       1853
## paternal_loss15               0.03      0.03    -0.02     0.08       1337
## paternal_loss510             -0.02      0.02    -0.06     0.02       1082
## paternal_loss1015            -0.02      0.02    -0.06     0.02       1018
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       1035
## paternal_loss2025            -0.03      0.02    -0.06     0.01       1084
## paternal_loss2530            -0.02      0.01    -0.05     0.01       1028
## paternal_loss3035            -0.01      0.01    -0.04     0.01       1174
## paternal_loss3540             0.02      0.01     0.00     0.05       1284
## paternal_loss4045             0.03      0.01     0.00     0.05       1610
## maternal_loss01               0.07      0.05    -0.04     0.17       2327
## maternal_loss15               0.00      0.03    -0.05     0.06       1911
## maternal_loss510             -0.02      0.02    -0.07     0.03       1640
## maternal_loss1015            -0.04      0.02    -0.08     0.01       1567
## maternal_loss1520            -0.04      0.02    -0.07     0.00       1431
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       1676
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1185
## maternal_loss3035            -0.02      0.01    -0.05     0.01       1328
## maternal_loss3540             0.00      0.01    -0.02     0.03       1484
## maternal_loss4045            -0.02      0.01    -0.04     0.00       1800
## older_siblings1               0.02      0.01     0.00     0.04       1250
## older_siblings2               0.03      0.01     0.00     0.06        956
## older_siblings3               0.04      0.02     0.00     0.07        854
## older_siblings4               0.01      0.02    -0.03     0.06        853
## older_siblings5P              0.03      0.03    -0.02     0.08        762
## nr.siblings                   0.02      0.00     0.02     0.03        775
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## paternalage:male1             0.00      0.01    -0.01     0.02       1453
## hu_Intercept                 -0.08      0.19    -0.47     0.29        269
## hu_paternalage                0.06      0.06    -0.06     0.17        701
## hu_male1                      0.09      0.09    -0.07     0.26       1888
## hu_birth_cohort1750M1755      0.37      0.28    -0.18     0.93        762
## hu_birth_cohort1755M1760      0.08      0.24    -0.37     0.55        442
## hu_birth_cohort1760M1765     -0.05      0.21    -0.47     0.37        341
## hu_birth_cohort1765M1770     -0.34      0.22    -0.76     0.11        345
## hu_birth_cohort1770M1775     -0.10      0.22    -0.52     0.34        334
## hu_birth_cohort1775M1780      0.05      0.21    -0.33     0.48        314
## hu_birth_cohort1780M1785     -0.01      0.21    -0.41     0.41        296
## hu_birth_cohort1785M1790      0.13      0.20    -0.25     0.52        283
## hu_birth_cohort1790M1795      0.31      0.19    -0.06     0.68        268
## hu_birth_cohort1795M1800      0.12      0.18    -0.24     0.47        253
## hu_birth_cohort1800M1805      0.04      0.18    -0.32     0.39        245
## hu_birth_cohort1805M1810     -0.01      0.18    -0.35     0.34        243
## hu_birth_cohort1810M1815      0.07      0.18    -0.28     0.41        237
## hu_birth_cohort1815M1820     -0.10      0.17    -0.44     0.24        233
## hu_birth_cohort1820M1825     -0.20      0.17    -0.55     0.13        235
## hu_birth_cohort1825M1830     -0.20      0.17    -0.55     0.14        232
## hu_birth_cohort1830M1835     -0.19      0.17    -0.53     0.15        233
## hu_birth_cohort1835M1840     -0.21      0.17    -0.54     0.13        233
## hu_birth_cohort1840M1845     -0.20      0.17    -0.53     0.14        231
## hu_birth_cohort1845M1850     -0.16      0.17    -0.50     0.18        232
## hu_maternalage.factor1020     0.06      0.09    -0.12     0.23       3000
## hu_maternalage.factor3559     0.07      0.03     0.01     0.13       3000
## hu_paternalage.mean          -0.08      0.06    -0.19     0.04        714
## hu_paternal_loss01            0.86      0.09     0.68     1.04       3000
## hu_paternal_loss15            0.67      0.06     0.55     0.79       1692
## hu_paternal_loss510           0.69      0.05     0.58     0.80       1352
## hu_paternal_loss1015          0.52      0.05     0.42     0.61       1257
## hu_paternal_loss1520          0.42      0.05     0.33     0.51       1261
## hu_paternal_loss2025          0.32      0.04     0.23     0.41       1372
## hu_paternal_loss2530          0.22      0.04     0.14     0.30       1214
## hu_paternal_loss3035          0.16      0.04     0.08     0.23       1269
## hu_paternal_loss3540          0.12      0.04     0.04     0.19       1389
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       1739
## hu_maternal_loss01            1.85      0.12     1.62     2.09       3000
## hu_maternal_loss15            1.02      0.07     0.89     1.16       3000
## hu_maternal_loss510           0.87      0.06     0.75     0.97       3000
## hu_maternal_loss1015          0.80      0.05     0.70     0.91       3000
## hu_maternal_loss1520          0.67      0.05     0.57     0.76       3000
## hu_maternal_loss2025          0.46      0.04     0.37     0.54       3000
## hu_maternal_loss2530          0.31      0.04     0.23     0.39       3000
## hu_maternal_loss3035          0.24      0.04     0.17     0.32       1713
## hu_maternal_loss3540          0.14      0.03     0.08     0.21       3000
## hu_maternal_loss4045          0.07      0.04     0.00     0.14       3000
## hu_older_siblings1           -0.04      0.03    -0.10     0.02       1268
## hu_older_siblings2           -0.04      0.04    -0.12     0.04        857
## hu_older_siblings3           -0.05      0.05    -0.16     0.05        796
## hu_older_siblings4           -0.09      0.06    -0.21     0.04        748
## hu_older_siblings5P          -0.15      0.08    -0.32     0.01        694
## hu_nr.siblings                0.05      0.01     0.03     0.06        817
## hu_last_born1                 0.01      0.03    -0.04     0.06       3000
## hu_paternalage:male1         -0.01      0.02    -0.06     0.03       1893
##                           Rhat
## Intercept                 1.03
## paternalage               1.01
## male1                     1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.02
## birth_cohort1760M1765     1.03
## birth_cohort1765M1770     1.02
## birth_cohort1770M1775     1.02
## birth_cohort1775M1780     1.02
## birth_cohort1780M1785     1.02
## 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
## birth_cohort1835M1840     1.03
## birth_cohort1840M1845     1.03
## birth_cohort1845M1850     1.03
## maternalage.factor1020    1.00
## maternalage.factor3559    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.01
## older_siblings2           1.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## paternalage:male1         1.00
## hu_Intercept              1.02
## hu_paternalage            1.00
## hu_male1                  1.00
## hu_birth_cohort1750M1755  1.01
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.01
## hu_birth_cohort1780M1785  1.01
## hu_birth_cohort1785M1790  1.02
## hu_birth_cohort1790M1795  1.02
## hu_birth_cohort1795M1800  1.02
## hu_birth_cohort1800M1805  1.02
## hu_birth_cohort1805M1810  1.02
## hu_birth_cohort1810M1815  1.02
## hu_birth_cohort1815M1820  1.02
## hu_birth_cohort1820M1825  1.02
## hu_birth_cohort1825M1830  1.02
## hu_birth_cohort1830M1835  1.02
## hu_birth_cohort1835M1840  1.02
## hu_birth_cohort1840M1845  1.02
## hu_birth_cohort1845M1850  1.02
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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.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 3.776 3.169 4.412
paternalage 0.9452 0.9108 0.9819
male1 1.028 0.9666 1.089
birth_cohort1750M1755 0.8399 0.6612 1.063
birth_cohort1755M1760 1.093 0.8985 1.327
birth_cohort1760M1765 1.156 0.9773 1.387
birth_cohort1765M1770 1.098 0.9296 1.312
birth_cohort1770M1775 1.057 0.8893 1.259
birth_cohort1775M1780 1.043 0.8809 1.251
birth_cohort1780M1785 1.161 0.9836 1.384
birth_cohort1785M1790 1.129 0.9629 1.347
birth_cohort1790M1795 1.021 0.8713 1.209
birth_cohort1795M1800 1.018 0.8708 1.205
birth_cohort1800M1805 0.9714 0.835 1.147
birth_cohort1805M1810 0.9856 0.8431 1.157
birth_cohort1810M1815 1.01 0.8704 1.188
birth_cohort1815M1820 1.064 0.9156 1.257
birth_cohort1820M1825 1.083 0.9331 1.274
birth_cohort1825M1830 1.038 0.895 1.222
birth_cohort1830M1835 1.065 0.9167 1.252
birth_cohort1835M1840 1.065 0.9198 1.254
birth_cohort1840M1845 1.042 0.8991 1.227
birth_cohort1845M1850 1.05 0.9053 1.241
maternalage.factor1020 1.036 0.9768 1.099
maternalage.factor3559 1.066 1.044 1.089
paternalage.mean 1.063 1.022 1.104
paternal_loss01 1.061 0.9866 1.144
paternal_loss15 1.027 0.9774 1.081
paternal_loss510 0.9816 0.9408 1.024
paternal_loss1015 0.9814 0.9438 1.018
paternal_loss1520 0.9303 0.8987 0.963
paternal_loss2025 0.9733 0.943 1.005
paternal_loss2530 0.9802 0.9514 1.009
paternal_loss3035 0.9856 0.9596 1.013
paternal_loss3540 1.022 0.9972 1.048
paternal_loss4045 1.029 1.002 1.056
maternal_loss01 1.068 0.9614 1.186
maternal_loss15 1.002 0.9466 1.057
maternal_loss510 0.9803 0.9349 1.026
maternal_loss1015 0.9645 0.9243 1.006
maternal_loss1520 0.9648 0.9289 1.004
maternal_loss2025 0.9318 0.9012 0.964
maternal_loss2530 0.9731 0.9444 1.002
maternal_loss3035 0.9792 0.9529 1.006
maternal_loss3540 1.002 0.9772 1.026
maternal_loss4045 0.9807 0.9582 1.005
older_siblings1 1.017 0.9965 1.04
older_siblings2 1.03 1.003 1.057
older_siblings3 1.039 1.003 1.075
older_siblings4 1.015 0.9717 1.057
older_siblings5P 1.03 0.9758 1.087
nr.siblings 1.023 1.018 1.029
last_born1 0.9789 0.961 0.997
paternalage:male1 1.004 0.9869 1.021
hu_Intercept 0.9187 0.6273 1.33
hu_paternalage 1.058 0.9431 1.183
hu_male1 1.097 0.9299 1.296
hu_birth_cohort1750M1755 1.445 0.8376 2.529
hu_birth_cohort1755M1760 1.083 0.688 1.738
hu_birth_cohort1760M1765 0.9504 0.6274 1.453
hu_birth_cohort1765M1770 0.7137 0.4696 1.118
hu_birth_cohort1770M1775 0.9044 0.5955 1.401
hu_birth_cohort1775M1780 1.056 0.7161 1.623
hu_birth_cohort1780M1785 0.9923 0.6634 1.504
hu_birth_cohort1785M1790 1.141 0.7783 1.674
hu_birth_cohort1790M1795 1.37 0.9458 1.97
hu_birth_cohort1795M1800 1.125 0.7902 1.608
hu_birth_cohort1800M1805 1.036 0.7262 1.474
hu_birth_cohort1805M1810 0.9927 0.7022 1.409
hu_birth_cohort1810M1815 1.07 0.7528 1.512
hu_birth_cohort1815M1820 0.9044 0.6464 1.271
hu_birth_cohort1820M1825 0.8151 0.576 1.135
hu_birth_cohort1825M1830 0.8159 0.5765 1.149
hu_birth_cohort1830M1835 0.8292 0.591 1.164
hu_birth_cohort1835M1840 0.8118 0.5803 1.142
hu_birth_cohort1840M1845 0.8226 0.5908 1.155
hu_birth_cohort1845M1850 0.8532 0.6092 1.2
hu_maternalage.factor1020 1.06 0.8894 1.261
hu_maternalage.factor3559 1.073 1.011 1.137
hu_paternalage.mean 0.9267 0.8304 1.04
hu_paternal_loss01 2.372 1.982 2.827
hu_paternal_loss15 1.95 1.728 2.204
hu_paternal_loss510 1.991 1.789 2.217
hu_paternal_loss1015 1.682 1.529 1.846
hu_paternal_loss1520 1.524 1.39 1.671
hu_paternal_loss2025 1.376 1.265 1.499
hu_paternal_loss2530 1.251 1.152 1.355
hu_paternal_loss3035 1.169 1.081 1.264
hu_paternal_loss3540 1.125 1.04 1.213
hu_paternal_loss4045 1.04 0.962 1.124
hu_maternal_loss01 6.384 5.037 8.059
hu_maternal_loss15 2.779 2.428 3.189
hu_maternal_loss510 2.375 2.121 2.639
hu_maternal_loss1015 2.234 2.014 2.484
hu_maternal_loss1520 1.955 1.772 2.149
hu_maternal_loss2025 1.579 1.446 1.721
hu_maternal_loss2530 1.368 1.259 1.48
hu_maternal_loss3035 1.277 1.185 1.374
hu_maternal_loss3540 1.155 1.081 1.233
hu_maternal_loss4045 1.078 1.003 1.153
hu_older_siblings1 0.9586 0.9023 1.019
hu_older_siblings2 0.9641 0.8877 1.043
hu_older_siblings3 0.9481 0.856 1.053
hu_older_siblings4 0.9178 0.8124 1.042
hu_older_siblings5P 0.8595 0.7282 1.012
hu_nr.siblings 1.049 1.034 1.064
hu_last_born1 1.008 0.9568 1.062
hu_paternalage:male1 0.9865 0.9415 1.033

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.26 [1.79;2.83] [1.95;2.63]
estimate father 35y 2.08 [1.63;2.62] [1.79;2.44]
percentage change -7.88 [-13.91;-1.34] [-11.9;-3.81]
OR/IRR 0.95 [0.91;0.98] [0.92;0.97]
OR hurdle 1.06 [0.94;1.18] [0.98;1.14]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37       1008 1.00
## sd(hu_Intercept)     0.82      0.02     0.79     0.85       1011 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.29      0.08     1.12     1.44         97
## paternalage                  -0.06      0.02    -0.10    -0.02        661
## birth_cohort1750M1755        -0.17      0.12    -0.39     0.07        587
## birth_cohort1755M1760         0.09      0.09    -0.08     0.28        214
## birth_cohort1760M1765         0.15      0.09    -0.01     0.32        162
## birth_cohort1765M1770         0.10      0.09    -0.05     0.28        149
## birth_cohort1770M1775         0.06      0.09    -0.11     0.25        143
## birth_cohort1775M1780         0.05      0.09    -0.11     0.23        137
## birth_cohort1780M1785         0.16      0.09    -0.01     0.33        149
## birth_cohort1785M1790         0.13      0.08    -0.03     0.30         98
## birth_cohort1790M1795         0.02      0.08    -0.12     0.19        121
## birth_cohort1795M1800         0.02      0.08    -0.12     0.19        116
## birth_cohort1800M1805        -0.03      0.08    -0.17     0.14        115
## birth_cohort1805M1810        -0.01      0.08    -0.16     0.15        116
## birth_cohort1810M1815         0.01      0.08    -0.12     0.18         87
## birth_cohort1815M1820         0.07      0.08    -0.07     0.23         87
## birth_cohort1820M1825         0.08      0.08    -0.05     0.25        112
## birth_cohort1825M1830         0.04      0.08    -0.09     0.21         89
## birth_cohort1830M1835         0.07      0.08    -0.07     0.23        111
## birth_cohort1835M1840         0.07      0.08    -0.07     0.24        111
## birth_cohort1840M1845         0.05      0.08    -0.08     0.21        111
## birth_cohort1845M1850         0.06      0.08    -0.08     0.22         90
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.04      0.03    -0.02     0.10       2459
## maternalage.factor3559        0.06      0.01     0.04     0.08       1964
## paternalage_at_1st_sib        0.06      0.02     0.03     0.09       1036
## paternalage.mean              0.02      0.02    -0.03     0.06        633
## paternal_loss01               0.06      0.04    -0.01     0.13       1422
## paternal_loss15               0.02      0.02    -0.02     0.07        919
## paternal_loss510             -0.02      0.02    -0.06     0.02       1031
## paternal_loss1015            -0.02      0.02    -0.06     0.01        835
## paternal_loss1520            -0.07      0.02    -0.11    -0.04        886
## paternal_loss2025            -0.03      0.02    -0.06     0.00        950
## paternal_loss2530            -0.02      0.01    -0.05     0.01        825
## paternal_loss3035            -0.02      0.01    -0.04     0.01        898
## paternal_loss3540             0.02      0.01     0.00     0.05       1167
## paternal_loss4045             0.03      0.01     0.00     0.05       1471
## maternal_loss01               0.06      0.05    -0.04     0.17       1682
## maternal_loss15               0.00      0.03    -0.05     0.06       1779
## maternal_loss510             -0.02      0.02    -0.07     0.03       1472
## maternal_loss1015            -0.04      0.02    -0.08     0.01       1336
## maternal_loss1520            -0.04      0.02    -0.07     0.00       1393
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       1201
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1131
## maternal_loss3035            -0.02      0.01    -0.05     0.01       1258
## maternal_loss3540             0.00      0.01    -0.02     0.03       1371
## maternal_loss4045            -0.02      0.01    -0.04     0.00       1794
## older_siblings1               0.02      0.01     0.00     0.04       1153
## older_siblings2               0.03      0.01     0.00     0.06        750
## older_siblings3               0.04      0.02     0.01     0.08        707
## older_siblings4               0.02      0.02    -0.02     0.06        687
## older_siblings5P              0.03      0.03    -0.02     0.09        619
## nr.siblings                   0.03      0.00     0.02     0.03        649
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                  0.02      0.22    -0.41     0.45        174
## hu_paternalage                0.06      0.06    -0.05     0.17        589
## hu_birth_cohort1750M1755      0.36      0.30    -0.19     0.94        394
## hu_birth_cohort1755M1760      0.08      0.26    -0.43     0.58        264
## hu_birth_cohort1760M1765     -0.04      0.24    -0.51     0.44        219
## hu_birth_cohort1765M1770     -0.34      0.24    -0.79     0.12        216
## hu_birth_cohort1770M1775     -0.11      0.25    -0.58     0.37        211
## hu_birth_cohort1775M1780      0.04      0.23    -0.40     0.50        204
## hu_birth_cohort1780M1785     -0.01      0.23    -0.47     0.44        209
## hu_birth_cohort1785M1790      0.14      0.22    -0.30     0.58        191
## hu_birth_cohort1790M1795      0.33      0.21    -0.08     0.74        178
## hu_birth_cohort1795M1800      0.13      0.21    -0.28     0.53        172
## hu_birth_cohort1800M1805      0.05      0.21    -0.36     0.45        171
## hu_birth_cohort1805M1810      0.00      0.21    -0.40     0.40        162
## hu_birth_cohort1810M1815      0.07      0.21    -0.34     0.47        164
## hu_birth_cohort1815M1820     -0.09      0.20    -0.49     0.29        162
## hu_birth_cohort1820M1825     -0.20      0.20    -0.60     0.19        165
## hu_birth_cohort1825M1830     -0.20      0.20    -0.60     0.19        162
## hu_birth_cohort1830M1835     -0.19      0.20    -0.59     0.20        164
## hu_birth_cohort1835M1840     -0.22      0.20    -0.61     0.17        163
## hu_birth_cohort1840M1845     -0.21      0.20    -0.61     0.19        164
## hu_birth_cohort1845M1850     -0.17      0.20    -0.56     0.23        162
## hu_male1                      0.04      0.02     0.01     0.08       3000
## hu_maternalage.factor1020     0.05      0.09    -0.12     0.24       3000
## hu_maternalage.factor3559     0.07      0.03     0.02     0.13       1807
## hu_paternalage_at_1st_sib    -0.16      0.04    -0.23    -0.08       1717
## hu_paternalage.mean           0.04      0.06    -0.08     0.16        646
## hu_paternal_loss01            0.87      0.09     0.69     1.06       3000
## hu_paternal_loss15            0.67      0.06     0.55     0.79       1452
## hu_paternal_loss510           0.69      0.05     0.58     0.79       1219
## hu_paternal_loss1015          0.52      0.05     0.43     0.61       1354
## hu_paternal_loss1520          0.42      0.04     0.33     0.51       1220
## hu_paternal_loss2025          0.32      0.04     0.24     0.40       1123
## hu_paternal_loss2530          0.22      0.04     0.15     0.30       1200
## hu_paternal_loss3035          0.16      0.04     0.08     0.23       1269
## hu_paternal_loss3540          0.12      0.04     0.05     0.19       1301
## hu_paternal_loss4045          0.04      0.04    -0.03     0.11       3000
## hu_maternal_loss01            1.87      0.12     1.65     2.09       3000
## hu_maternal_loss15            1.03      0.07     0.89     1.16       1923
## hu_maternal_loss510           0.87      0.06     0.76     0.98       1864
## hu_maternal_loss1015          0.81      0.06     0.70     0.91       2017
## hu_maternal_loss1520          0.67      0.05     0.57     0.77       1730
## hu_maternal_loss2025          0.46      0.05     0.37     0.54       3000
## hu_maternal_loss2530          0.32      0.04     0.24     0.40       1686
## hu_maternal_loss3035          0.25      0.04     0.17     0.32       1492
## hu_maternal_loss3540          0.14      0.03     0.08     0.21       1724
## hu_maternal_loss4045          0.07      0.04     0.01     0.14       2022
## hu_older_siblings1           -0.05      0.03    -0.11     0.01       1084
## hu_older_siblings2           -0.05      0.04    -0.12     0.03        714
## hu_older_siblings3           -0.07      0.05    -0.17     0.04        664
## hu_older_siblings4           -0.10      0.06    -0.22     0.02        631
## hu_older_siblings5P          -0.17      0.08    -0.33    -0.01        568
## hu_nr.siblings                0.04      0.01     0.02     0.05        718
## hu_last_born1                 0.01      0.03    -0.04     0.06       3000
##                           Rhat
## Intercept                 1.05
## paternalage               1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.03
## birth_cohort1760M1765     1.04
## birth_cohort1765M1770     1.04
## birth_cohort1770M1775     1.04
## birth_cohort1775M1780     1.04
## birth_cohort1780M1785     1.04
## birth_cohort1785M1790     1.05
## birth_cohort1790M1795     1.05
## birth_cohort1795M1800     1.05
## birth_cohort1800M1805     1.05
## birth_cohort1805M1810     1.05
## birth_cohort1810M1815     1.06
## birth_cohort1815M1820     1.06
## birth_cohort1820M1825     1.05
## birth_cohort1825M1830     1.05
## birth_cohort1830M1835     1.05
## birth_cohort1835M1840     1.05
## birth_cohort1840M1845     1.05
## birth_cohort1845M1850     1.05
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    1.00
## paternalage_at_1st_sib    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.00
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.01
## hu_paternalage            1.01
## hu_birth_cohort1750M1755  1.00
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## 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_birth_cohort1835M1840  1.01
## hu_birth_cohort1840M1845  1.01
## hu_birth_cohort1845M1850  1.01
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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.01
## 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.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 3.633 3.066 4.232
paternalage 0.9433 0.9083 0.9796
birth_cohort1750M1755 0.8469 0.6757 1.07
birth_cohort1755M1760 1.1 0.922 1.325
birth_cohort1760M1765 1.162 0.9873 1.384
birth_cohort1765M1770 1.107 0.9481 1.326
birth_cohort1770M1775 1.064 0.8987 1.285
birth_cohort1775M1780 1.052 0.8931 1.26
birth_cohort1780M1785 1.17 0.9919 1.39
birth_cohort1785M1790 1.134 0.9666 1.345
birth_cohort1790M1795 1.024 0.8831 1.214
birth_cohort1795M1800 1.022 0.883 1.21
birth_cohort1800M1805 0.9747 0.8466 1.149
birth_cohort1805M1810 0.9882 0.8556 1.164
birth_cohort1810M1815 1.015 0.8835 1.195
birth_cohort1815M1820 1.067 0.9309 1.258
birth_cohort1820M1825 1.088 0.9489 1.284
birth_cohort1825M1830 1.046 0.9137 1.23
birth_cohort1830M1835 1.074 0.9356 1.264
birth_cohort1835M1840 1.075 0.9361 1.266
birth_cohort1840M1845 1.053 0.9192 1.238
birth_cohort1845M1850 1.061 0.9244 1.246
male1 1.041 1.027 1.055
maternalage.factor1020 1.04 0.9809 1.105
maternalage.factor3559 1.065 1.043 1.088
paternalage_at_1st_sib 1.06 1.027 1.096
paternalage.mean 1.018 0.972 1.064
paternal_loss01 1.059 0.9863 1.135
paternal_loss15 1.025 0.9759 1.076
paternal_loss510 0.9809 0.9404 1.023
paternal_loss1015 0.9803 0.9455 1.014
paternal_loss1520 0.9304 0.8985 0.9633
paternal_loss2025 0.9725 0.9431 1.004
paternal_loss2530 0.9793 0.9518 1.008
paternal_loss3035 0.9847 0.9588 1.012
paternal_loss3540 1.021 0.9956 1.046
paternal_loss4045 1.028 1.002 1.055
maternal_loss01 1.065 0.9573 1.182
maternal_loss15 1.001 0.9483 1.06
maternal_loss510 0.9792 0.9352 1.026
maternal_loss1015 0.9641 0.9232 1.006
maternal_loss1520 0.9654 0.929 1.004
maternal_loss2025 0.932 0.9011 0.9637
maternal_loss2530 0.9727 0.944 1.002
maternal_loss3035 0.9797 0.9545 1.007
maternal_loss3540 1.002 0.9781 1.026
maternal_loss4045 0.9804 0.9578 1.005
older_siblings1 1.019 0.9977 1.04
older_siblings2 1.033 1.004 1.062
older_siblings3 1.042 1.008 1.078
older_siblings4 1.018 0.9762 1.064
older_siblings5P 1.035 0.9789 1.093
nr.siblings 1.027 1.022 1.033
last_born1 0.9792 0.9608 0.9976
hu_Intercept 1.016 0.6626 1.569
hu_paternalage 1.066 0.9551 1.188
hu_birth_cohort1750M1755 1.43 0.8257 2.564
hu_birth_cohort1755M1760 1.086 0.6513 1.793
hu_birth_cohort1760M1765 0.9638 0.6033 1.546
hu_birth_cohort1765M1770 0.712 0.453 1.13
hu_birth_cohort1770M1775 0.897 0.5608 1.444
hu_birth_cohort1775M1780 1.044 0.6688 1.645
hu_birth_cohort1780M1785 0.9883 0.6273 1.551
hu_birth_cohort1785M1790 1.15 0.7401 1.781
hu_birth_cohort1790M1795 1.39 0.9189 2.09
hu_birth_cohort1795M1800 1.138 0.7588 1.7
hu_birth_cohort1800M1805 1.046 0.6997 1.568
hu_birth_cohort1805M1810 1.001 0.6722 1.491
hu_birth_cohort1810M1815 1.075 0.7153 1.598
hu_birth_cohort1815M1820 0.9138 0.6153 1.34
hu_birth_cohort1820M1825 0.8194 0.5507 1.209
hu_birth_cohort1825M1830 0.8149 0.5504 1.204
hu_birth_cohort1830M1835 0.8263 0.554 1.227
hu_birth_cohort1835M1840 0.8061 0.5424 1.189
hu_birth_cohort1840M1845 0.8139 0.5418 1.213
hu_birth_cohort1845M1850 0.847 0.5684 1.256
hu_male1 1.045 1.005 1.086
hu_maternalage.factor1020 1.053 0.886 1.268
hu_maternalage.factor3559 1.076 1.016 1.14
hu_paternalage_at_1st_sib 0.8523 0.7912 0.9201
hu_paternalage.mean 1.036 0.9215 1.174
hu_paternal_loss01 2.394 2 2.876
hu_paternal_loss15 1.959 1.734 2.212
hu_paternal_loss510 1.991 1.794 2.207
hu_paternal_loss1015 1.682 1.533 1.844
hu_paternal_loss1520 1.522 1.396 1.663
hu_paternal_loss2025 1.376 1.267 1.493
hu_paternal_loss2530 1.25 1.157 1.35
hu_paternal_loss3035 1.17 1.087 1.261
hu_paternal_loss3540 1.127 1.052 1.208
hu_paternal_loss4045 1.041 0.9659 1.121
hu_maternal_loss01 6.469 5.205 8.122
hu_maternal_loss15 2.805 2.438 3.205
hu_maternal_loss510 2.38 2.128 2.669
hu_maternal_loss1015 2.24 2.014 2.488
hu_maternal_loss1520 1.958 1.769 2.161
hu_maternal_loss2025 1.579 1.445 1.723
hu_maternal_loss2530 1.373 1.266 1.49
hu_maternal_loss3035 1.278 1.191 1.374
hu_maternal_loss3540 1.155 1.081 1.236
hu_maternal_loss4045 1.077 1.007 1.153
hu_older_siblings1 0.9529 0.8986 1.013
hu_older_siblings2 0.9535 0.8831 1.03
hu_older_siblings3 0.935 0.8451 1.037
hu_older_siblings4 0.9032 0.7988 1.022
hu_older_siblings5P 0.843 0.7181 0.9908
hu_nr.siblings 1.038 1.023 1.054
hu_last_born1 1.007 0.9572 1.06

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.23 [1.72;2.77] [1.89;2.59]
estimate father 35y 2.04 [1.56;2.58] [1.72;2.39]
percentage change -8.34 [-14.9;-2.41] [-12.48;-4.45]
OR/IRR 0.94 [0.91;0.98] [0.92;0.97]
OR hurdle 1.07 [0.96;1.19] [0.99;1.14]

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/ddb/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 
## -9.442 -1.463 -0.133  0.841 17.148 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## paternalage                -0.6177     0.1450   -4.26  2.1e-05 ***
## birth_cohort1750-1755      -0.4029     0.4430   -0.91  0.36311    
## birth_cohort1755-1760       0.1612     0.4829    0.33  0.73852    
## birth_cohort1760-1765       0.2469     0.5368    0.46  0.64562    
## birth_cohort1765-1770       0.5396     0.5644    0.96  0.33905    
## birth_cohort1770-1775       0.1969     0.6053    0.33  0.74499    
## birth_cohort1775-1780      -0.0625     0.6327   -0.10  0.92137    
## birth_cohort1780-1785       0.2182     0.6690    0.33  0.74429    
## birth_cohort1785-1790       0.2372     0.7075    0.34  0.73747    
## birth_cohort1790-1795       0.0750     0.7385    0.10  0.91916    
## birth_cohort1795-1800       0.2232     0.7695    0.29  0.77180    
## birth_cohort1800-1805       0.2870     0.8028    0.36  0.72068    
## birth_cohort1805-1810       0.4110     0.8343    0.49  0.62229    
## birth_cohort1810-1815       0.5043     0.8682    0.58  0.56131    
## birth_cohort1815-1820       0.6558     0.9026    0.73  0.46752    
## birth_cohort1820-1825       0.8581     0.9373    0.92  0.35996    
## birth_cohort1825-1830       0.8446     0.9726    0.87  0.38519    
## birth_cohort1830-1835       0.9453     1.0093    0.94  0.34895    
## birth_cohort1835-1840       1.0612     1.0461    1.01  0.31039    
## birth_cohort1840-1845       1.0310     1.0852    0.95  0.34212    
## birth_cohort1845-1850       0.9407     1.1226    0.84  0.40207    
## male1                       0.0591     0.0288    2.05  0.04037 *  
## maternalage.factor(10,20]   0.0638     0.1437    0.44  0.65696    
## maternalage.factor(35,59]   0.0437     0.0525    0.83  0.40524    
## paternal_loss[0,1]          0.1749     0.3588    0.49  0.62591    
## paternal_loss(1,5]          0.3016     0.3220    0.94  0.34889    
## paternal_loss(5,10]         0.1500     0.2888    0.52  0.60342    
## paternal_loss(10,15]        0.2127     0.2549    0.83  0.40407    
## paternal_loss(15,20]        0.0735     0.2218    0.33  0.74030    
## paternal_loss(20,25]        0.1664     0.1895    0.88  0.37992    
## paternal_loss(25,30]        0.1666     0.1576    1.06  0.29051    
## paternal_loss(30,35]        0.1654     0.1266    1.31  0.19141    
## paternal_loss(35,40]        0.1392     0.0973    1.43  0.15252    
## paternal_loss(40,45]        0.1791     0.0766    2.34  0.01930 *  
## maternal_loss[0,1]         -1.5728     0.3213   -4.89  9.9e-07 ***
## maternal_loss(1,5]         -0.9552     0.2832   -3.37  0.00074 ***
## maternal_loss(5,10]        -0.7429     0.2532   -2.93  0.00335 ** 
## maternal_loss(10,15]       -0.6736     0.2246   -3.00  0.00271 ** 
## maternal_loss(15,20]       -0.6590     0.1952   -3.38  0.00073 ***
## maternal_loss(20,25]       -0.4887     0.1655   -2.95  0.00315 ** 
## maternal_loss(25,30]       -0.2509     0.1369   -1.83  0.06687 .  
## maternal_loss(30,35]       -0.1930     0.1101   -1.75  0.07952 .  
## maternal_loss(35,40]       -0.0771     0.0845   -0.91  0.36149    
## maternal_loss(40,45]       -0.0701     0.0675   -1.04  0.29893    
## older_siblings1             0.1731     0.0436    3.97  7.3e-05 ***
## older_siblings2             0.2841     0.0584    4.86  1.2e-06 ***
## older_siblings3             0.3844     0.0749    5.13  2.9e-07 ***
## older_siblings4             0.4090     0.0916    4.46  8.1e-06 ***
## older_siblings5+            0.4647     0.1174    3.96  7.5e-05 ***
## last_born1                 -0.0529     0.0365   -1.45  0.14720    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.95 on 41867 degrees of freedom
## Multiple R-squared(full model): 0.376   Adjusted R-squared: 0.155 
## Multiple R-squared(proj model): 0.00625   Adjusted R-squared: -0.345 
## F-statistic(full model): 1.7 on 14795 and 41867 DF, p-value: <2e-16 
## F-statistic(proj model): 5.27 on 50 and 41867 DF, p-value: <2e-16

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 * region + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) + (1 | parish_code) 
##          hu ~ paternalage + region + birth_cohort + male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) + (1 | parish_code) + paternalage:region
##    Data: model_data (Number of observations: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.30      0.01     0.29     0.31       1029 1.01
## sd(hu_Intercept)     0.61      0.02     0.57     0.64        800 1.00
## 
## ~parish_code (Number of levels: 34) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.11      0.02     0.09     0.15        796    1
## sd(hu_Intercept)     0.24      0.04     0.18     0.31        778    1
## 
## Population-Level Effects: 
##                                   Estimate Est.Error l-95% CI u-95% CI
## Intercept                             1.69      0.11     1.47     1.90
## paternalage                          -0.04      0.02    -0.08     0.00
## regionLinkopings                     -0.42      0.09    -0.61    -0.25
## regionNorrainlands                    0.00      0.09    -0.19     0.17
## regionSundsvalls                     -0.45      0.09    -0.62    -0.27
## birth_cohort1750M1755                -0.17      0.11    -0.39     0.05
## birth_cohort1755M1760                 0.01      0.09    -0.17     0.19
## birth_cohort1760M1765                 0.03      0.08    -0.14     0.19
## birth_cohort1765M1770                -0.01      0.08    -0.18     0.15
## birth_cohort1770M1775                -0.05      0.09    -0.22     0.11
## birth_cohort1775M1780                -0.07      0.08    -0.24     0.09
## birth_cohort1780M1785                 0.06      0.08    -0.11     0.21
## birth_cohort1785M1790                 0.07      0.08    -0.09     0.23
## birth_cohort1790M1795                 0.00      0.08    -0.16     0.14
## birth_cohort1795M1800                 0.02      0.08    -0.14     0.17
## birth_cohort1800M1805                -0.03      0.08    -0.19     0.12
## birth_cohort1805M1810                -0.02      0.08    -0.17     0.12
## birth_cohort1810M1815                 0.00      0.08    -0.15     0.14
## birth_cohort1815M1820                 0.03      0.08    -0.12     0.17
## birth_cohort1820M1825                 0.05      0.08    -0.10     0.19
## birth_cohort1825M1830                 0.00      0.08    -0.14     0.15
## birth_cohort1830M1835                 0.03      0.08    -0.12     0.17
## birth_cohort1835M1840                 0.02      0.08    -0.12     0.16
## birth_cohort1840M1845                 0.00      0.08    -0.15     0.14
## birth_cohort1845M1850                -0.01      0.08    -0.15     0.13
## male1                                 0.04      0.01     0.03     0.05
## maternalage.factor1020                0.04      0.03    -0.02     0.10
## maternalage.factor3559                0.04      0.01     0.02     0.06
## paternalage.mean                      0.04      0.02     0.00     0.07
## paternal_loss01                       0.07      0.04    -0.01     0.13
## paternal_loss15                       0.03      0.02    -0.01     0.08
## paternal_loss510                      0.01      0.02    -0.03     0.05
## paternal_loss1015                     0.01      0.02    -0.02     0.05
## paternal_loss1520                    -0.04      0.02    -0.07    -0.01
## paternal_loss2025                     0.00      0.02    -0.03     0.03
## paternal_loss2530                     0.00      0.01    -0.03     0.03
## paternal_loss3035                     0.00      0.01    -0.03     0.03
## paternal_loss3540                     0.03      0.01     0.00     0.05
## paternal_loss4045                     0.03      0.01     0.01     0.06
## maternal_loss01                       0.03      0.05    -0.08     0.13
## maternal_loss15                      -0.04      0.03    -0.09     0.02
## maternal_loss510                     -0.03      0.02    -0.08     0.01
## maternal_loss1015                    -0.04      0.02    -0.08     0.00
## maternal_loss1520                    -0.03      0.02    -0.06     0.01
## maternal_loss2025                    -0.06      0.02    -0.09    -0.03
## maternal_loss2530                    -0.01      0.01    -0.04     0.01
## maternal_loss3035                    -0.01      0.01    -0.04     0.02
## maternal_loss3540                     0.01      0.01    -0.02     0.03
## maternal_loss4045                    -0.02      0.01    -0.04     0.01
## older_siblings1                       0.02      0.01     0.00     0.04
## older_siblings2                       0.03      0.01     0.00     0.05
## older_siblings3                       0.04      0.02     0.01     0.07
## older_siblings4                       0.01      0.02    -0.03     0.05
## older_siblings5P                      0.04      0.03    -0.02     0.09
## nr.siblings                           0.01      0.00     0.00     0.01
## last_born1                           -0.02      0.01    -0.04     0.00
## paternalage:regionLinkopings          0.01      0.02    -0.02     0.04
## paternalage:regionNorrainlands       -0.02      0.01    -0.05     0.00
## paternalage:regionSundsvalls          0.02      0.01    -0.01     0.05
## hu_Intercept                         -0.71      0.25    -1.20    -0.23
## hu_paternalage                        0.08      0.06    -0.04     0.20
## hu_regionLinkopings                   1.21      0.21     0.80     1.62
## hu_regionNorrainlands                -0.05      0.21    -0.46     0.37
## hu_regionSundsvalls                   0.33      0.21    -0.07     0.73
## hu_birth_cohort1750M1755              0.42      0.28    -0.10     0.96
## hu_birth_cohort1755M1760              0.34      0.24    -0.12     0.80
## hu_birth_cohort1760M1765              0.34      0.22    -0.08     0.77
## hu_birth_cohort1765M1770              0.02      0.21    -0.40     0.46
## hu_birth_cohort1770M1775              0.23      0.22    -0.20     0.67
## hu_birth_cohort1775M1780              0.42      0.21     0.01     0.83
## hu_birth_cohort1780M1785              0.32      0.21    -0.11     0.72
## hu_birth_cohort1785M1790              0.25      0.20    -0.13     0.63
## hu_birth_cohort1790M1795              0.25      0.19    -0.11     0.62
## hu_birth_cohort1795M1800              0.00      0.19    -0.38     0.36
## hu_birth_cohort1800M1805             -0.01      0.18    -0.38     0.34
## hu_birth_cohort1805M1810              0.05      0.18    -0.30     0.41
## hu_birth_cohort1810M1815              0.16      0.18    -0.20     0.52
## hu_birth_cohort1815M1820              0.16      0.18    -0.19     0.51
## hu_birth_cohort1820M1825              0.07      0.18    -0.28     0.42
## hu_birth_cohort1825M1830              0.08      0.18    -0.28     0.42
## hu_birth_cohort1830M1835              0.09      0.18    -0.26     0.43
## hu_birth_cohort1835M1840              0.08      0.18    -0.27     0.43
## hu_birth_cohort1840M1845              0.10      0.18    -0.25     0.45
## hu_birth_cohort1845M1850              0.17      0.18    -0.19     0.51
## hu_male1                              0.04      0.02     0.01     0.08
## hu_maternalage.factor1020             0.04      0.09    -0.14     0.21
## hu_maternalage.factor3559             0.12      0.03     0.07     0.18
## hu_paternalage.mean                  -0.11      0.06    -0.22     0.00
## hu_paternal_loss01                    0.71      0.09     0.53     0.90
## hu_paternal_loss15                    0.47      0.06     0.35     0.59
## hu_paternal_loss510                   0.48      0.05     0.39     0.59
## hu_paternal_loss1015                  0.32      0.05     0.23     0.41
## hu_paternal_loss1520                  0.26      0.04     0.17     0.34
## hu_paternal_loss2025                  0.17      0.04     0.09     0.25
## hu_paternal_loss2530                  0.11      0.04     0.02     0.18
## hu_paternal_loss3035                  0.07      0.04    -0.01     0.14
## hu_paternal_loss3540                  0.06      0.04     0.00     0.14
## hu_paternal_loss4045                  0.01      0.04    -0.06     0.09
## hu_maternal_loss01                    1.71      0.12     1.48     1.94
## hu_maternal_loss15                    0.87      0.07     0.74     1.00
## hu_maternal_loss510                   0.69      0.06     0.58     0.80
## hu_maternal_loss1015                  0.62      0.05     0.52     0.72
## hu_maternal_loss1520                  0.50      0.05     0.41     0.60
## hu_maternal_loss2025                  0.32      0.04     0.24     0.40
## hu_maternal_loss2530                  0.19      0.04     0.12     0.27
## hu_maternal_loss3035                  0.14      0.04     0.07     0.21
## hu_maternal_loss3540                  0.07      0.03     0.00     0.13
## hu_maternal_loss4045                  0.02      0.04    -0.04     0.09
## hu_older_siblings1                   -0.06      0.03    -0.12     0.00
## hu_older_siblings2                   -0.07      0.04    -0.15     0.01
## hu_older_siblings3                   -0.10      0.05    -0.20     0.01
## hu_older_siblings4                   -0.13      0.06    -0.26    -0.01
## hu_older_siblings5P                  -0.21      0.08    -0.37    -0.05
## hu_nr.siblings                        0.07      0.01     0.06     0.09
## hu_last_born1                         0.00      0.03    -0.05     0.06
## hu_paternalage:regionLinkopings       0.03      0.04    -0.04     0.11
## hu_paternalage:regionNorrainlands     0.04      0.04    -0.03     0.11
## hu_paternalage:regionSundsvalls       0.01      0.04    -0.06     0.08
##                                   Eff.Sample Rhat
## Intercept                                121 1.05
## paternalage                              941 1.01
## regionLinkopings                        1027 1.00
## regionNorrainlands                       936 1.00
## regionSundsvalls                        1015 1.00
## birth_cohort1750M1755                    432 1.02
## birth_cohort1755M1760                    100 1.06
## birth_cohort1760M1765                     78 1.08
## birth_cohort1765M1770                     71 1.08
## birth_cohort1770M1775                     76 1.08
## birth_cohort1775M1780                     78 1.08
## birth_cohort1780M1785                     82 1.07
## birth_cohort1785M1790                    164 1.07
## birth_cohort1790M1795                     72 1.08
## birth_cohort1795M1800                     69 1.09
## birth_cohort1800M1805                     67 1.09
## birth_cohort1805M1810                     64 1.10
## birth_cohort1810M1815                     66 1.09
## birth_cohort1815M1820                     63 1.10
## birth_cohort1820M1825                     63 1.10
## birth_cohort1825M1830                     63 1.10
## birth_cohort1830M1835                     63 1.10
## birth_cohort1835M1840                     63 1.10
## birth_cohort1840M1845                     63 1.10
## birth_cohort1845M1850                     64 1.09
## male1                                   3000 1.00
## maternalage.factor1020                  3000 1.00
## maternalage.factor3559                  3000 1.00
## paternalage.mean                         838 1.00
## paternal_loss01                         3000 1.00
## paternal_loss15                         1800 1.00
## paternal_loss510                        1590 1.00
## paternal_loss1015                       1510 1.00
## paternal_loss1520                       1438 1.00
## paternal_loss2025                       1538 1.00
## paternal_loss2530                       1471 1.00
## paternal_loss3035                       1413 1.00
## paternal_loss3540                       1641 1.00
## paternal_loss4045                       3000 1.00
## maternal_loss01                         3000 1.00
## maternal_loss15                         3000 1.00
## maternal_loss510                        2306 1.00
## maternal_loss1015                       1740 1.00
## maternal_loss1520                       2145 1.00
## maternal_loss2025                       1875 1.00
## maternal_loss2530                       1847 1.00
## maternal_loss3035                       1764 1.00
## maternal_loss3540                       1930 1.00
## maternal_loss4045                       3000 1.00
## older_siblings1                         1902 1.00
## older_siblings2                         1217 1.00
## older_siblings3                         1069 1.00
## older_siblings4                         1050 1.00
## older_siblings5P                         973 1.00
## nr.siblings                             1267 1.00
## last_born1                              3000 1.00
## paternalage:regionLinkopings            1935 1.00
## paternalage:regionNorrainlands          1720 1.00
## paternalage:regionSundsvalls            2128 1.00
## hu_Intercept                             385 1.01
## hu_paternalage                           729 1.01
## hu_regionLinkopings                      594 1.00
## hu_regionNorrainlands                    706 1.00
## hu_regionSundsvalls                      603 1.00
## hu_birth_cohort1750M1755                 618 1.01
## hu_birth_cohort1755M1760                 446 1.01
## hu_birth_cohort1760M1765                 339 1.02
## hu_birth_cohort1765M1770                 334 1.02
## hu_birth_cohort1770M1775                 333 1.01
## hu_birth_cohort1775M1780                 307 1.02
## hu_birth_cohort1780M1785                 314 1.02
## hu_birth_cohort1785M1790                 293 1.02
## hu_birth_cohort1790M1795                 267 1.02
## hu_birth_cohort1795M1800                 258 1.02
## hu_birth_cohort1800M1805                 267 1.02
## hu_birth_cohort1805M1810                 257 1.02
## hu_birth_cohort1810M1815                 248 1.02
## hu_birth_cohort1815M1820                 243 1.02
## hu_birth_cohort1820M1825                 239 1.02
## hu_birth_cohort1825M1830                 243 1.02
## hu_birth_cohort1830M1835                 246 1.02
## hu_birth_cohort1835M1840                 241 1.02
## hu_birth_cohort1840M1845                 244 1.02
## hu_birth_cohort1845M1850                 239 1.02
## hu_male1                                3000 1.00
## hu_maternalage.factor1020               3000 1.00
## hu_maternalage.factor3559               3000 1.00
## hu_paternalage.mean                      769 1.01
## hu_paternal_loss01                      3000 1.00
## hu_paternal_loss15                      3000 1.00
## hu_paternal_loss510                     3000 1.00
## hu_paternal_loss1015                    1953 1.00
## hu_paternal_loss1520                    1791 1.00
## hu_paternal_loss2025                    1867 1.00
## hu_paternal_loss2530                    1909 1.00
## hu_paternal_loss3035                    1466 1.00
## hu_paternal_loss3540                    1664 1.00
## hu_paternal_loss4045                    3000 1.00
## hu_maternal_loss01                      3000 1.00
## hu_maternal_loss15                      3000 1.00
## hu_maternal_loss510                     3000 1.00
## hu_maternal_loss1015                    3000 1.00
## hu_maternal_loss1520                    3000 1.00
## hu_maternal_loss2025                    3000 1.00
## hu_maternal_loss2530                    3000 1.00
## hu_maternal_loss3035                    3000 1.00
## hu_maternal_loss3540                    3000 1.00
## hu_maternal_loss4045                    3000 1.00
## hu_older_siblings1                      1471 1.00
## hu_older_siblings2                       832 1.01
## hu_older_siblings3                       750 1.01
## hu_older_siblings4                       690 1.01
## hu_older_siblings5P                      688 1.01
## hu_nr.siblings                           846 1.01
## hu_last_born1                           3000 1.00
## hu_paternalage:regionLinkopings         1901 1.00
## hu_paternalage:regionNorrainlands       1882 1.00
## hu_paternalage:regionSundsvalls         1783 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.437 4.369 6.688
paternalage 0.9587 0.922 0.9989
regionLinkopings 0.654 0.5423 0.7781
regionNorrainlands 0.9969 0.8306 1.19
regionSundsvalls 0.6406 0.5381 0.767
birth_cohort1750M1755 0.84 0.6787 1.054
birth_cohort1755M1760 1.01 0.841 1.209
birth_cohort1760M1765 1.03 0.8737 1.205
birth_cohort1765M1770 0.9895 0.8346 1.166
birth_cohort1770M1775 0.9508 0.8024 1.12
birth_cohort1775M1780 0.9344 0.7892 1.093
birth_cohort1780M1785 1.059 0.8995 1.24
birth_cohort1785M1790 1.078 0.9149 1.262
birth_cohort1790M1795 0.9959 0.8531 1.155
birth_cohort1795M1800 1.02 0.8727 1.188
birth_cohort1800M1805 0.9676 0.8284 1.122
birth_cohort1805M1810 0.9805 0.8409 1.131
birth_cohort1810M1815 1.002 0.8628 1.155
birth_cohort1815M1820 1.029 0.888 1.185
birth_cohort1820M1825 1.046 0.9053 1.209
birth_cohort1825M1830 1.003 0.8688 1.157
birth_cohort1830M1835 1.027 0.8885 1.184
birth_cohort1835M1840 1.022 0.8839 1.176
birth_cohort1840M1845 0.996 0.8612 1.148
birth_cohort1845M1850 0.9948 0.8585 1.144
male1 1.041 1.028 1.055
maternalage.factor1020 1.043 0.9851 1.103
maternalage.factor3559 1.043 1.022 1.064
paternalage.mean 1.036 0.9976 1.075
paternal_loss01 1.067 0.9946 1.141
paternal_loss15 1.032 0.9858 1.08
paternal_loss510 1.008 0.9694 1.047
paternal_loss1015 1.011 0.9767 1.049
paternal_loss1520 0.9632 0.9315 0.9949
paternal_loss2025 1.004 0.9734 1.034
paternal_loss2530 1.002 0.9737 1.031
paternal_loss3035 0.999 0.9721 1.027
paternal_loss3540 1.029 1.003 1.055
paternal_loss4045 1.034 1.008 1.06
maternal_loss01 1.026 0.9213 1.136
maternal_loss15 0.9643 0.9135 1.017
maternal_loss510 0.9686 0.9268 1.011
maternal_loss1015 0.9633 0.9235 1.005
maternal_loss1520 0.9732 0.9373 1.009
maternal_loss2025 0.9422 0.9118 0.9724
maternal_loss2530 0.9862 0.9591 1.015
maternal_loss3035 0.9898 0.964 1.016
maternal_loss3540 1.006 0.9834 1.031
maternal_loss4045 0.9843 0.9618 1.008
older_siblings1 1.017 0.9957 1.038
older_siblings2 1.028 1 1.055
older_siblings3 1.04 1.006 1.075
older_siblings4 1.015 0.9738 1.056
older_siblings5P 1.039 0.9843 1.093
nr.siblings 1.005 1.001 1.01
last_born1 0.9808 0.9626 0.9982
paternalage:regionLinkopings 1.011 0.9821 1.041
paternalage:regionNorrainlands 0.977 0.9534 1.001
paternalage:regionSundsvalls 1.022 0.9945 1.05
hu_Intercept 0.4918 0.301 0.7911
hu_paternalage 1.085 0.9603 1.222
hu_regionLinkopings 3.341 2.236 5.067
hu_regionNorrainlands 0.9529 0.6308 1.445
hu_regionSundsvalls 1.384 0.9352 2.081
hu_birth_cohort1750M1755 1.522 0.9046 2.611
hu_birth_cohort1755M1760 1.409 0.888 2.217
hu_birth_cohort1760M1765 1.405 0.9252 2.163
hu_birth_cohort1765M1770 1.017 0.6707 1.581
hu_birth_cohort1770M1775 1.263 0.8178 1.948
hu_birth_cohort1775M1780 1.52 1.007 2.286
hu_birth_cohort1780M1785 1.37 0.9 2.051
hu_birth_cohort1785M1790 1.285 0.8748 1.877
hu_birth_cohort1790M1795 1.285 0.8917 1.852
hu_birth_cohort1795M1800 0.9967 0.6845 1.434
hu_birth_cohort1800M1805 0.9868 0.6847 1.41
hu_birth_cohort1805M1810 1.056 0.7382 1.512
hu_birth_cohort1810M1815 1.175 0.8194 1.678
hu_birth_cohort1815M1820 1.176 0.8276 1.668
hu_birth_cohort1820M1825 1.076 0.7545 1.516
hu_birth_cohort1825M1830 1.083 0.7553 1.529
hu_birth_cohort1830M1835 1.096 0.7694 1.541
hu_birth_cohort1835M1840 1.086 0.763 1.53
hu_birth_cohort1840M1845 1.106 0.7756 1.562
hu_birth_cohort1845M1850 1.184 0.8266 1.671
hu_male1 1.044 1.006 1.082
hu_maternalage.factor1020 1.037 0.8715 1.229
hu_maternalage.factor3559 1.132 1.068 1.197
hu_paternalage.mean 0.8957 0.8011 1.005
hu_paternal_loss01 2.04 1.692 2.457
hu_paternal_loss15 1.603 1.422 1.807
hu_paternal_loss510 1.622 1.47 1.796
hu_paternal_loss1015 1.378 1.259 1.503
hu_paternal_loss1520 1.291 1.181 1.405
hu_paternal_loss2025 1.183 1.092 1.284
hu_paternal_loss2530 1.111 1.025 1.2
hu_paternal_loss3035 1.069 0.9921 1.152
hu_paternal_loss3540 1.067 0.9958 1.145
hu_paternal_loss4045 1.015 0.9382 1.094
hu_maternal_loss01 5.539 4.386 6.989
hu_maternal_loss15 2.38 2.089 2.72
hu_maternal_loss510 1.99 1.788 2.223
hu_maternal_loss1015 1.866 1.687 2.059
hu_maternal_loss1520 1.656 1.511 1.82
hu_maternal_loss2025 1.378 1.266 1.499
hu_maternal_loss2530 1.211 1.122 1.307
hu_maternal_loss3035 1.151 1.069 1.239
hu_maternal_loss3540 1.07 1.002 1.142
hu_maternal_loss4045 1.025 0.9565 1.098
hu_older_siblings1 0.9422 0.8849 1.001
hu_older_siblings2 0.9349 0.8636 1.013
hu_older_siblings3 0.9086 0.8228 1.006
hu_older_siblings4 0.8752 0.7731 0.993
hu_older_siblings5P 0.8089 0.6906 0.9546
hu_nr.siblings 1.074 1.059 1.089
hu_last_born1 1.004 0.9525 1.057
hu_paternalage:regionLinkopings 1.035 0.9619 1.112
hu_paternalage:regionNorrainlands 1.037 0.9657 1.111
hu_paternalage:regionSundsvalls 1.007 0.9375 1.084

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 3.6 [2.74;4.59] [3.01;4.24]
estimate father 35y 3.35 [2.54;4.32] [2.79;3.95]
percentage change -6.89 [-12.58;-1.25] [-10.67;-3.2]
OR/IRR 0.96 [0.92;1] [0.93;0.98]
OR hurdle 1.08 [0.96;1.22] [1;1.17]

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/ddb/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å.

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: 11963) 
## 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: 2688) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.22      0.01     0.20     0.24        996    1
## sd(hu_Intercept)     0.70      0.04     0.63     0.77       1218    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.80      0.09     1.62     1.98        727
## paternalage                  -0.05      0.03    -0.11     0.02        912
## birth_cohort1815M1820        -0.04      0.08    -0.20     0.11        577
## birth_cohort1820M1825        -0.04      0.08    -0.19     0.11        557
## birth_cohort1825M1830        -0.09      0.08    -0.24     0.06        567
## birth_cohort1830M1835        -0.11      0.08    -0.26     0.04        568
## birth_cohort1835M1840        -0.07      0.08    -0.22     0.08        553
## birth_cohort1840M1845        -0.11      0.08    -0.25     0.04        576
## birth_cohort1845M1850        -0.11      0.08    -0.26     0.05        567
## male1                         0.07      0.01     0.05     0.09       3000
## maternalage.factor1020        0.01      0.06    -0.11     0.12       3000
## maternalage.factor3559        0.02      0.02    -0.02     0.06       3000
## paternalage.mean              0.05      0.04    -0.02     0.11        970
## paternal_loss01               0.12      0.06    -0.01     0.24       3000
## paternal_loss15              -0.01      0.04    -0.10     0.08       3000
## paternal_loss510             -0.02      0.04    -0.10     0.05       3000
## paternal_loss1015            -0.05      0.03    -0.12     0.01       1971
## paternal_loss1520            -0.14      0.03    -0.19    -0.08       1963
## paternal_loss2025            -0.05      0.03    -0.10     0.01       1745
## paternal_loss2530            -0.06      0.02    -0.11    -0.02       1982
## paternal_loss3035            -0.03      0.02    -0.08     0.01       1870
## paternal_loss3540             0.00      0.02    -0.04     0.04       1971
## paternal_loss4045            -0.02      0.02    -0.06     0.02       3000
## maternal_loss01              -0.01      0.09    -0.19     0.16       3000
## maternal_loss15              -0.04      0.05    -0.14     0.05       3000
## maternal_loss510             -0.07      0.04    -0.15     0.00       3000
## maternal_loss1015            -0.07      0.04    -0.14     0.00       3000
## maternal_loss1520            -0.05      0.03    -0.11     0.01       3000
## maternal_loss2025            -0.09      0.03    -0.14    -0.03       3000
## maternal_loss2530            -0.02      0.03    -0.07     0.03       2239
## maternal_loss3035             0.00      0.02    -0.04     0.04       1849
## maternal_loss3540            -0.03      0.02    -0.07     0.02       3000
## maternal_loss4045             0.00      0.02    -0.04     0.04       3000
## older_siblings1               0.03      0.02     0.00     0.07       3000
## older_siblings2               0.05      0.02     0.00     0.10       1156
## older_siblings3               0.07      0.03     0.02     0.13       1004
## older_siblings4               0.09      0.04     0.02     0.16        994
## older_siblings5P              0.11      0.05     0.02     0.20        885
## nr.siblings                   0.00      0.00    -0.01     0.01       1220
## last_born1                   -0.02      0.02    -0.06     0.01       3000
## hu_Intercept                 -0.06      0.31    -0.67     0.55        653
## hu_paternalage                0.11      0.12    -0.14     0.34        655
## hu_birth_cohort1815M1820     -0.27      0.26    -0.79     0.23        397
## hu_birth_cohort1820M1825     -0.51      0.26    -1.03    -0.01        372
## hu_birth_cohort1825M1830     -0.41      0.26    -0.94     0.09        356
## hu_birth_cohort1830M1835     -0.28      0.26    -0.80     0.22        374
## hu_birth_cohort1835M1840     -0.43      0.27    -0.96     0.09        373
## hu_birth_cohort1840M1845     -0.44      0.27    -0.99     0.07        386
## hu_birth_cohort1845M1850     -0.31      0.27    -0.85     0.19        494
## hu_male1                      0.03      0.04    -0.05     0.11       3000
## hu_maternalage.factor1020     0.11      0.21    -0.30     0.54       3000
## hu_maternalage.factor3559     0.10      0.06    -0.02     0.23       3000
## hu_paternalage.mean          -0.13      0.12    -0.36     0.13        811
## hu_paternal_loss01            0.30      0.21    -0.12     0.71       3000
## hu_paternal_loss15            0.26      0.15    -0.03     0.54       3000
## hu_paternal_loss510           0.36      0.13     0.11     0.61       3000
## hu_paternal_loss1015          0.18      0.11    -0.04     0.40       3000
## hu_paternal_loss1520          0.19      0.10     0.00     0.39       1654
## hu_paternal_loss2025          0.13      0.09    -0.05     0.31       1538
## hu_paternal_loss2530         -0.01      0.08    -0.17     0.16       1574
## hu_paternal_loss3035          0.07      0.08    -0.09     0.23       1465
## hu_paternal_loss3540          0.01      0.08    -0.14     0.16       1748
## hu_paternal_loss4045          0.03      0.08    -0.12     0.19       3000
## hu_maternal_loss01            1.91      0.24     1.45     2.39       3000
## hu_maternal_loss15            0.98      0.14     0.69     1.25       3000
## hu_maternal_loss510           0.62      0.12     0.39     0.85       3000
## hu_maternal_loss1015          0.54      0.11     0.34     0.77       3000
## hu_maternal_loss1520          0.53      0.10     0.32     0.74       3000
## hu_maternal_loss2025          0.20      0.09     0.02     0.38       3000
## hu_maternal_loss2530          0.25      0.08     0.09     0.41       2149
## hu_maternal_loss3035          0.20      0.07     0.05     0.34       3000
## hu_maternal_loss3540          0.10      0.07    -0.05     0.24       3000
## hu_maternal_loss4045          0.05      0.08    -0.10     0.20       3000
## hu_older_siblings1           -0.02      0.07    -0.15     0.11       1637
## hu_older_siblings2           -0.05      0.08    -0.21     0.11       1035
## hu_older_siblings3           -0.06      0.11    -0.27     0.14        846
## hu_older_siblings4           -0.22      0.13    -0.47     0.02        803
## hu_older_siblings5P          -0.15      0.16    -0.46     0.17        740
## hu_nr.siblings                0.04      0.01     0.02     0.07        913
## hu_last_born1                -0.01      0.06    -0.12     0.10       3000
##                           Rhat
## Intercept                 1.00
## paternalage               1.01
## birth_cohort1815M1820     1.01
## birth_cohort1820M1825     1.01
## birth_cohort1825M1830     1.01
## birth_cohort1830M1835     1.01
## birth_cohort1835M1840     1.01
## birth_cohort1840M1845     1.01
## birth_cohort1845M1850     1.01
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.01
## 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.01
## older_siblings1           1.00
## older_siblings2           1.00
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.00
## last_born1                1.00
## hu_Intercept              1.01
## hu_paternalage            1.00
## hu_birth_cohort1815M1820  1.01
## hu_birth_cohort1820M1825  1.01
## hu_birth_cohort1825M1830  1.01
## hu_birth_cohort1830M1835  1.01
## hu_birth_cohort1835M1840  1.01
## hu_birth_cohort1840M1845  1.01
## hu_birth_cohort1845M1850  1.01
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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 6.03 5.028 7.225
paternalage 0.9526 0.8926 1.02
birth_cohort1815M1820 0.9573 0.8223 1.111
birth_cohort1820M1825 0.9562 0.8272 1.113
birth_cohort1825M1830 0.9145 0.7872 1.064
birth_cohort1830M1835 0.8948 0.7691 1.043
birth_cohort1835M1840 0.9289 0.8019 1.079
birth_cohort1840M1845 0.898 0.7752 1.046
birth_cohort1845M1850 0.8983 0.7722 1.049
male1 1.073 1.05 1.097
maternalage.factor1020 1.007 0.8917 1.133
maternalage.factor3559 1.021 0.9837 1.06
paternalage.mean 1.047 0.9759 1.119
paternal_loss01 1.123 0.9925 1.271
paternal_loss15 0.9899 0.9062 1.079
paternal_loss510 0.9781 0.9088 1.05
paternal_loss1015 0.9493 0.8889 1.014
paternal_loss1520 0.8728 0.8237 0.9271
paternal_loss2025 0.9548 0.9064 1.006
paternal_loss2530 0.9377 0.8924 0.9845
paternal_loss3035 0.9662 0.9229 1.012
paternal_loss3540 0.9961 0.9562 1.038
paternal_loss4045 0.9784 0.9383 1.021
maternal_loss01 0.988 0.8264 1.175
maternal_loss15 0.9591 0.8723 1.053
maternal_loss510 0.9312 0.8648 1.004
maternal_loss1015 0.9326 0.8697 0.9985
maternal_loss1520 0.9525 0.8923 1.014
maternal_loss2025 0.9157 0.8662 0.9688
maternal_loss2530 0.9796 0.9329 1.029
maternal_loss3035 0.9994 0.9576 1.043
maternal_loss3540 0.975 0.936 1.016
maternal_loss4045 0.9974 0.9565 1.04
older_siblings1 1.035 0.9976 1.076
older_siblings2 1.05 1.003 1.101
older_siblings3 1.076 1.018 1.137
older_siblings4 1.094 1.023 1.172
older_siblings5P 1.114 1.02 1.218
nr.siblings 0.9987 0.9908 1.006
last_born1 0.9762 0.9424 1.011
hu_Intercept 0.9375 0.5111 1.726
hu_paternalage 1.118 0.8672 1.403
hu_birth_cohort1815M1820 0.7622 0.4561 1.26
hu_birth_cohort1820M1825 0.5989 0.3569 0.9868
hu_birth_cohort1825M1830 0.6606 0.3896 1.089
hu_birth_cohort1830M1835 0.7555 0.4487 1.25
hu_birth_cohort1835M1840 0.6536 0.3821 1.09
hu_birth_cohort1840M1845 0.6415 0.3724 1.073
hu_birth_cohort1845M1850 0.7301 0.4259 1.208
hu_male1 1.034 0.9544 1.119
hu_maternalage.factor1020 1.116 0.7372 1.709
hu_maternalage.factor3559 1.106 0.976 1.254
hu_paternalage.mean 0.8786 0.6962 1.141
hu_paternal_loss01 1.345 0.8835 2.024
hu_paternal_loss15 1.291 0.9707 1.718
hu_paternal_loss510 1.431 1.118 1.847
hu_paternal_loss1015 1.196 0.9618 1.499
hu_paternal_loss1520 1.215 1.004 1.483
hu_paternal_loss2025 1.14 0.9551 1.361
hu_paternal_loss2530 0.9942 0.8469 1.178
hu_paternal_loss3035 1.075 0.9153 1.255
hu_paternal_loss3540 1.005 0.8661 1.176
hu_paternal_loss4045 1.036 0.8894 1.205
hu_maternal_loss01 6.74 4.274 10.96
hu_maternal_loss15 2.651 2.001 3.508
hu_maternal_loss510 1.86 1.482 2.337
hu_maternal_loss1015 1.721 1.406 2.152
hu_maternal_loss1520 1.696 1.378 2.101
hu_maternal_loss2025 1.217 1.023 1.457
hu_maternal_loss2530 1.282 1.093 1.5
hu_maternal_loss3035 1.22 1.056 1.407
hu_maternal_loss3540 1.101 0.9518 1.27
hu_maternal_loss4045 1.051 0.9063 1.225
hu_older_siblings1 0.979 0.8586 1.114
hu_older_siblings2 0.9516 0.8128 1.119
hu_older_siblings3 0.9392 0.764 1.155
hu_older_siblings4 0.7994 0.624 1.02
hu_older_siblings5P 0.8616 0.6283 1.183
hu_nr.siblings 1.046 1.017 1.073
hu_last_born1 0.9897 0.8841 1.106

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 3.06 [2.23;4.09] [2.51;3.71]
estimate father 35y 2.76 [1.95;3.75] [2.22;3.4]
percentage change -10.22 [-22.12;4.2] [-17.88;-1.42]
OR/IRR 0.95 [0.89;1.02] [0.91;0.99]
OR hurdle 1.12 [0.87;1.4] [0.96;1.3]

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/ddb/r16_restrict_to_skelleftea.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

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: 55183) 
## 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: 14638) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.37       1286    1
## sd(hu_Intercept)     0.82      0.02     0.78     0.85        992    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.33      0.08     1.17     1.47        114
## paternalage                  -0.05      0.02    -0.09    -0.02        852
## birth_cohort1750M1755        -0.18      0.12    -0.41     0.06        415
## birth_cohort1755M1760         0.08      0.09    -0.10     0.26        180
## birth_cohort1760M1765         0.14      0.09    -0.02     0.31        142
## birth_cohort1765M1770         0.09      0.09    -0.07     0.26        133
## birth_cohort1770M1775         0.05      0.09    -0.11     0.23        138
## birth_cohort1775M1780         0.04      0.09    -0.13     0.20        131
## birth_cohort1780M1785         0.14      0.09    -0.01     0.31        126
## birth_cohort1785M1790         0.12      0.08    -0.04     0.28        118
## birth_cohort1790M1795         0.02      0.08    -0.13     0.18        113
## birth_cohort1795M1800         0.01      0.08    -0.13     0.17        113
## birth_cohort1800M1805        -0.03      0.08    -0.18     0.12        107
## birth_cohort1805M1810        -0.02      0.08    -0.16     0.13        110
## birth_cohort1810M1815         0.01      0.08    -0.13     0.15        105
## birth_cohort1815M1820         0.06      0.08    -0.08     0.20        102
## birth_cohort1820M1825         0.08      0.08    -0.06     0.22        103
## birth_cohort1825M1830         0.03      0.08    -0.11     0.18        102
## birth_cohort1830M1835         0.06      0.08    -0.08     0.21        102
## birth_cohort1835M1840         0.06      0.08    -0.08     0.21        100
## birth_cohort1840M1845         0.04      0.08    -0.10     0.19        102
## birth_cohort1845M1850         0.05      0.08    -0.09     0.19        103
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.04      0.03    -0.02     0.10       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       2425
## paternalage.mean              0.06      0.02     0.02     0.10        868
## paternal_loss01               0.06      0.04    -0.01     0.13       2312
## paternal_loss15               0.02      0.02    -0.02     0.07       1498
## paternal_loss510             -0.02      0.02    -0.06     0.02       1544
## paternal_loss1015            -0.02      0.02    -0.06     0.02       1384
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       1276
## paternal_loss2025            -0.03      0.02    -0.06     0.00       1264
## paternal_loss2530            -0.02      0.01    -0.05     0.01       1397
## paternal_loss3035            -0.02      0.01    -0.04     0.01       1596
## paternal_loss3540             0.02      0.01     0.00     0.05       1737
## paternal_loss4045             0.03      0.01     0.00     0.05       2013
## maternal_loss01               0.07      0.05    -0.04     0.16       1977
## maternal_loss15               0.00      0.03    -0.05     0.06       1745
## maternal_loss510             -0.02      0.02    -0.07     0.03       1672
## maternal_loss1015            -0.04      0.02    -0.08     0.01       1661
## maternal_loss1520            -0.04      0.02    -0.07     0.00       1666
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       1498
## maternal_loss2530            -0.03      0.02    -0.06     0.00       1613
## maternal_loss3035            -0.02      0.01    -0.05     0.01       1582
## maternal_loss3540             0.00      0.01    -0.02     0.03       1798
## maternal_loss4045            -0.02      0.01    -0.04     0.00       3000
## older_siblings1               0.02      0.01    -0.01     0.04       1434
## older_siblings2               0.03      0.01     0.00     0.06       1025
## older_siblings3               0.04      0.02     0.00     0.07        958
## older_siblings4               0.01      0.02    -0.03     0.05        961
## older_siblings5P              0.03      0.03    -0.03     0.08        858
## nr.siblings                   0.02      0.00     0.02     0.03        889
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                 -0.09      0.19    -0.46     0.27         80
## hu_paternalage               -0.11      0.06    -0.22     0.01        751
## hu_birth_cohort1750M1755      0.41      0.29    -0.15     0.97        372
## hu_birth_cohort1755M1760      0.08      0.24    -0.40     0.54        136
## hu_birth_cohort1760M1765     -0.06      0.22    -0.48     0.37        114
## hu_birth_cohort1765M1770     -0.36      0.22    -0.76     0.07        200
## hu_birth_cohort1770M1775     -0.09      0.22    -0.53     0.35        206
## hu_birth_cohort1775M1780      0.11      0.21    -0.29     0.53        181
## hu_birth_cohort1780M1785      0.02      0.21    -0.39     0.43        109
## hu_birth_cohort1785M1790      0.17      0.19    -0.21     0.56        169
## hu_birth_cohort1790M1795      0.34      0.18    -0.03     0.70         84
## hu_birth_cohort1795M1800      0.13      0.18    -0.23     0.49         83
## hu_birth_cohort1800M1805      0.06      0.18    -0.30     0.42         77
## hu_birth_cohort1805M1810      0.01      0.18    -0.35     0.36         78
## hu_birth_cohort1810M1815      0.08      0.18    -0.27     0.43         76
## hu_birth_cohort1815M1820     -0.07      0.18    -0.42     0.28         73
## hu_birth_cohort1820M1825     -0.18      0.17    -0.52     0.17         73
## hu_birth_cohort1825M1830     -0.18      0.18    -0.52     0.18         75
## hu_birth_cohort1830M1835     -0.15      0.18    -0.50     0.21         72
## hu_birth_cohort1835M1840     -0.17      0.18    -0.52     0.17         72
## hu_birth_cohort1840M1845     -0.16      0.17    -0.51     0.18         74
## hu_birth_cohort1845M1850     -0.14      0.18    -0.49     0.21         74
## hu_male1                      0.04      0.02     0.00     0.08       3000
## hu_maternalage.factor1020     0.03      0.09    -0.14     0.21       3000
## hu_maternalage.factor3559     0.00      0.03    -0.06     0.06       3000
## hu_paternalage.mean           0.07      0.06    -0.05     0.18        781
## hu_paternal_loss01            0.91      0.09     0.73     1.09       3000
## hu_paternal_loss15            0.69      0.06     0.57     0.81       1722
## hu_paternal_loss510           0.71      0.05     0.61     0.82       1484
## hu_paternal_loss1015          0.53      0.05     0.43     0.62       1454
## hu_paternal_loss1520          0.44      0.05     0.34     0.53       1492
## hu_paternal_loss2025          0.33      0.04     0.24     0.41       1494
## hu_paternal_loss2530          0.23      0.04     0.15     0.32       1332
## hu_paternal_loss3035          0.16      0.04     0.08     0.23       1483
## hu_paternal_loss3540          0.12      0.04     0.05     0.20       1683
## hu_paternal_loss4045          0.05      0.04    -0.02     0.12       3000
## hu_maternal_loss01            1.87      0.12     1.64     2.11       3000
## hu_maternal_loss15            1.03      0.07     0.90     1.17       3000
## hu_maternal_loss510           0.88      0.06     0.77     0.99       3000
## hu_maternal_loss1015          0.79      0.05     0.69     0.90       3000
## hu_maternal_loss1520          0.64      0.05     0.54     0.74       3000
## hu_maternal_loss2025          0.44      0.04     0.35     0.53       3000
## hu_maternal_loss2530          0.30      0.04     0.22     0.38       2169
## hu_maternal_loss3035          0.22      0.04     0.15     0.30       1804
## hu_maternal_loss3540          0.14      0.03     0.07     0.21       1945
## hu_maternal_loss4045          0.08      0.04     0.01     0.15       3000
## hu_older_siblings1           -0.01      0.03    -0.07     0.05       1253
## hu_older_siblings2            0.03      0.04    -0.05     0.11        891
## hu_older_siblings3            0.04      0.05    -0.07     0.14        855
## hu_older_siblings4            0.03      0.06    -0.10     0.15        812
## hu_older_siblings5P          -0.03      0.08    -0.19     0.14        732
## hu_nr.siblings                0.04      0.01     0.03     0.05        761
## hu_last_born1                 0.02      0.03    -0.03     0.08       3000
##                           Rhat
## Intercept                 1.03
## paternalage               1.00
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.02
## birth_cohort1760M1765     1.03
## birth_cohort1765M1770     1.03
## birth_cohort1770M1775     1.02
## birth_cohort1775M1780     1.03
## birth_cohort1780M1785     1.03
## birth_cohort1785M1790     1.03
## birth_cohort1790M1795     1.03
## birth_cohort1795M1800     1.03
## birth_cohort1800M1805     1.04
## birth_cohort1805M1810     1.04
## birth_cohort1810M1815     1.04
## birth_cohort1815M1820     1.04
## birth_cohort1820M1825     1.04
## birth_cohort1825M1830     1.04
## birth_cohort1830M1835     1.04
## birth_cohort1835M1840     1.04
## birth_cohort1840M1845     1.04
## birth_cohort1845M1850     1.04
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.07
## hu_paternalage            1.01
## hu_birth_cohort1750M1755  1.02
## hu_birth_cohort1755M1760  1.04
## hu_birth_cohort1760M1765  1.04
## hu_birth_cohort1765M1770  1.04
## hu_birth_cohort1770M1775  1.04
## hu_birth_cohort1775M1780  1.05
## hu_birth_cohort1780M1785  1.04
## hu_birth_cohort1785M1790  1.05
## hu_birth_cohort1790M1795  1.06
## hu_birth_cohort1795M1800  1.06
## hu_birth_cohort1800M1805  1.06
## hu_birth_cohort1805M1810  1.07
## hu_birth_cohort1810M1815  1.06
## hu_birth_cohort1815M1820  1.07
## hu_birth_cohort1820M1825  1.07
## hu_birth_cohort1825M1830  1.07
## hu_birth_cohort1830M1835  1.07
## hu_birth_cohort1835M1840  1.07
## hu_birth_cohort1840M1845  1.07
## hu_birth_cohort1845M1850  1.07
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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.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 3.772 3.235 4.37
paternalage 0.9484 0.9141 0.985
birth_cohort1750M1755 0.8372 0.6667 1.059
birth_cohort1755M1760 1.086 0.9032 1.302
birth_cohort1760M1765 1.149 0.9761 1.366
birth_cohort1765M1770 1.094 0.9299 1.297
birth_cohort1770M1775 1.053 0.8937 1.253
birth_cohort1775M1780 1.037 0.8809 1.225
birth_cohort1780M1785 1.154 0.9867 1.36
birth_cohort1785M1790 1.123 0.9607 1.324
birth_cohort1790M1795 1.018 0.8767 1.194
birth_cohort1795M1800 1.015 0.8775 1.187
birth_cohort1800M1805 0.9671 0.8369 1.13
birth_cohort1805M1810 0.9807 0.8502 1.137
birth_cohort1810M1815 1.005 0.8754 1.165
birth_cohort1815M1820 1.06 0.9222 1.226
birth_cohort1820M1825 1.079 0.9378 1.249
birth_cohort1825M1830 1.035 0.8998 1.196
birth_cohort1830M1835 1.061 0.9259 1.228
birth_cohort1835M1840 1.061 0.9238 1.229
birth_cohort1840M1845 1.038 0.9036 1.203
birth_cohort1845M1850 1.047 0.9117 1.209
male1 1.041 1.027 1.055
maternalage.factor1020 1.038 0.9775 1.102
maternalage.factor3559 1.066 1.044 1.089
paternalage.mean 1.061 1.019 1.102
paternal_loss01 1.061 0.9885 1.141
paternal_loss15 1.025 0.9788 1.075
paternal_loss510 0.9802 0.9386 1.021
paternal_loss1015 0.9799 0.9445 1.016
paternal_loss1520 0.9285 0.8963 0.9626
paternal_loss2025 0.9717 0.942 1.002
paternal_loss2530 0.9788 0.951 1.006
paternal_loss3035 0.9843 0.9576 1.011
paternal_loss3540 1.021 0.9951 1.047
paternal_loss4045 1.028 1.002 1.054
maternal_loss01 1.069 0.9643 1.179
maternal_loss15 1.003 0.9471 1.06
maternal_loss510 0.9808 0.936 1.027
maternal_loss1015 0.9651 0.9249 1.007
maternal_loss1520 0.9653 0.9284 1.003
maternal_loss2025 0.9319 0.9004 0.9646
maternal_loss2530 0.9727 0.9434 1.003
maternal_loss3035 0.9796 0.9534 1.007
maternal_loss3540 1.002 0.9769 1.027
maternal_loss4045 0.9805 0.9567 1.004
older_siblings1 1.016 0.9942 1.037
older_siblings2 1.03 1 1.057
older_siblings3 1.037 1.001 1.073
older_siblings4 1.013 0.971 1.056
older_siblings5P 1.028 0.9715 1.083
nr.siblings 1.024 1.018 1.029
last_born1 0.979 0.9606 0.9971
hu_Intercept 0.9136 0.6294 1.315
hu_paternalage 0.8975 0.8057 1.009
hu_birth_cohort1750M1755 1.514 0.8618 2.629
hu_birth_cohort1755M1760 1.078 0.671 1.719
hu_birth_cohort1760M1765 0.9453 0.6193 1.444
hu_birth_cohort1765M1770 0.6993 0.4654 1.072
hu_birth_cohort1770M1775 0.9096 0.5913 1.418
hu_birth_cohort1775M1780 1.118 0.7494 1.691
hu_birth_cohort1780M1785 1.016 0.6772 1.538
hu_birth_cohort1785M1790 1.185 0.8081 1.756
hu_birth_cohort1790M1795 1.4 0.9663 2.006
hu_birth_cohort1795M1800 1.14 0.7964 1.637
hu_birth_cohort1800M1805 1.058 0.7426 1.528
hu_birth_cohort1805M1810 1.012 0.7021 1.438
hu_birth_cohort1810M1815 1.086 0.762 1.534
hu_birth_cohort1815M1820 0.9313 0.658 1.325
hu_birth_cohort1820M1825 0.8388 0.5916 1.188
hu_birth_cohort1825M1830 0.8382 0.5943 1.198
hu_birth_cohort1830M1835 0.8618 0.6078 1.23
hu_birth_cohort1835M1840 0.8398 0.5918 1.18
hu_birth_cohort1840M1845 0.85 0.6013 1.202
hu_birth_cohort1845M1850 0.869 0.6149 1.238
hu_male1 1.043 1.004 1.085
hu_maternalage.factor1020 1.028 0.8718 1.228
hu_maternalage.factor3559 0.9992 0.9416 1.059
hu_paternalage.mean 1.068 0.9499 1.192
hu_paternal_loss01 2.485 2.065 2.983
hu_paternal_loss15 1.998 1.765 2.259
hu_paternal_loss510 2.039 1.844 2.262
hu_paternal_loss1015 1.694 1.541 1.863
hu_paternal_loss1520 1.551 1.412 1.7
hu_paternal_loss2025 1.388 1.272 1.509
hu_paternal_loss2530 1.264 1.164 1.372
hu_paternal_loss3035 1.169 1.083 1.264
hu_paternal_loss3540 1.133 1.054 1.223
hu_paternal_loss4045 1.047 0.9756 1.13
hu_maternal_loss01 6.511 5.171 8.243
hu_maternal_loss15 2.807 2.455 3.225
hu_maternal_loss510 2.404 2.15 2.689
hu_maternal_loss1015 2.204 1.984 2.448
hu_maternal_loss1520 1.905 1.725 2.104
hu_maternal_loss2025 1.554 1.424 1.702
hu_maternal_loss2530 1.344 1.244 1.46
hu_maternal_loss3035 1.252 1.164 1.348
hu_maternal_loss3540 1.151 1.076 1.23
hu_maternal_loss4045 1.083 1.008 1.161
hu_older_siblings1 0.9873 0.9288 1.048
hu_older_siblings2 1.03 0.9512 1.112
hu_older_siblings3 1.041 0.9353 1.148
hu_older_siblings4 1.026 0.902 1.162
hu_older_siblings5P 0.9715 0.8237 1.146
hu_nr.siblings 1.041 1.026 1.056
hu_last_born1 1.022 0.9694 1.079

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.23 [1.77;2.76] [1.91;2.57]
estimate father 35y 2.23 [1.78;2.77] [1.92;2.57]
percentage change 0.41 [-6.23;7.48] [-3.85;5.08]
OR/IRR 0.95 [0.91;0.98] [0.93;0.97]
OR hurdle 0.9 [0.81;1.01] [0.83;0.97]

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/ddb/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: 56663) 
## 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)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 14746) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     1.19      0.01     1.17     1.21        483 1.01
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  0.38      0.12     0.15     0.61        244
## paternalage               -0.09      0.02    -0.13    -0.05        447
## birth_cohort1750M1755     -0.31      0.11    -0.52    -0.09        874
## birth_cohort1755M1760      0.02      0.10    -0.17     0.22        397
## birth_cohort1760M1765      0.06      0.10    -0.13     0.27        298
## birth_cohort1765M1770      0.18      0.11    -0.01     0.39        258
## birth_cohort1770M1775      0.02      0.11    -0.18     0.25        259
## birth_cohort1775M1780     -0.12      0.11    -0.33     0.10        241
## birth_cohort1780M1785     -0.03      0.11    -0.23     0.19        243
## birth_cohort1785M1790     -0.08      0.11    -0.29     0.14        226
## birth_cohort1790M1795     -0.22      0.11    -0.43    -0.01        207
## birth_cohort1795M1800     -0.15      0.10    -0.34     0.06        210
## birth_cohort1800M1805     -0.14      0.10    -0.35     0.06        207
## birth_cohort1805M1810     -0.10      0.10    -0.29     0.11        213
## birth_cohort1810M1815     -0.08      0.10    -0.28     0.13        211
## birth_cohort1815M1820      0.00      0.10    -0.20     0.20        207
## birth_cohort1820M1825      0.08      0.10    -0.12     0.28        207
## birth_cohort1825M1830      0.05      0.10    -0.15     0.26        208
## birth_cohort1830M1835      0.08      0.11    -0.12     0.29        205
## birth_cohort1835M1840      0.12      0.11    -0.09     0.32        206
## birth_cohort1840M1845      0.08      0.11    -0.12     0.29        205
## birth_cohort1845M1850      0.02      0.11    -0.19     0.23        203
## male1                      0.02      0.01     0.01     0.04       3000
## maternalage.factor1020     0.02      0.03    -0.04     0.08       3000
## maternalage.factor3559     0.02      0.01     0.00     0.04       1931
## paternalage.mean           0.07      0.03     0.02     0.12        397
## paternal_loss01           -0.53      0.05    -0.62    -0.43        462
## paternal_loss15           -0.40      0.04    -0.48    -0.33        301
## paternal_loss510          -0.42      0.03    -0.49    -0.36        273
## paternal_loss1015         -0.30      0.03    -0.36    -0.24        259
## paternal_loss1520         -0.30      0.03    -0.35    -0.24        326
## paternal_loss2025         -0.18      0.02    -0.23    -0.13        255
## paternal_loss2530         -0.12      0.02    -0.16    -0.08        265
## paternal_loss3035         -0.07      0.02    -0.11    -0.04        482
## paternal_loss3540         -0.03      0.02    -0.06     0.00        656
## paternal_loss4045          0.02      0.01    -0.01     0.05       1110
## maternal_loss01           -1.45      0.06    -1.57    -1.34        888
## maternal_loss15           -0.84      0.04    -0.92    -0.76        454
## maternal_loss510          -0.65      0.03    -0.72    -0.59        399
## maternal_loss1015         -0.58      0.03    -0.64    -0.52        437
## maternal_loss1520         -0.52      0.03    -0.58    -0.46        439
## maternal_loss2025         -0.38      0.02    -0.42    -0.33        457
## maternal_loss2530         -0.22      0.02    -0.26    -0.18        468
## maternal_loss3035         -0.16      0.02    -0.19    -0.12        484
## maternal_loss3540         -0.08      0.01    -0.11    -0.05        603
## maternal_loss4045         -0.05      0.01    -0.08    -0.02       1191
## older_siblings1            0.07      0.01     0.05     0.09       1371
## older_siblings2            0.11      0.01     0.09     0.14       1006
## older_siblings3            0.15      0.02     0.12     0.18        891
## older_siblings4            0.16      0.02     0.11     0.20        916
## older_siblings5P           0.18      0.03     0.13     0.23        841
## nr.siblings                0.01      0.00     0.00     0.02        128
## last_born1                -0.02      0.01    -0.04    -0.01       3000
##                        Rhat
## Intercept              1.02
## paternalage            1.01
## birth_cohort1750M1755  1.01
## birth_cohort1755M1760  1.02
## birth_cohort1760M1765  1.02
## birth_cohort1765M1770  1.03
## birth_cohort1770M1775  1.03
## birth_cohort1775M1780  1.03
## birth_cohort1780M1785  1.03
## birth_cohort1785M1790  1.03
## birth_cohort1790M1795  1.04
## birth_cohort1795M1800  1.04
## birth_cohort1800M1805  1.04
## birth_cohort1805M1810  1.04
## birth_cohort1810M1815  1.04
## birth_cohort1815M1820  1.04
## birth_cohort1820M1825  1.04
## birth_cohort1825M1830  1.04
## birth_cohort1830M1835  1.04
## birth_cohort1835M1840  1.04
## birth_cohort1840M1845  1.04
## birth_cohort1845M1850  1.04
## male1                  1.00
## maternalage.factor1020 1.00
## maternalage.factor3559 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.02
## paternal_loss2530      1.02
## paternal_loss3035      1.01
## paternal_loss3540      1.01
## paternal_loss4045      1.01
## maternal_loss01        1.01
## maternal_loss15        1.01
## maternal_loss510       1.02
## maternal_loss1015      1.01
## maternal_loss1520      1.02
## maternal_loss2025      1.02
## maternal_loss2530      1.02
## maternal_loss3035      1.01
## maternal_loss3540      1.01
## maternal_loss4045      1.01
## older_siblings1        1.00
## older_siblings2        1.00
## older_siblings3        1.01
## older_siblings4        1.00
## older_siblings5P       1.01
## nr.siblings            1.04
## 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 1.456 1.157 1.834
paternalage 0.9146 0.8746 0.9538
birth_cohort1750M1755 0.7371 0.5928 0.9139
birth_cohort1755M1760 1.024 0.8424 1.244
birth_cohort1760M1765 1.066 0.8745 1.307
birth_cohort1765M1770 1.2 0.9854 1.477
birth_cohort1770M1775 1.024 0.8339 1.279
birth_cohort1775M1780 0.8841 0.7218 1.102
birth_cohort1780M1785 0.9724 0.7957 1.21
birth_cohort1785M1790 0.927 0.7515 1.149
birth_cohort1790M1795 0.8018 0.6537 0.9908
birth_cohort1795M1800 0.8646 0.7093 1.064
birth_cohort1800M1805 0.8658 0.7079 1.058
birth_cohort1805M1810 0.9088 0.746 1.111
birth_cohort1810M1815 0.9246 0.7592 1.133
birth_cohort1815M1820 0.9985 0.8199 1.226
birth_cohort1820M1825 1.079 0.8863 1.322
birth_cohort1825M1830 1.054 0.864 1.292
birth_cohort1830M1835 1.085 0.8883 1.334
birth_cohort1835M1840 1.123 0.913 1.379
birth_cohort1840M1845 1.087 0.8827 1.34
birth_cohort1845M1850 1.022 0.8251 1.26
male1 1.023 1.009 1.036
maternalage.factor1020 1.018 0.9574 1.082
maternalage.factor3559 1.02 0.996 1.044
paternalage.mean 1.076 1.022 1.132
paternal_loss01 0.5908 0.5377 0.6484
paternal_loss15 0.6679 0.6203 0.718
paternal_loss510 0.654 0.6118 0.6977
paternal_loss1015 0.7422 0.7001 0.7875
paternal_loss1520 0.7421 0.7055 0.7832
paternal_loss2025 0.8351 0.7967 0.8768
paternal_loss2530 0.8859 0.8501 0.9248
paternal_loss3035 0.9279 0.8948 0.9633
paternal_loss3540 0.9675 0.9379 0.9982
paternal_loss4045 1.021 0.9922 1.049
maternal_loss01 0.2336 0.2076 0.2631
maternal_loss15 0.4328 0.399 0.4691
maternal_loss510 0.5213 0.4861 0.556
maternal_loss1015 0.5621 0.5287 0.5962
maternal_loss1520 0.5966 0.5627 0.6292
maternal_loss2025 0.6864 0.6543 0.7186
maternal_loss2530 0.8026 0.7701 0.8368
maternal_loss3035 0.8546 0.824 0.8848
maternal_loss3540 0.9274 0.9001 0.9547
maternal_loss4045 0.949 0.9247 0.9754
older_siblings1 1.074 1.051 1.097
older_siblings2 1.119 1.089 1.149
older_siblings3 1.162 1.123 1.203
older_siblings4 1.168 1.119 1.217
older_siblings5P 1.199 1.136 1.263
nr.siblings 1.014 1.004 1.024
last_born1 0.9756 0.9583 0.9937

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.61 [1.31;1.96] [1.41;1.84]
estimate father 35y 1.48 [1.19;1.82] [1.28;1.69]
percentage change -8.54 [-12.54;-4.62] [-11.08;-5.98]
OR/IRR 0.91 [0.87;0.95] [0.89;0.94]

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/ddb/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: 56663) 
## 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: 14746) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     1.17      0.02     1.13     1.21        904    1
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  2.05      0.28     1.48     2.60         79
## paternalage               -0.16      0.07    -0.30    -0.02        579
## birth_cohort1750M1755     -0.44      0.37    -1.12     0.31        186
## birth_cohort1755M1760      0.12      0.34    -0.50     0.81        117
## birth_cohort1760M1765      0.36      0.31    -0.26     0.99         94
## birth_cohort1765M1770      0.58      0.31    -0.02     1.21         90
## birth_cohort1770M1775      0.29      0.31    -0.32     0.93         92
## birth_cohort1775M1780      0.01      0.30    -0.56     0.63         84
## birth_cohort1780M1785      0.28      0.30    -0.31     0.90         86
## birth_cohort1785M1790      0.13      0.29    -0.42     0.72         75
## birth_cohort1790M1795     -0.20      0.27    -0.73     0.38         74
## birth_cohort1795M1800      0.00      0.27    -0.53     0.58         73
## birth_cohort1800M1805     -0.02      0.27    -0.53     0.55         72
## birth_cohort1805M1810      0.07      0.27    -0.46     0.62         73
## birth_cohort1810M1815      0.03      0.26    -0.50     0.59         71
## birth_cohort1815M1820      0.28      0.26    -0.23     0.82         69
## birth_cohort1820M1825      0.41      0.26    -0.10     0.96         68
## birth_cohort1825M1830      0.34      0.26    -0.18     0.88         70
## birth_cohort1830M1835      0.36      0.26    -0.15     0.91         69
## birth_cohort1835M1840      0.38      0.26    -0.14     0.92         70
## birth_cohort1840M1845      0.33      0.26    -0.19     0.88         70
## birth_cohort1845M1850      0.29      0.26    -0.24     0.85         69
## male1                      0.04      0.03    -0.01     0.09       3000
## maternalage.factor1020     0.01      0.11    -0.22     0.23       3000
## maternalage.factor3559     0.06      0.04    -0.01     0.14       1932
## paternalage.mean           0.21      0.07     0.07     0.35        612
## paternal_loss01           -0.70      0.12    -0.93    -0.47       2000
## paternal_loss15           -0.61      0.08    -0.77    -0.45       1308
## paternal_loss510          -0.71      0.07    -0.85    -0.58       1026
## paternal_loss1015         -0.56      0.06    -0.68    -0.43       1090
## paternal_loss1520         -0.56      0.06    -0.67    -0.44       1076
## paternal_loss2025         -0.39      0.06    -0.50    -0.28        933
## paternal_loss2530         -0.28      0.05    -0.39    -0.17        909
## paternal_loss3035         -0.21      0.05    -0.32    -0.10       1015
## paternal_loss3540         -0.08      0.05    -0.18     0.03       1150
## paternal_loss4045          0.02      0.05    -0.09     0.12       1081
## maternal_loss01           -1.51      0.13    -1.76    -1.27       2245
## maternal_loss15           -0.96      0.09    -1.14    -0.79       2017
## maternal_loss510          -0.87      0.07    -1.01    -0.73       1927
## maternal_loss1015         -0.86      0.07    -1.00    -0.74       1652
## maternal_loss1520         -0.76      0.07    -0.88    -0.63       1569
## maternal_loss2025         -0.61      0.06    -0.73    -0.49       1524
## maternal_loss2530         -0.40      0.05    -0.50    -0.29       1473
## maternal_loss3035         -0.31      0.05    -0.40    -0.21       1544
## maternal_loss3540         -0.17      0.05    -0.26    -0.07       1550
## maternal_loss4045         -0.13      0.05    -0.23    -0.04       1581
## older_siblings1            0.07      0.04    -0.01     0.15       1169
## older_siblings2            0.09      0.05    -0.01     0.20        718
## older_siblings3            0.13      0.07     0.00     0.26        607
## older_siblings4            0.11      0.08    -0.05     0.28        580
## older_siblings5P           0.16      0.11    -0.04     0.37        508
## nr.siblings                0.01      0.01    -0.01     0.03        454
## last_born1                -0.03      0.03    -0.10     0.03       3000
##                        Rhat
## Intercept              1.04
## paternalage            1.01
## birth_cohort1750M1755  1.02
## birth_cohort1755M1760  1.03
## birth_cohort1760M1765  1.03
## birth_cohort1765M1770  1.03
## birth_cohort1770M1775  1.03
## birth_cohort1775M1780  1.04
## birth_cohort1780M1785  1.03
## birth_cohort1785M1790  1.04
## birth_cohort1790M1795  1.04
## birth_cohort1795M1800  1.04
## birth_cohort1800M1805  1.04
## birth_cohort1805M1810  1.04
## birth_cohort1810M1815  1.04
## birth_cohort1815M1820  1.04
## birth_cohort1820M1825  1.04
## birth_cohort1825M1830  1.04
## birth_cohort1830M1835  1.04
## birth_cohort1835M1840  1.04
## birth_cohort1840M1845  1.04
## birth_cohort1845M1850  1.04
## male1                  1.00
## maternalage.factor1020 1.00
## maternalage.factor3559 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
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     2.94      0.01     2.92     2.96       2292    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 7.776 4.389 13.43
paternalage 0.8542 0.7431 0.9792
birth_cohort1750M1755 0.6446 0.3255 1.358
birth_cohort1755M1760 1.129 0.6068 2.25
birth_cohort1760M1765 1.427 0.7744 2.686
birth_cohort1765M1770 1.789 0.9831 3.363
birth_cohort1770M1775 1.339 0.723 2.546
birth_cohort1775M1780 1.013 0.5713 1.878
birth_cohort1780M1785 1.319 0.735 2.462
birth_cohort1785M1790 1.137 0.6584 2.055
birth_cohort1790M1795 0.8197 0.4812 1.458
birth_cohort1795M1800 0.9998 0.5909 1.791
birth_cohort1800M1805 0.9765 0.5882 1.726
birth_cohort1805M1810 1.069 0.6328 1.866
birth_cohort1810M1815 1.03 0.6066 1.797
birth_cohort1815M1820 1.319 0.7933 2.266
birth_cohort1820M1825 1.514 0.9058 2.612
birth_cohort1825M1830 1.399 0.8339 2.406
birth_cohort1830M1835 1.434 0.862 2.489
birth_cohort1835M1840 1.463 0.8733 2.504
birth_cohort1840M1845 1.389 0.8264 2.407
birth_cohort1845M1850 1.33 0.789 2.333
male1 1.036 0.987 1.091
maternalage.factor1020 1.011 0.8048 1.257
maternalage.factor3559 1.065 0.9865 1.148
paternalage.mean 1.23 1.068 1.414
paternal_loss01 0.497 0.3929 0.6229
paternal_loss15 0.5443 0.4652 0.6364
paternal_loss510 0.4913 0.4282 0.5621
paternal_loss1015 0.572 0.5048 0.648
paternal_loss1520 0.5715 0.5096 0.6454
paternal_loss2025 0.6771 0.6066 0.7575
paternal_loss2530 0.7577 0.6802 0.8437
paternal_loss3035 0.8124 0.7282 0.9006
paternal_loss3540 0.9256 0.8368 1.028
paternal_loss4045 1.016 0.9165 1.127
maternal_loss01 0.2211 0.1721 0.2814
maternal_loss15 0.3824 0.3203 0.4533
maternal_loss510 0.4202 0.3636 0.4839
maternal_loss1015 0.4215 0.3671 0.4794
maternal_loss1520 0.4688 0.4132 0.5305
maternal_loss2025 0.5427 0.4806 0.6103
maternal_loss2530 0.6705 0.6036 0.7456
maternal_loss3035 0.7353 0.6671 0.8123
maternal_loss3540 0.8436 0.7726 0.9282
maternal_loss4045 0.8742 0.796 0.9632
older_siblings1 1.073 0.9887 1.16
older_siblings2 1.099 0.9938 1.217
older_siblings3 1.135 0.9969 1.294
older_siblings4 1.121 0.9558 1.321
older_siblings5P 1.17 0.9594 1.441
nr.siblings 1.008 0.9891 1.027
last_born1 0.9657 0.9017 1.033

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.43 [1.86;2.94] [2.09;2.76]
estimate father 35y 2.27 [1.71;2.79] [1.92;2.61]
percentage change -6.48 [-12.63;-0.85] [-10.4;-2.81]
OR/IRR 0.85 [0.74;0.98] [0.78;0.93]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.37       1183    1
## sd(hu_Intercept)     0.82      0.02     0.78     0.86        659    1
## 
## Population-Level Effects: 
##                          Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                    1.32      0.08     1.16     1.47        201
## paternalage                 -0.01      0.02    -0.04     0.02        840
## birth_cohort1750M1755       -0.16      0.12    -0.40     0.07        681
## birth_cohort1755M1760        0.10      0.10    -0.09     0.29        305
## birth_cohort1760M1765        0.16      0.09    -0.01     0.33        240
## birth_cohort1765M1770        0.11      0.09    -0.06     0.28        244
## birth_cohort1770M1775        0.06      0.09    -0.11     0.23        245
## birth_cohort1775M1780        0.04      0.09    -0.13     0.21        224
## birth_cohort1780M1785        0.15      0.08    -0.01     0.32        211
## birth_cohort1785M1790        0.13      0.08    -0.03     0.29        200
## birth_cohort1790M1795        0.03      0.08    -0.13     0.19        201
## birth_cohort1795M1800        0.02      0.08    -0.13     0.17        191
## birth_cohort1800M1805       -0.02      0.08    -0.16     0.13        193
## birth_cohort1805M1810       -0.01      0.08    -0.15     0.14        186
## birth_cohort1810M1815        0.02      0.07    -0.13     0.17        183
## birth_cohort1815M1820        0.07      0.07    -0.07     0.22        183
## birth_cohort1820M1825        0.09      0.07    -0.05     0.23        179
## birth_cohort1825M1830        0.04      0.07    -0.10     0.19        182
## birth_cohort1830M1835        0.07      0.07    -0.07     0.22        182
## birth_cohort1835M1840        0.07      0.07    -0.08     0.22        181
## birth_cohort1840M1845        0.05      0.07    -0.10     0.19        179
## birth_cohort1845M1850        0.05      0.07    -0.09     0.20        178
## male1                        0.04      0.01     0.03     0.05       3000
## paternalage.mean             0.02      0.02    -0.01     0.06        887
## paternal_loss01              0.05      0.04    -0.01     0.12       1846
## paternal_loss15              0.02      0.02    -0.03     0.06       1430
## paternal_loss510            -0.02      0.02    -0.07     0.02       1015
## paternal_loss1015           -0.02      0.02    -0.06     0.01       1207
## paternal_loss1520           -0.08      0.02    -0.11    -0.04       1238
## paternal_loss2025           -0.03      0.02    -0.06     0.00       1247
## paternal_loss2530           -0.02      0.02    -0.05     0.01       1183
## paternal_loss3035           -0.02      0.01    -0.04     0.01       1202
## paternal_loss3540            0.02      0.01     0.00     0.05       1518
## paternal_loss4045            0.03      0.01     0.00     0.05       1762
## maternal_loss01              0.07      0.05    -0.04     0.17       3000
## maternal_loss15              0.00      0.03    -0.06     0.06       1970
## maternal_loss510            -0.02      0.02    -0.06     0.02       1835
## maternal_loss1015           -0.03      0.02    -0.08     0.01       1786
## maternal_loss1520           -0.03      0.02    -0.07     0.01       1928
## maternal_loss2025           -0.06      0.02    -0.10    -0.03       1919
## maternal_loss2530           -0.02      0.01    -0.05     0.01       1932
## maternal_loss3035           -0.01      0.01    -0.04     0.01       1874
## maternal_loss3540            0.01      0.01    -0.02     0.03       1878
## maternal_loss4045           -0.02      0.01    -0.04     0.01       3000
## older_siblings1              0.01      0.01    -0.01     0.03       1471
## older_siblings2              0.02      0.01    -0.01     0.04       1115
## older_siblings3              0.02      0.02    -0.01     0.06        923
## older_siblings4              0.00      0.02    -0.04     0.04        967
## older_siblings5P             0.01      0.03    -0.04     0.07        839
## nr.siblings                  0.02      0.00     0.02     0.03        911
## last_born1                  -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                -0.03      0.20    -0.41     0.36        152
## hu_paternalage               0.09      0.05    -0.01     0.20        569
## hu_birth_cohort1750M1755     0.34      0.28    -0.20     0.90        371
## hu_birth_cohort1755M1760     0.05      0.25    -0.43     0.53        306
## hu_birth_cohort1760M1765    -0.07      0.23    -0.51     0.38        185
## hu_birth_cohort1765M1770    -0.36      0.23    -0.78     0.08        215
## hu_birth_cohort1770M1775    -0.13      0.23    -0.58     0.30        227
## hu_birth_cohort1775M1780     0.02      0.22    -0.39     0.46        210
## hu_birth_cohort1780M1785    -0.04      0.22    -0.45     0.39        202
## hu_birth_cohort1785M1790     0.11      0.21    -0.29     0.52        174
## hu_birth_cohort1790M1795     0.29      0.20    -0.09     0.67        170
## hu_birth_cohort1795M1800     0.09      0.20    -0.29     0.47        174
## hu_birth_cohort1800M1805     0.01      0.20    -0.37     0.39        160
## hu_birth_cohort1805M1810    -0.04      0.19    -0.41     0.34        154
## hu_birth_cohort1810M1815     0.04      0.19    -0.33     0.41        150
## hu_birth_cohort1815M1820    -0.13      0.19    -0.49     0.23        154
## hu_birth_cohort1820M1825    -0.23      0.19    -0.59     0.13        145
## hu_birth_cohort1825M1830    -0.23      0.19    -0.60     0.13        145
## hu_birth_cohort1830M1835    -0.22      0.19    -0.58     0.16        146
## hu_birth_cohort1835M1840    -0.24      0.19    -0.59     0.13        150
## hu_birth_cohort1840M1845    -0.22      0.19    -0.59     0.16        141
## hu_birth_cohort1845M1850    -0.19      0.19    -0.55     0.19        150
## hu_male1                     0.04      0.02     0.01     0.08       3000
## hu_paternalage.mean         -0.11      0.05    -0.21    -0.01        571
## hu_paternal_loss01           0.86      0.09     0.68     1.04       3000
## hu_paternal_loss15           0.66      0.06     0.54     0.79       3000
## hu_paternal_loss510          0.68      0.05     0.58     0.78       1467
## hu_paternal_loss1015         0.52      0.05     0.42     0.61       1491
## hu_paternal_loss1520         0.42      0.04     0.33     0.51       1330
## hu_paternal_loss2025         0.32      0.04     0.24     0.41       1169
## hu_paternal_loss2530         0.22      0.04     0.14     0.30       1231
## hu_paternal_loss3035         0.16      0.04     0.08     0.23       1170
## hu_paternal_loss3540         0.12      0.04     0.04     0.19       1434
## hu_paternal_loss4045         0.04      0.04    -0.04     0.11       1695
## hu_maternal_loss01           1.86      0.12     1.63     2.09       3000
## hu_maternal_loss15           1.02      0.07     0.89     1.16       1742
## hu_maternal_loss510          0.86      0.06     0.76     0.97       3000
## hu_maternal_loss1015         0.81      0.06     0.70     0.92       3000
## hu_maternal_loss1520         0.68      0.05     0.58     0.78       3000
## hu_maternal_loss2025         0.46      0.04     0.38     0.55       1681
## hu_maternal_loss2530         0.32      0.04     0.24     0.40       1594
## hu_maternal_loss3035         0.25      0.04     0.18     0.33       1884
## hu_maternal_loss3540         0.15      0.03     0.08     0.21       2050
## hu_maternal_loss4045         0.08      0.04     0.01     0.15       3000
## hu_older_siblings1          -0.05      0.03    -0.11     0.01       1506
## hu_older_siblings2          -0.05      0.04    -0.12     0.03        917
## hu_older_siblings3          -0.06      0.05    -0.16     0.04        842
## hu_older_siblings4          -0.09      0.06    -0.22     0.03        628
## hu_older_siblings5P         -0.15      0.08    -0.31     0.01        707
## hu_nr.siblings               0.05      0.01     0.03     0.06        846
## hu_last_born1                0.01      0.03    -0.04     0.06       3000
##                          Rhat
## Intercept                1.01
## paternalage              1.01
## birth_cohort1750M1755    1.00
## birth_cohort1755M1760    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.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
## birth_cohort1835M1840    1.01
## birth_cohort1840M1845    1.01
## birth_cohort1845M1850    1.01
## male1                    1.00
## paternalage.mean         1.01
## paternal_loss01          1.00
## paternal_loss15          1.00
## 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.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.01
## 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.05
## hu_paternalage           1.01
## hu_birth_cohort1750M1755 1.02
## hu_birth_cohort1755M1760 1.02
## 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.04
## hu_birth_cohort1790M1795 1.04
## hu_birth_cohort1795M1800 1.04
## hu_birth_cohort1800M1805 1.04
## hu_birth_cohort1805M1810 1.05
## hu_birth_cohort1810M1815 1.04
## hu_birth_cohort1815M1820 1.04
## hu_birth_cohort1820M1825 1.05
## hu_birth_cohort1825M1830 1.05
## hu_birth_cohort1830M1835 1.05
## hu_birth_cohort1835M1840 1.05
## hu_birth_cohort1840M1845 1.05
## hu_birth_cohort1845M1850 1.05
## 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.01
## hu_paternal_loss3035     1.01
## hu_paternal_loss3540     1.01
## hu_paternal_loss4045     1.01
## 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.01
## hu_maternal_loss2530     1.00
## hu_maternal_loss3035     1.01
## 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 3.735 3.183 4.356
paternalage 0.9911 0.959 1.025
birth_cohort1750M1755 0.8484 0.6735 1.07
birth_cohort1755M1760 1.101 0.9116 1.331
birth_cohort1760M1765 1.169 0.9902 1.393
birth_cohort1765M1770 1.112 0.941 1.32
birth_cohort1770M1775 1.063 0.8983 1.263
birth_cohort1775M1780 1.041 0.8811 1.233
birth_cohort1780M1785 1.163 0.991 1.382
birth_cohort1785M1790 1.135 0.9693 1.338
birth_cohort1790M1795 1.029 0.8807 1.204
birth_cohort1795M1800 1.024 0.8817 1.189
birth_cohort1800M1805 0.9789 0.8487 1.137
birth_cohort1805M1810 0.9904 0.858 1.152
birth_cohort1810M1815 1.016 0.882 1.18
birth_cohort1815M1820 1.071 0.93 1.241
birth_cohort1820M1825 1.09 0.9469 1.26
birth_cohort1825M1830 1.043 0.9064 1.208
birth_cohort1830M1835 1.07 0.9279 1.245
birth_cohort1835M1840 1.068 0.9268 1.241
birth_cohort1840M1845 1.047 0.9087 1.213
birth_cohort1845M1850 1.055 0.9155 1.225
male1 1.041 1.028 1.055
paternalage.mean 1.023 0.9864 1.06
paternal_loss01 1.056 0.9852 1.132
paternal_loss15 1.018 0.9695 1.066
paternal_loss510 0.9762 0.9369 1.017
paternal_loss1015 0.9771 0.9423 1.015
paternal_loss1520 0.9273 0.897 0.96
paternal_loss2025 0.9707 0.9404 1.001
paternal_loss2530 0.978 0.9497 1.007
paternal_loss3035 0.9843 0.9583 1.011
paternal_loss3540 1.022 0.9964 1.048
paternal_loss4045 1.029 1.001 1.056
maternal_loss01 1.071 0.9633 1.185
maternal_loss15 1.001 0.9458 1.06
maternal_loss510 0.9805 0.9382 1.025
maternal_loss1015 0.9668 0.9267 1.008
maternal_loss1520 0.9715 0.9345 1.01
maternal_loss2025 0.9394 0.909 0.9715
maternal_loss2530 0.9808 0.9514 1.01
maternal_loss3035 0.9861 0.9596 1.014
maternal_loss3540 1.007 0.9829 1.032
maternal_loss4045 0.9843 0.9614 1.008
older_siblings1 1.009 0.9883 1.03
older_siblings2 1.016 0.9886 1.044
older_siblings3 1.022 0.988 1.057
older_siblings4 0.9984 0.9579 1.039
older_siblings5P 1.015 0.9603 1.069
nr.siblings 1.024 1.019 1.029
last_born1 0.9828 0.9644 1.002
hu_Intercept 0.9718 0.6635 1.433
hu_paternalage 1.097 0.9916 1.216
hu_birth_cohort1750M1755 1.403 0.8155 2.458
hu_birth_cohort1755M1760 1.051 0.6517 1.703
hu_birth_cohort1760M1765 0.9358 0.6 1.463
hu_birth_cohort1765M1770 0.6976 0.4562 1.086
hu_birth_cohort1770M1775 0.8759 0.5609 1.353
hu_birth_cohort1775M1780 1.024 0.6767 1.582
hu_birth_cohort1780M1785 0.9632 0.6381 1.471
hu_birth_cohort1785M1790 1.112 0.7463 1.684
hu_birth_cohort1790M1795 1.335 0.9159 1.961
hu_birth_cohort1795M1800 1.096 0.7505 1.604
hu_birth_cohort1800M1805 1.011 0.6936 1.476
hu_birth_cohort1805M1810 0.9647 0.6657 1.405
hu_birth_cohort1810M1815 1.039 0.722 1.503
hu_birth_cohort1815M1820 0.8811 0.6148 1.264
hu_birth_cohort1820M1825 0.7933 0.5546 1.144
hu_birth_cohort1825M1830 0.7921 0.5488 1.137
hu_birth_cohort1830M1835 0.8062 0.561 1.169
hu_birth_cohort1835M1840 0.7888 0.5519 1.138
hu_birth_cohort1840M1845 0.7997 0.5567 1.171
hu_birth_cohort1845M1850 0.8296 0.5771 1.204
hu_male1 1.045 1.006 1.087
hu_paternalage.mean 0.8944 0.8071 0.9932
hu_paternal_loss01 2.353 1.981 2.833
hu_paternal_loss15 1.936 1.712 2.196
hu_paternal_loss510 1.979 1.785 2.185
hu_paternal_loss1015 1.679 1.527 1.838
hu_paternal_loss1520 1.524 1.396 1.662
hu_paternal_loss2025 1.376 1.267 1.503
hu_paternal_loss2530 1.249 1.155 1.355
hu_paternal_loss3035 1.17 1.079 1.265
hu_paternal_loss3540 1.125 1.042 1.21
hu_paternal_loss4045 1.038 0.9587 1.121
hu_maternal_loss01 6.396 5.11 8.115
hu_maternal_loss15 2.781 2.428 3.196
hu_maternal_loss510 2.374 2.13 2.647
hu_maternal_loss1015 2.244 2.008 2.504
hu_maternal_loss1520 1.971 1.786 2.181
hu_maternal_loss2025 1.592 1.458 1.736
hu_maternal_loss2530 1.377 1.266 1.495
hu_maternal_loss3035 1.285 1.191 1.384
hu_maternal_loss3540 1.16 1.084 1.239
hu_maternal_loss4045 1.081 1.007 1.158
hu_older_siblings1 0.9531 0.8985 1.01
hu_older_siblings2 0.9545 0.8864 1.032
hu_older_siblings3 0.9395 0.8517 1.036
hu_older_siblings4 0.9101 0.8006 1.033
hu_older_siblings5P 0.8571 0.7322 1.006
hu_nr.siblings 1.049 1.034 1.064
hu_last_born1 1.012 0.9612 1.063

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.19 [1.72;2.79] [1.89;2.55]
estimate father 35y 2.08 [1.6;2.64] [1.77;2.42]
percentage change -5.55 [-11.28;0.5] [-9.2;-1.75]
OR/IRR 0.99 [0.96;1.03] [0.97;1.01]
OR hurdle 1.1 [0.99;1.22] [1.03;1.17]

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/ddb/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: 56666) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37        988 1.01
## sd(hu_Intercept)     0.82      0.02     0.79     0.85        912 1.01
## 
## Population-Level Effects: 
##                          Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                    1.13      0.09     0.96     1.29        178
## paternalage                 -0.08      0.02    -0.12    -0.04        562
## maternalage                  0.07      0.01     0.05     0.10        989
## birth_cohort1750M1755       -0.17      0.12    -0.40     0.06        480
## birth_cohort1755M1760        0.09      0.09    -0.10     0.26        258
## birth_cohort1760M1765        0.15      0.08    -0.03     0.31        189
## birth_cohort1765M1770        0.10      0.08    -0.08     0.26        182
## birth_cohort1770M1775        0.06      0.09    -0.11     0.23        192
## birth_cohort1775M1780        0.04      0.08    -0.13     0.20        187
## birth_cohort1780M1785        0.15      0.08    -0.02     0.31        178
## birth_cohort1785M1790        0.12      0.08    -0.04     0.28        168
## birth_cohort1790M1795        0.02      0.08    -0.14     0.17        158
## birth_cohort1795M1800        0.01      0.08    -0.14     0.16        149
## birth_cohort1800M1805       -0.03      0.08    -0.19     0.12        145
## birth_cohort1805M1810       -0.02      0.07    -0.17     0.13        144
## birth_cohort1810M1815        0.01      0.07    -0.14     0.16        140
## birth_cohort1815M1820        0.06      0.07    -0.09     0.20        137
## birth_cohort1820M1825        0.08      0.07    -0.07     0.22        136
## birth_cohort1825M1830        0.04      0.07    -0.11     0.18        136
## birth_cohort1830M1835        0.06      0.07    -0.08     0.21        136
## birth_cohort1835M1840        0.06      0.07    -0.09     0.21        137
## birth_cohort1840M1845        0.04      0.07    -0.10     0.18        137
## birth_cohort1845M1850        0.05      0.07    -0.10     0.19        136
## male1                        0.04      0.01     0.03     0.05       3000
## paternalage.mean             0.08      0.02     0.04     0.13        544
## paternal_loss01              0.07      0.04     0.00     0.14       1540
## paternal_loss15              0.03      0.03    -0.02     0.08       1282
## paternal_loss510            -0.01      0.02    -0.06     0.03        992
## paternal_loss1015           -0.02      0.02    -0.05     0.02       1009
## paternal_loss1520           -0.07      0.02    -0.11    -0.04        879
## paternal_loss2025           -0.03      0.02    -0.06     0.01        821
## paternal_loss2530           -0.02      0.01    -0.05     0.01        893
## paternal_loss3035           -0.02      0.01    -0.04     0.01        915
## paternal_loss3540            0.02      0.01     0.00     0.05       1210
## paternal_loss4045            0.03      0.01     0.00     0.05       1552
## maternal_loss01              0.08      0.05    -0.03     0.18       1999
## maternal_loss15              0.01      0.03    -0.05     0.07       1706
## maternal_loss510            -0.02      0.02    -0.06     0.03       1452
## maternal_loss1015           -0.04      0.02    -0.08     0.01       1553
## maternal_loss1520           -0.03      0.02    -0.07     0.00       1347
## maternal_loss2025           -0.07      0.02    -0.10    -0.04       1273
## maternal_loss2530           -0.03      0.02    -0.06     0.00       1342
## maternal_loss3035           -0.02      0.01    -0.05     0.00       1249
## maternal_loss3540            0.00      0.01    -0.02     0.02       1373
## maternal_loss4045           -0.02      0.01    -0.04     0.00       1865
## older_siblings1              0.01      0.01    -0.01     0.03       1272
## older_siblings2              0.02      0.01    -0.01     0.04        843
## older_siblings3              0.02      0.02    -0.01     0.06        758
## older_siblings4              0.00      0.02    -0.04     0.04        742
## older_siblings5P             0.02      0.03    -0.04     0.07        677
## nr.siblings                  0.02      0.00     0.02     0.03        735
## last_born1                  -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                -0.28      0.21    -0.71     0.11        220
## hu_paternalage               0.03      0.06    -0.09     0.15        623
## hu_maternalage               0.07      0.03     0.02     0.13       1290
## hu_birth_cohort1750M1755     0.40      0.29    -0.15     0.97        572
## hu_birth_cohort1755M1760     0.11      0.25    -0.37     0.60        367
## hu_birth_cohort1760M1765    -0.02      0.23    -0.46     0.42        287
## hu_birth_cohort1765M1770    -0.29      0.22    -0.74     0.14        296
## hu_birth_cohort1770M1775    -0.06      0.22    -0.48     0.38        279
## hu_birth_cohort1775M1780     0.09      0.22    -0.34     0.52        266
## hu_birth_cohort1780M1785     0.03      0.22    -0.40     0.45        265
## hu_birth_cohort1785M1790     0.16      0.21    -0.25     0.57        239
## hu_birth_cohort1790M1795     0.34      0.19    -0.04     0.70        230
## hu_birth_cohort1795M1800     0.15      0.19    -0.25     0.51        236
## hu_birth_cohort1800M1805     0.07      0.19    -0.30     0.45        231
## hu_birth_cohort1805M1810     0.02      0.19    -0.35     0.38        219
## hu_birth_cohort1810M1815     0.10      0.19    -0.28     0.45        216
## hu_birth_cohort1815M1820    -0.07      0.18    -0.44     0.28        214
## hu_birth_cohort1820M1825    -0.17      0.18    -0.54     0.18        213
## hu_birth_cohort1825M1830    -0.17      0.18    -0.54     0.18        215
## hu_birth_cohort1830M1835    -0.15      0.18    -0.52     0.20        211
## hu_birth_cohort1835M1840    -0.17      0.18    -0.54     0.18        214
## hu_birth_cohort1840M1845    -0.16      0.18    -0.53     0.20        212
## hu_birth_cohort1845M1850    -0.13      0.18    -0.49     0.22        209
## hu_male1                     0.04      0.02     0.01     0.08       3000
## hu_paternalage.mean         -0.06      0.06    -0.18     0.06        641
## hu_paternal_loss01           0.87      0.09     0.69     1.05       3000
## hu_paternal_loss15           0.67      0.06     0.55     0.79       1482
## hu_paternal_loss510          0.69      0.05     0.59     0.80       1308
## hu_paternal_loss1015         0.52      0.05     0.43     0.62       1345
## hu_paternal_loss1520         0.42      0.04     0.34     0.51       1074
## hu_paternal_loss2025         0.32      0.04     0.24     0.40       1112
## hu_paternal_loss2530         0.23      0.04     0.15     0.30       1070
## hu_paternal_loss3035         0.16      0.04     0.08     0.23       1237
## hu_paternal_loss3540         0.12      0.04     0.04     0.19       1293
## hu_paternal_loss4045         0.04      0.04    -0.04     0.11       1545
## hu_maternal_loss01           1.86      0.12     1.64     2.09       3000
## hu_maternal_loss15           1.03      0.07     0.88     1.16       2092
## hu_maternal_loss510          0.86      0.06     0.75     0.98       1776
## hu_maternal_loss1015         0.80      0.06     0.69     0.91       3000
## hu_maternal_loss1520         0.67      0.05     0.57     0.77       1473
## hu_maternal_loss2025         0.45      0.04     0.37     0.54       1604
## hu_maternal_loss2530         0.31      0.04     0.23     0.39       1538
## hu_maternal_loss3035         0.24      0.04     0.16     0.32       1665
## hu_maternal_loss3540         0.14      0.04     0.07     0.21       1631
## hu_maternal_loss4045         0.07      0.04     0.00     0.14       1827
## hu_older_siblings1          -0.05      0.03    -0.11     0.01       1110
## hu_older_siblings2          -0.05      0.04    -0.13     0.03        743
## hu_older_siblings3          -0.07      0.05    -0.17     0.03        685
## hu_older_siblings4          -0.10      0.06    -0.23     0.02        676
## hu_older_siblings5P         -0.17      0.08    -0.33    -0.01        584
## hu_nr.siblings               0.05      0.01     0.03     0.06        665
## hu_last_born1                0.01      0.03    -0.04     0.06       3000
##                          Rhat
## Intercept                1.02
## paternalage              1.02
## maternalage              1.01
## birth_cohort1750M1755    1.01
## birth_cohort1755M1760    1.01
## birth_cohort1760M1765    1.01
## birth_cohort1765M1770    1.01
## birth_cohort1770M1775    1.01
## birth_cohort1775M1780    1.01
## birth_cohort1780M1785    1.01
## birth_cohort1785M1790    1.01
## 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
## male1                    1.00
## paternalage.mean         1.02
## paternal_loss01          1.00
## paternal_loss15          1.00
## paternal_loss510         1.00
## paternal_loss1015        1.01
## paternal_loss1520        1.00
## paternal_loss2025        1.01
## paternal_loss2530        1.01
## paternal_loss3035        1.00
## paternal_loss3540        1.00
## paternal_loss4045        1.00
## maternal_loss01          1.00
## maternal_loss15          1.01
## 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.02
## hu_paternalage           1.01
## hu_maternalage           1.00
## hu_birth_cohort1750M1755 1.01
## hu_birth_cohort1755M1760 1.01
## hu_birth_cohort1760M1765 1.01
## hu_birth_cohort1765M1770 1.01
## hu_birth_cohort1770M1775 1.01
## 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.02
## hu_birth_cohort1820M1825 1.02
## hu_birth_cohort1825M1830 1.02
## hu_birth_cohort1830M1835 1.02
## hu_birth_cohort1835M1840 1.02
## hu_birth_cohort1840M1845 1.02
## hu_birth_cohort1845M1850 1.02
## hu_male1                 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.01
## 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.01
## 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.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 3.091 2.604 3.646
paternalage 0.9203 0.8833 0.9588
maternalage 1.075 1.05 1.101
birth_cohort1750M1755 0.847 0.6731 1.058
birth_cohort1755M1760 1.09 0.9065 1.303
birth_cohort1760M1765 1.156 0.9752 1.363
birth_cohort1765M1770 1.102 0.9273 1.296
birth_cohort1770M1775 1.058 0.8979 1.257
birth_cohort1775M1780 1.039 0.8813 1.221
birth_cohort1780M1785 1.158 0.983 1.365
birth_cohort1785M1790 1.126 0.9582 1.318
birth_cohort1790M1795 1.016 0.8682 1.18
birth_cohort1795M1800 1.013 0.8658 1.177
birth_cohort1800M1805 0.967 0.8294 1.122
birth_cohort1805M1810 0.9813 0.8441 1.136
birth_cohort1810M1815 1.008 0.8695 1.169
birth_cohort1815M1820 1.061 0.9175 1.224
birth_cohort1820M1825 1.082 0.9323 1.251
birth_cohort1825M1830 1.039 0.8948 1.199
birth_cohort1830M1835 1.066 0.9208 1.23
birth_cohort1835M1840 1.063 0.9175 1.23
birth_cohort1840M1845 1.042 0.9027 1.202
birth_cohort1845M1850 1.049 0.9057 1.21
male1 1.041 1.027 1.055
paternalage.mean 1.088 1.043 1.135
paternal_loss01 1.072 0.9986 1.152
paternal_loss15 1.034 0.9837 1.087
paternal_loss510 0.986 0.9464 1.029
paternal_loss1015 0.9842 0.9495 1.021
paternal_loss1520 0.9305 0.8989 0.9631
paternal_loss2025 0.9734 0.9437 1.005
paternal_loss2530 0.979 0.9507 1.008
paternal_loss3035 0.9845 0.9574 1.012
paternal_loss3540 1.021 0.996 1.048
paternal_loss4045 1.028 1.002 1.055
maternal_loss01 1.08 0.972 1.199
maternal_loss15 1.009 0.9549 1.07
maternal_loss510 0.9824 0.9385 1.027
maternal_loss1015 0.9647 0.9254 1.006
maternal_loss1520 0.9656 0.9281 1.005
maternal_loss2025 0.9313 0.9016 0.9638
maternal_loss2530 0.9718 0.9436 1.001
maternal_loss3035 0.9778 0.951 1.004
maternal_loss3540 1 0.9771 1.025
maternal_loss4045 0.9791 0.9563 1.002
older_siblings1 1.009 0.9896 1.03
older_siblings2 1.017 0.9897 1.045
older_siblings3 1.023 0.9872 1.059
older_siblings4 0.9992 0.9579 1.042
older_siblings5P 1.016 0.9622 1.072
nr.siblings 1.025 1.02 1.03
last_born1 0.9834 0.965 1.002
hu_Intercept 0.7521 0.4935 1.117
hu_paternalage 1.029 0.9102 1.159
hu_maternalage 1.075 1.015 1.14
hu_birth_cohort1750M1755 1.485 0.8593 2.645
hu_birth_cohort1755M1760 1.114 0.6905 1.827
hu_birth_cohort1760M1765 0.983 0.6344 1.526
hu_birth_cohort1765M1770 0.7476 0.4774 1.145
hu_birth_cohort1770M1775 0.9391 0.6189 1.458
hu_birth_cohort1775M1780 1.098 0.7124 1.689
hu_birth_cohort1780M1785 1.03 0.6682 1.564
hu_birth_cohort1785M1790 1.178 0.7786 1.762
hu_birth_cohort1790M1795 1.409 0.9615 2.021
hu_birth_cohort1795M1800 1.161 0.7822 1.664
hu_birth_cohort1800M1805 1.073 0.7398 1.561
hu_birth_cohort1805M1810 1.024 0.7022 1.467
hu_birth_cohort1810M1815 1.106 0.7539 1.572
hu_birth_cohort1815M1820 0.9342 0.6469 1.327
hu_birth_cohort1820M1825 0.8452 0.5847 1.197
hu_birth_cohort1825M1830 0.8442 0.5846 1.192
hu_birth_cohort1830M1835 0.8585 0.5968 1.219
hu_birth_cohort1835M1840 0.8401 0.5802 1.198
hu_birth_cohort1840M1845 0.8513 0.5898 1.218
hu_birth_cohort1845M1850 0.8819 0.6118 1.252
hu_male1 1.046 1.007 1.086
hu_paternalage.mean 0.9421 0.8392 1.063
hu_paternal_loss01 2.399 2.003 2.858
hu_paternal_loss15 1.96 1.733 2.21
hu_paternal_loss510 1.998 1.803 2.219
hu_paternal_loss1015 1.687 1.536 1.853
hu_paternal_loss1520 1.528 1.4 1.667
hu_paternal_loss2025 1.379 1.27 1.496
hu_paternal_loss2530 1.253 1.158 1.355
hu_paternal_loss3035 1.17 1.083 1.26
hu_paternal_loss3540 1.125 1.045 1.208
hu_paternal_loss4045 1.04 0.9611 1.121
hu_maternal_loss01 6.406 5.144 8.063
hu_maternal_loss15 2.792 2.42 3.204
hu_maternal_loss510 2.367 2.11 2.668
hu_maternal_loss1015 2.229 1.994 2.492
hu_maternal_loss1520 1.947 1.762 2.163
hu_maternal_loss2025 1.571 1.441 1.72
hu_maternal_loss2530 1.36 1.255 1.478
hu_maternal_loss3035 1.271 1.174 1.374
hu_maternal_loss3540 1.15 1.075 1.235
hu_maternal_loss4045 1.074 0.9979 1.156
hu_older_siblings1 0.9503 0.8958 1.008
hu_older_siblings2 0.9503 0.8785 1.03
hu_older_siblings3 0.9325 0.8411 1.035
hu_older_siblings4 0.9011 0.7972 1.024
hu_older_siblings5P 0.8462 0.7215 0.9944
hu_nr.siblings 1.051 1.035 1.066
hu_last_born1 1.012 0.9617 1.066

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.36 [1.84;2.91] [2.01;2.74]
estimate father 35y 2.15 [1.67;2.67] [1.82;2.49]
percentage change -8.94 [-15.31;-2.32] [-13.13;-4.65]
OR/IRR 0.92 [0.88;0.96] [0.9;0.95]
OR hurdle 1.03 [0.91;1.16] [0.95;1.11]

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/ddb/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: 181577) 
## 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: 50139) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.35      0.00     0.34     0.36       1012 1.01
## sd(hu_Intercept)     1.01      0.01     0.99     1.04       1269 1.00
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.40      0.07     1.25     1.53        138
## paternalage                  -0.04      0.01    -0.07    -0.01        737
## birth_cohort1750M1755        -0.12      0.10    -0.32     0.08        307
## birth_cohort1755M1760         0.05      0.09    -0.12     0.22        217
## birth_cohort1760M1765         0.12      0.08    -0.02     0.28        163
## birth_cohort1765M1770         0.11      0.08    -0.04     0.27        157
## birth_cohort1770M1775         0.06      0.08    -0.10     0.22        167
## birth_cohort1775M1780         0.06      0.08    -0.09     0.23        154
## birth_cohort1780M1785         0.16      0.08     0.01     0.32        160
## birth_cohort1785M1790         0.10      0.08    -0.04     0.26        142
## birth_cohort1790M1795         0.02      0.07    -0.12     0.17        139
## birth_cohort1795M1800         0.02      0.07    -0.11     0.17        133
## birth_cohort1800M1805        -0.03      0.07    -0.15     0.12        132
## birth_cohort1805M1810         0.00      0.07    -0.13     0.14        131
## birth_cohort1810M1815         0.01      0.07    -0.12     0.15        131
## birth_cohort1815M1820         0.06      0.07    -0.06     0.21        124
## birth_cohort1820M1825         0.08      0.07    -0.05     0.22        124
## birth_cohort1825M1830         0.04      0.07    -0.08     0.19        123
## birth_cohort1830M1835         0.07      0.07    -0.06     0.21        122
## birth_cohort1835M1840         0.06      0.07    -0.06     0.20        125
## birth_cohort1840M1845         0.03      0.07    -0.10     0.17        123
## birth_cohort1845M1850         0.03      0.07    -0.10     0.17        121
## birth_cohort1850M1855         0.02      0.07    -0.10     0.16        122
## birth_cohort1855M1860        -0.09      0.07    -0.21     0.06        122
## birth_cohort1860M1865        -0.34      0.07    -0.46    -0.19        123
## birth_cohort1865M1870        -0.68      0.07    -0.80    -0.54        126
## birth_cohort1870M1875        -1.10      0.08    -1.23    -0.94        140
## birth_cohort1875M1880        -1.61      0.11    -1.83    -1.39        253
## male1                         0.00      0.01    -0.01     0.01       3000
## maternalage.factor1020        0.07      0.02     0.02     0.11       3000
## maternalage.factor3559        0.04      0.01     0.02     0.06       3000
## paternalage.mean              0.04      0.02     0.01     0.07        690
## paternal_loss01               0.05      0.03     0.00     0.11       2022
## paternal_loss15               0.02      0.02    -0.02     0.06       1543
## paternal_loss510             -0.02      0.02    -0.05     0.02       1456
## paternal_loss1015            -0.01      0.02    -0.04     0.02       1233
## paternal_loss1520            -0.05      0.01    -0.08    -0.02       1088
## paternal_loss2025            -0.02      0.01    -0.05     0.00       1115
## paternal_loss2530            -0.01      0.01    -0.04     0.01       1037
## paternal_loss3035             0.00      0.01    -0.03     0.02       1255
## paternal_loss3540             0.02      0.01     0.00     0.04       1267
## paternal_loss4045             0.04      0.01     0.02     0.06       1910
## paternal_lossunclear         -0.08      0.01    -0.11    -0.05       1295
## maternal_loss01               0.05      0.04    -0.04     0.13       3000
## maternal_loss15              -0.02      0.02    -0.06     0.02       1737
## maternal_loss510             -0.02      0.02    -0.06     0.02       1647
## maternal_loss1015            -0.05      0.02    -0.08    -0.01       1653
## maternal_loss1520            -0.02      0.02    -0.05     0.01       1728
## maternal_loss2025            -0.06      0.02    -0.08    -0.03       1473
## maternal_loss2530            -0.02      0.01    -0.05     0.00       1325
## maternal_loss3035            -0.02      0.01    -0.05     0.00       1692
## maternal_loss3540             0.00      0.01    -0.02     0.03       1728
## maternal_loss4045            -0.01      0.01    -0.03     0.01       3000
## maternal_lossunclear         -0.10      0.01    -0.13    -0.08       1518
## older_siblings1               0.01      0.01    -0.01     0.02       1722
## older_siblings2               0.01      0.01    -0.01     0.03       1359
## older_siblings3               0.01      0.01    -0.02     0.03       1096
## older_siblings4               0.00      0.02    -0.04     0.03        942
## older_siblings5P              0.01      0.02    -0.03     0.05        819
## nr.siblings                   0.02      0.00     0.02     0.03       1040
## last_born1                   -0.01      0.01    -0.03     0.00       3000
## hu_Intercept                  0.29      0.16    -0.02     0.60        137
## hu_paternalage                0.49      0.04     0.41     0.56        839
## hu_birth_cohort1750M1755      0.05      0.24    -0.41     0.53        449
## hu_birth_cohort1755M1760     -0.04      0.21    -0.44     0.39        267
## hu_birth_cohort1760M1765     -0.09      0.19    -0.45     0.29        194
## hu_birth_cohort1765M1770     -0.28      0.19    -0.66     0.09        192
## hu_birth_cohort1770M1775     -0.19      0.20    -0.57     0.19        198
## hu_birth_cohort1775M1780      0.15      0.19    -0.20     0.52        173
## hu_birth_cohort1780M1785      0.08      0.18    -0.26     0.44        178
## hu_birth_cohort1785M1790      0.24      0.18    -0.10     0.59        162
## hu_birth_cohort1790M1795      0.40      0.16     0.08     0.72        142
## hu_birth_cohort1795M1800      0.25      0.16    -0.05     0.58        140
## hu_birth_cohort1800M1805      0.17      0.16    -0.15     0.48        136
## hu_birth_cohort1805M1810      0.13      0.16    -0.17     0.44        135
## hu_birth_cohort1810M1815      0.22      0.16    -0.08     0.53        130
## hu_birth_cohort1815M1820      0.05      0.15    -0.25     0.36        127
## hu_birth_cohort1820M1825     -0.09      0.16    -0.39     0.22        128
## hu_birth_cohort1825M1830     -0.11      0.15    -0.41     0.19        128
## hu_birth_cohort1830M1835     -0.11      0.16    -0.40     0.21        127
## hu_birth_cohort1835M1840     -0.16      0.16    -0.46     0.15        127
## hu_birth_cohort1840M1845     -0.16      0.15    -0.45     0.15        125
## hu_birth_cohort1845M1850     -0.14      0.15    -0.44     0.18        126
## hu_birth_cohort1850M1855     -0.19      0.15    -0.48     0.11        126
## hu_birth_cohort1855M1860     -0.44      0.15    -0.74    -0.14        126
## hu_birth_cohort1860M1865     -0.32      0.15    -0.62    -0.02        127
## hu_birth_cohort1865M1870      0.03      0.16    -0.27     0.33        128
## hu_birth_cohort1870M1875      1.10      0.16     0.80     1.42        132
## hu_birth_cohort1875M1880      2.84      0.17     2.52     3.16        145
## hu_male1                      0.21      0.01     0.19     0.24       3000
## hu_maternalage.factor1020     0.17      0.06     0.04     0.29       3000
## hu_maternalage.factor3559    -0.08      0.02    -0.12    -0.04       3000
## hu_paternalage.mean          -0.48      0.04    -0.56    -0.41        779
## hu_paternal_loss01            0.49      0.07     0.35     0.63       3000
## hu_paternal_loss15            0.45      0.05     0.35     0.55       1133
## hu_paternal_loss510           0.48      0.05     0.39     0.57        895
## hu_paternal_loss1015          0.37      0.04     0.29     0.45        898
## hu_paternal_loss1520          0.26      0.04     0.18     0.34        849
## hu_paternal_loss2025          0.16      0.04     0.08     0.23        788
## hu_paternal_loss2530          0.06      0.04    -0.01     0.13        877
## hu_paternal_loss3035         -0.01      0.04    -0.08     0.06        983
## hu_paternal_loss3540         -0.02      0.04    -0.09     0.05       1101
## hu_paternal_loss4045         -0.09      0.04    -0.16    -0.02       1518
## hu_paternal_lossunclear       1.06      0.03     0.99     1.12        790
## hu_maternal_loss01            1.60      0.09     1.43     1.79       3000
## hu_maternal_loss15            0.81      0.06     0.70     0.92       3000
## hu_maternal_loss510           0.77      0.05     0.68     0.87       1417
## hu_maternal_loss1015          0.74      0.05     0.65     0.83       1457
## hu_maternal_loss1520          0.58      0.04     0.50     0.66       1581
## hu_maternal_loss2025          0.32      0.04     0.25     0.40       1631
## hu_maternal_loss2530          0.18      0.04     0.11     0.25       1221
## hu_maternal_loss3035          0.14      0.03     0.08     0.21       1316
## hu_maternal_loss3540          0.03      0.03    -0.03     0.10       3000
## hu_maternal_loss4045         -0.02      0.03    -0.08     0.05       3000
## hu_maternal_lossunclear       1.15      0.03     1.08     1.21       1157
## hu_older_siblings1           -0.05      0.02    -0.09    -0.01       1443
## hu_older_siblings2           -0.08      0.03    -0.13    -0.02       1033
## hu_older_siblings3           -0.13      0.04    -0.20    -0.06        863
## hu_older_siblings4           -0.22      0.04    -0.31    -0.14        884
## hu_older_siblings5P          -0.30      0.06    -0.42    -0.20        780
## hu_nr.siblings                0.00      0.01    -0.01     0.01        899
## hu_last_born1                 0.05      0.02     0.01     0.08       3000
##                           Rhat
## Intercept                 1.04
## paternalage               1.01
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.02
## birth_cohort1760M1765     1.03
## birth_cohort1765M1770     1.03
## birth_cohort1770M1775     1.03
## birth_cohort1775M1780     1.04
## birth_cohort1780M1785     1.03
## birth_cohort1785M1790     1.04
## birth_cohort1790M1795     1.04
## birth_cohort1795M1800     1.04
## birth_cohort1800M1805     1.04
## birth_cohort1805M1810     1.04
## birth_cohort1810M1815     1.04
## birth_cohort1815M1820     1.04
## birth_cohort1820M1825     1.04
## birth_cohort1825M1830     1.04
## birth_cohort1830M1835     1.04
## birth_cohort1835M1840     1.04
## birth_cohort1840M1845     1.04
## birth_cohort1845M1850     1.04
## birth_cohort1850M1855     1.04
## birth_cohort1855M1860     1.04
## birth_cohort1860M1865     1.04
## birth_cohort1865M1870     1.04
## birth_cohort1870M1875     1.04
## birth_cohort1875M1880     1.02
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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
## 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.01
## older_siblings3           1.01
## older_siblings4           1.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.02
## hu_paternalage            1.00
## hu_birth_cohort1750M1755  1.00
## hu_birth_cohort1755M1760  1.01
## hu_birth_cohort1760M1765  1.01
## hu_birth_cohort1765M1770  1.01
## hu_birth_cohort1770M1775  1.01
## hu_birth_cohort1775M1780  1.02
## hu_birth_cohort1780M1785  1.01
## hu_birth_cohort1785M1790  1.02
## hu_birth_cohort1790M1795  1.02
## hu_birth_cohort1795M1800  1.02
## hu_birth_cohort1800M1805  1.02
## hu_birth_cohort1805M1810  1.02
## hu_birth_cohort1810M1815  1.02
## hu_birth_cohort1815M1820  1.02
## hu_birth_cohort1820M1825  1.02
## hu_birth_cohort1825M1830  1.02
## hu_birth_cohort1830M1835  1.02
## hu_birth_cohort1835M1840  1.02
## hu_birth_cohort1840M1845  1.02
## hu_birth_cohort1845M1850  1.02
## hu_birth_cohort1850M1855  1.02
## hu_birth_cohort1855M1860  1.02
## hu_birth_cohort1860M1865  1.02
## hu_birth_cohort1865M1870  1.02
## hu_birth_cohort1870M1875  1.02
## hu_birth_cohort1875M1880  1.02
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 1.00
## hu_paternalage.mean       1.00
## hu_paternal_loss01        1.00
## hu_paternal_loss15        1.00
## hu_paternal_loss510       1.01
## 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.01
## 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 4.047 3.483 4.61
paternalage 0.9581 0.9315 0.9859
birth_cohort1750M1755 0.8881 0.7264 1.082
birth_cohort1755M1760 1.049 0.8856 1.251
birth_cohort1760M1765 1.127 0.9781 1.321
birth_cohort1765M1770 1.112 0.9579 1.306
birth_cohort1770M1775 1.058 0.9076 1.246
birth_cohort1775M1780 1.061 0.9162 1.254
birth_cohort1780M1785 1.17 1.015 1.371
birth_cohort1785M1790 1.109 0.9641 1.298
birth_cohort1790M1795 1.02 0.8912 1.183
birth_cohort1795M1800 1.021 0.8998 1.189
birth_cohort1800M1805 0.9724 0.8567 1.127
birth_cohort1805M1810 0.9962 0.8788 1.153
birth_cohort1810M1815 1.005 0.8865 1.164
birth_cohort1815M1820 1.067 0.9438 1.235
birth_cohort1820M1825 1.081 0.9551 1.248
birth_cohort1825M1830 1.043 0.9223 1.206
birth_cohort1830M1835 1.068 0.946 1.234
birth_cohort1835M1840 1.059 0.9377 1.223
birth_cohort1840M1845 1.028 0.9086 1.19
birth_cohort1845M1850 1.026 0.9085 1.186
birth_cohort1850M1855 1.018 0.9007 1.177
birth_cohort1855M1860 0.9178 0.8133 1.059
birth_cohort1860M1865 0.7131 0.6304 0.825
birth_cohort1865M1870 0.5067 0.4479 0.5852
birth_cohort1870M1875 0.3334 0.2913 0.3921
birth_cohort1875M1880 0.1992 0.1599 0.2481
male1 0.9977 0.9871 1.009
maternalage.factor1020 1.067 1.02 1.117
maternalage.factor3559 1.041 1.024 1.06
paternalage.mean 1.038 1.008 1.069
paternal_loss01 1.054 0.9962 1.114
paternal_loss15 1.02 0.9784 1.062
paternal_loss510 0.982 0.9474 1.018
paternal_loss1015 0.987 0.9564 1.018
paternal_loss1520 0.9479 0.9215 0.9764
paternal_loss2025 0.9761 0.9496 1.003
paternal_loss2530 0.9853 0.9604 1.011
paternal_loss3035 0.9953 0.9718 1.019
paternal_loss3540 1.018 0.9952 1.04
paternal_loss4045 1.04 1.016 1.064
paternal_lossunclear 0.9217 0.8977 0.9466
maternal_loss01 1.051 0.9654 1.142
maternal_loss15 0.9792 0.9379 1.025
maternal_loss510 0.9785 0.9416 1.017
maternal_loss1015 0.9519 0.9189 0.9873
maternal_loss1520 0.9826 0.9529 1.014
maternal_loss2025 0.9464 0.919 0.9743
maternal_loss2530 0.9781 0.9537 1.004
maternal_loss3035 0.9763 0.9533 0.9994
maternal_loss3540 1.004 0.9829 1.026
maternal_loss4045 0.9895 0.968 1.011
maternal_lossunclear 0.9006 0.8793 0.9231
older_siblings1 1.007 0.9896 1.024
older_siblings2 1.011 0.9892 1.032
older_siblings3 1.008 0.9813 1.035
older_siblings4 0.9953 0.9634 1.029
older_siblings5P 1.009 0.9684 1.053
nr.siblings 1.024 1.02 1.028
last_born1 0.9852 0.9705 0.9998
hu_Intercept 1.342 0.9825 1.822
hu_paternalage 1.626 1.511 1.756
hu_birth_cohort1750M1755 1.049 0.6643 1.706
hu_birth_cohort1755M1760 0.9649 0.6417 1.483
hu_birth_cohort1760M1765 0.9157 0.6371 1.338
hu_birth_cohort1765M1770 0.7523 0.518 1.098
hu_birth_cohort1770M1775 0.8265 0.567 1.206
hu_birth_cohort1775M1780 1.167 0.8198 1.677
hu_birth_cohort1780M1785 1.088 0.7687 1.558
hu_birth_cohort1785M1790 1.267 0.9022 1.797
hu_birth_cohort1790M1795 1.488 1.082 2.058
hu_birth_cohort1795M1800 1.289 0.9507 1.788
hu_birth_cohort1800M1805 1.18 0.8629 1.612
hu_birth_cohort1805M1810 1.142 0.8436 1.55
hu_birth_cohort1810M1815 1.246 0.9195 1.691
hu_birth_cohort1815M1820 1.049 0.7784 1.426
hu_birth_cohort1820M1825 0.9161 0.6795 1.247
hu_birth_cohort1825M1830 0.8941 0.6629 1.215
hu_birth_cohort1830M1835 0.897 0.6697 1.23
hu_birth_cohort1835M1840 0.8498 0.6313 1.161
hu_birth_cohort1840M1845 0.8542 0.6377 1.165
hu_birth_cohort1845M1850 0.8728 0.6467 1.194
hu_birth_cohort1850M1855 0.8241 0.6157 1.119
hu_birth_cohort1855M1860 0.6419 0.4759 0.8693
hu_birth_cohort1860M1865 0.7232 0.5366 0.9809
hu_birth_cohort1865M1870 1.031 0.7621 1.396
hu_birth_cohort1870M1875 3.015 2.22 4.151
hu_birth_cohort1875M1880 17.18 12.47 23.67
hu_male1 1.236 1.204 1.269
hu_maternalage.factor1020 1.183 1.046 1.341
hu_maternalage.factor3559 0.9228 0.884 0.9606
hu_paternalage.mean 0.6168 0.5706 0.6659
hu_paternal_loss01 1.64 1.422 1.882
hu_paternal_loss15 1.565 1.412 1.731
hu_paternal_loss510 1.612 1.472 1.763
hu_paternal_loss1015 1.449 1.331 1.572
hu_paternal_loss1520 1.297 1.197 1.405
hu_paternal_loss2025 1.172 1.086 1.262
hu_paternal_loss2530 1.061 0.9897 1.139
hu_paternal_loss3035 0.9897 0.9238 1.06
hu_paternal_loss3540 0.9794 0.9153 1.047
hu_paternal_loss4045 0.9136 0.8492 0.9844
hu_paternal_lossunclear 2.878 2.689 3.07
hu_maternal_loss01 4.96 4.178 5.996
hu_maternal_loss15 2.256 2.023 2.511
hu_maternal_loss510 2.165 1.98 2.379
hu_maternal_loss1015 2.094 1.91 2.286
hu_maternal_loss1520 1.778 1.642 1.932
hu_maternal_loss2025 1.383 1.282 1.495
hu_maternal_loss2530 1.2 1.117 1.288
hu_maternal_loss3035 1.152 1.078 1.231
hu_maternal_loss3540 1.035 0.9729 1.1
hu_maternal_loss4045 0.9811 0.9199 1.047
hu_maternal_lossunclear 3.144 2.956 3.347
hu_older_siblings1 0.9485 0.9097 0.9901
hu_older_siblings2 0.9254 0.8777 0.9774
hu_older_siblings3 0.8811 0.8201 0.9439
hu_older_siblings4 0.8042 0.7358 0.8726
hu_older_siblings5P 0.7373 0.6573 0.8224
hu_nr.siblings 0.9992 0.9889 1.01
hu_last_born1 1.048 1.008 1.087

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.53 [2.06;3.03] [2.21;2.86]
estimate father 35y 1.89 [1.48;2.31] [1.61;2.16]
percentage change -25.5 [-29.91;-21.11] [-28.51;-22.53]
OR/IRR 0.96 [0.93;0.99] [0.94;0.98]
OR hurdle 1.63 [1.51;1.76] [1.55;1.71]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.34     0.37       1082    1
## sd(hu_Intercept)     0.82      0.02     0.79     0.85       1225    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.32      0.08     1.16     1.47        193
## paternalage                  -0.05      0.02    -0.09    -0.02       1090
## birth_cohort1750M1755        -0.17      0.12    -0.40     0.06        606
## birth_cohort1755M1760         0.09      0.10    -0.10     0.28        306
## birth_cohort1760M1765         0.14      0.09    -0.01     0.32        231
## birth_cohort1765M1770         0.09      0.09    -0.07     0.27        228
## birth_cohort1770M1775         0.05      0.09    -0.11     0.22        237
## birth_cohort1775M1780         0.04      0.08    -0.12     0.21        223
## birth_cohort1780M1785         0.15      0.08    -0.01     0.32        213
## birth_cohort1785M1790         0.12      0.08    -0.03     0.28        196
## birth_cohort1790M1795         0.02      0.08    -0.13     0.18        181
## birth_cohort1795M1800         0.02      0.08    -0.12     0.17        178
## birth_cohort1800M1805        -0.03      0.08    -0.17     0.12        177
## birth_cohort1805M1810        -0.02      0.08    -0.15     0.14        172
## birth_cohort1810M1815         0.01      0.08    -0.13     0.16        172
## birth_cohort1815M1820         0.06      0.07    -0.07     0.21        167
## birth_cohort1820M1825         0.08      0.07    -0.05     0.23        166
## birth_cohort1825M1830         0.04      0.07    -0.09     0.19        166
## birth_cohort1830M1835         0.06      0.07    -0.07     0.21        168
## birth_cohort1835M1840         0.06      0.07    -0.07     0.21        168
## birth_cohort1840M1845         0.04      0.07    -0.09     0.19        167
## birth_cohort1845M1850         0.05      0.07    -0.08     0.20        168
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.04      0.03    -0.02     0.09       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       3000
## paternalage.mean              0.06      0.02     0.02     0.10       1234
## paternal_loss01               0.06      0.04    -0.01     0.13       3000
## paternal_loss15               0.03      0.03    -0.03     0.07       1973
## paternal_loss510             -0.02      0.02    -0.06     0.02       1785
## paternal_loss1015            -0.02      0.02    -0.06     0.02       1563
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       1654
## paternal_loss2025            -0.03      0.02    -0.06     0.00       1571
## paternal_loss2530            -0.02      0.02    -0.05     0.01       1523
## paternal_loss3035            -0.02      0.01    -0.04     0.01       1655
## paternal_loss3540             0.02      0.01     0.00     0.05       2291
## paternal_loss4045             0.03      0.01     0.00     0.05       3000
## maternal_loss01               0.07      0.05    -0.03     0.16       3000
## maternal_loss15               0.00      0.03    -0.05     0.06       3000
## maternal_loss510             -0.02      0.02    -0.06     0.03       2512
## maternal_loss1015            -0.03      0.02    -0.08     0.01       2214
## maternal_loss1520            -0.03      0.02    -0.07     0.00       2503
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       2270
## maternal_loss2530            -0.03      0.02    -0.06     0.00       2142
## maternal_loss3035            -0.02      0.01    -0.05     0.01       2370
## maternal_loss3540             0.00      0.01    -0.02     0.03       3000
## maternal_loss4045            -0.02      0.01    -0.04     0.00       3000
## older_siblings1               0.02      0.01     0.00     0.04       1968
## older_siblings2               0.03      0.01     0.00     0.06       1397
## older_siblings3               0.04      0.02     0.00     0.07        877
## older_siblings4               0.01      0.02    -0.03     0.06       1140
## older_siblings5P              0.03      0.03    -0.02     0.08       1125
## nr.siblings                   0.02      0.00     0.02     0.03       1056
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                 -0.07      0.19    -0.44     0.31        183
## hu_paternalage                0.05      0.05    -0.06     0.15        900
## hu_birth_cohort1750M1755      0.38      0.28    -0.17     0.94        492
## hu_birth_cohort1755M1760      0.09      0.24    -0.39     0.56        288
## hu_birth_cohort1760M1765     -0.03      0.22    -0.46     0.39        247
## hu_birth_cohort1765M1770     -0.32      0.22    -0.75     0.12        232
## hu_birth_cohort1770M1775     -0.09      0.23    -0.53     0.35        235
## hu_birth_cohort1775M1780      0.07      0.22    -0.36     0.48        219
## hu_birth_cohort1780M1785      0.01      0.22    -0.44     0.41        225
## hu_birth_cohort1785M1790      0.15      0.21    -0.27     0.54        195
## hu_birth_cohort1790M1795      0.33      0.19    -0.07     0.70        187
## hu_birth_cohort1795M1800      0.13      0.19    -0.25     0.49        177
## hu_birth_cohort1800M1805      0.05      0.19    -0.32     0.40        174
## hu_birth_cohort1805M1810      0.00      0.19    -0.37     0.35        183
## hu_birth_cohort1810M1815      0.08      0.19    -0.30     0.42        169
## hu_birth_cohort1815M1820     -0.09      0.18    -0.46     0.25        166
## hu_birth_cohort1820M1825     -0.19      0.18    -0.56     0.14        167
## hu_birth_cohort1825M1830     -0.19      0.18    -0.56     0.14        165
## hu_birth_cohort1830M1835     -0.17      0.18    -0.54     0.17        169
## hu_birth_cohort1835M1840     -0.19      0.18    -0.57     0.14        167
## hu_birth_cohort1840M1845     -0.18      0.18    -0.56     0.15        168
## hu_birth_cohort1845M1850     -0.15      0.18    -0.51     0.19        167
## hu_male1                      0.04      0.02     0.01     0.08       3000
## hu_maternalage.factor1020     0.06      0.09    -0.12     0.23       3000
## hu_maternalage.factor3559     0.07      0.03     0.02     0.13       3000
## hu_paternalage.mean          -0.07      0.06    -0.18     0.04        878
## hu_paternal_loss01            0.87      0.09     0.68     1.05       3000
## hu_paternal_loss15            0.67      0.06     0.55     0.80       3000
## hu_paternal_loss510           0.69      0.05     0.58     0.79       3000
## hu_paternal_loss1015          0.52      0.05     0.43     0.62       3000
## hu_paternal_loss1520          0.42      0.05     0.34     0.51       1864
## hu_paternal_loss2025          0.32      0.04     0.24     0.40       1812
## hu_paternal_loss2530          0.23      0.04     0.15     0.31       1673
## hu_paternal_loss3035          0.16      0.04     0.08     0.23       1755
## hu_paternal_loss3540          0.12      0.04     0.04     0.19       1992
## hu_paternal_loss4045          0.04      0.04    -0.03     0.12       3000
## hu_maternal_loss01            1.86      0.12     1.63     2.09       3000
## hu_maternal_loss15            1.02      0.07     0.88     1.16       3000
## hu_maternal_loss510           0.86      0.06     0.75     0.97       3000
## hu_maternal_loss1015          0.80      0.05     0.70     0.91       3000
## hu_maternal_loss1520          0.67      0.05     0.57     0.77       3000
## hu_maternal_loss2025          0.46      0.05     0.37     0.55       3000
## hu_maternal_loss2530          0.31      0.04     0.23     0.39       3000
## hu_maternal_loss3035          0.24      0.04     0.17     0.32       3000
## hu_maternal_loss3540          0.14      0.04     0.07     0.21       3000
## hu_maternal_loss4045          0.07      0.04     0.00     0.14       3000
## hu_older_siblings1           -0.04      0.03    -0.10     0.02       3000
## hu_older_siblings2           -0.04      0.04    -0.11     0.04       1059
## hu_older_siblings3           -0.05      0.05    -0.15     0.05        849
## hu_older_siblings4           -0.08      0.06    -0.21     0.04        890
## hu_older_siblings5P          -0.15      0.08    -0.30     0.01        896
## hu_nr.siblings                0.05      0.01     0.03     0.06       1079
## hu_last_born1                 0.01      0.03    -0.05     0.06       3000
##                           Rhat
## Intercept                 1.04
## paternalage               1.01
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     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.04
## birth_cohort1790M1795     1.04
## birth_cohort1795M1800     1.04
## birth_cohort1800M1805     1.04
## birth_cohort1805M1810     1.05
## birth_cohort1810M1815     1.05
## birth_cohort1815M1820     1.05
## birth_cohort1820M1825     1.05
## birth_cohort1825M1830     1.05
## birth_cohort1830M1835     1.04
## birth_cohort1835M1840     1.04
## birth_cohort1840M1845     1.04
## birth_cohort1845M1850     1.04
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.01
## older_siblings5P          1.01
## nr.siblings               1.01
## last_born1                1.00
## hu_Intercept              1.03
## hu_paternalage            1.01
## hu_birth_cohort1750M1755  1.01
## hu_birth_cohort1755M1760  1.02
## hu_birth_cohort1760M1765  1.02
## hu_birth_cohort1765M1770  1.02
## hu_birth_cohort1770M1775  1.02
## hu_birth_cohort1775M1780  1.03
## hu_birth_cohort1780M1785  1.02
## 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_birth_cohort1835M1840  1.03
## hu_birth_cohort1840M1845  1.03
## hu_birth_cohort1845M1850  1.03
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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.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 3.762 3.202 4.357
paternalage 0.9476 0.9128 0.9848
birth_cohort1750M1755 0.8413 0.6684 1.058
birth_cohort1755M1760 1.09 0.9029 1.328
birth_cohort1760M1765 1.155 0.9867 1.38
birth_cohort1765M1770 1.098 0.9364 1.312
birth_cohort1770M1775 1.056 0.8998 1.251
birth_cohort1775M1780 1.04 0.8843 1.232
birth_cohort1780M1785 1.158 0.9897 1.374
birth_cohort1785M1790 1.126 0.967 1.329
birth_cohort1790M1795 1.019 0.8798 1.195
birth_cohort1795M1800 1.016 0.8844 1.188
birth_cohort1800M1805 0.969 0.8425 1.131
birth_cohort1805M1810 0.9839 0.8569 1.147
birth_cohort1810M1815 1.009 0.8815 1.178
birth_cohort1815M1820 1.062 0.9314 1.239
birth_cohort1820M1825 1.081 0.9491 1.256
birth_cohort1825M1830 1.037 0.9104 1.206
birth_cohort1830M1835 1.064 0.9317 1.233
birth_cohort1835M1840 1.064 0.9342 1.238
birth_cohort1840M1845 1.04 0.9116 1.21
birth_cohort1845M1850 1.049 0.9191 1.22
male1 1.041 1.027 1.055
maternalage.factor1020 1.038 0.981 1.099
maternalage.factor3559 1.066 1.042 1.089
paternalage.mean 1.062 1.021 1.104
paternal_loss01 1.062 0.9876 1.139
paternal_loss15 1.026 0.975 1.077
paternal_loss510 0.9808 0.9397 1.024
paternal_loss1015 0.9804 0.9426 1.017
paternal_loss1520 0.9295 0.8978 0.9626
paternal_loss2025 0.9723 0.941 1.004
paternal_loss2530 0.9792 0.9496 1.008
paternal_loss3035 0.9848 0.9571 1.012
paternal_loss3540 1.021 0.9951 1.049
paternal_loss4045 1.028 1.002 1.056
maternal_loss01 1.069 0.9676 1.179
maternal_loss15 1.004 0.9488 1.063
maternal_loss510 0.9818 0.9394 1.028
maternal_loss1015 0.9658 0.9256 1.009
maternal_loss1520 0.9662 0.9293 1.004
maternal_loss2025 0.9331 0.9022 0.965
maternal_loss2530 0.9735 0.9451 1.003
maternal_loss3035 0.98 0.9539 1.007
maternal_loss3540 1.002 0.9771 1.027
maternal_loss4045 0.9809 0.9581 1.004
older_siblings1 1.017 0.9964 1.038
older_siblings2 1.03 1.002 1.059
older_siblings3 1.038 1.003 1.073
older_siblings4 1.014 0.9735 1.057
older_siblings5P 1.029 0.9756 1.086
nr.siblings 1.023 1.018 1.028
last_born1 0.9789 0.9611 0.9981
hu_Intercept 0.9289 0.6428 1.358
hu_paternalage 1.049 0.9423 1.163
hu_birth_cohort1750M1755 1.456 0.8444 2.55
hu_birth_cohort1755M1760 1.098 0.6772 1.749
hu_birth_cohort1760M1765 0.9676 0.6314 1.475
hu_birth_cohort1765M1770 0.7261 0.4744 1.125
hu_birth_cohort1770M1775 0.9129 0.5868 1.415
hu_birth_cohort1775M1780 1.071 0.6992 1.611
hu_birth_cohort1780M1785 1.006 0.6458 1.509
hu_birth_cohort1785M1790 1.157 0.7641 1.71
hu_birth_cohort1790M1795 1.39 0.9321 2.007
hu_birth_cohort1795M1800 1.141 0.7809 1.626
hu_birth_cohort1800M1805 1.051 0.7254 1.493
hu_birth_cohort1805M1810 1.004 0.6921 1.417
hu_birth_cohort1810M1815 1.081 0.7401 1.526
hu_birth_cohort1815M1820 0.9174 0.6285 1.282
hu_birth_cohort1820M1825 0.8265 0.5685 1.155
hu_birth_cohort1825M1830 0.8262 0.57 1.15
hu_birth_cohort1830M1835 0.8411 0.5843 1.181
hu_birth_cohort1835M1840 0.823 0.5678 1.148
hu_birth_cohort1840M1845 0.8332 0.5731 1.163
hu_birth_cohort1845M1850 0.8646 0.5987 1.209
hu_male1 1.045 1.008 1.086
hu_maternalage.factor1020 1.059 0.891 1.264
hu_maternalage.factor3559 1.074 1.016 1.137
hu_paternalage.mean 0.9278 0.8334 1.037
hu_paternal_loss01 2.381 1.983 2.844
hu_paternal_loss15 1.959 1.734 2.219
hu_paternal_loss510 1.996 1.795 2.214
hu_paternal_loss1015 1.687 1.53 1.853
hu_paternal_loss1520 1.529 1.399 1.668
hu_paternal_loss2025 1.38 1.268 1.496
hu_paternal_loss2530 1.255 1.16 1.36
hu_paternal_loss3035 1.172 1.088 1.264
hu_paternal_loss3540 1.126 1.045 1.214
hu_paternal_loss4045 1.041 0.9656 1.125
hu_maternal_loss01 6.404 5.084 8.086
hu_maternal_loss15 2.785 2.417 3.199
hu_maternal_loss510 2.37 2.116 2.648
hu_maternal_loss1015 2.236 2.011 2.489
hu_maternal_loss1520 1.955 1.773 2.16
hu_maternal_loss2025 1.578 1.443 1.726
hu_maternal_loss2530 1.367 1.263 1.481
hu_maternal_loss3035 1.275 1.185 1.37
hu_maternal_loss3540 1.154 1.077 1.236
hu_maternal_loss4045 1.077 1.003 1.155
hu_older_siblings1 0.9592 0.9027 1.02
hu_older_siblings2 0.9652 0.8959 1.044
hu_older_siblings3 0.949 0.8581 1.048
hu_older_siblings4 0.9185 0.8141 1.039
hu_older_siblings5P 0.861 0.7373 1.012
hu_nr.siblings 1.049 1.034 1.064
hu_last_born1 1.008 0.9557 1.062

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.28 [1.78;2.8] [1.94;2.63]
estimate father 35y 2.11 [1.66;2.62] [1.79;2.45]
percentage change -7.27 [-13.28;-1.01] [-11.19;-3.31]
OR/IRR 0.95 [0.91;0.98] [0.92;0.97]
OR hurdle 1.05 [0.94;1.16] [0.98;1.12]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.36      0.01     0.35     0.37       1120    1
## sd(hu_Intercept)     0.82      0.02     0.79     0.85       1363    1
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.32      0.08     1.16     1.49        126
## paternalage                  -0.05      0.02    -0.09    -0.02        796
## birth_cohort1750M1755        -0.17      0.12    -0.42     0.06        345
## birth_cohort1755M1760         0.09      0.10    -0.10     0.27        202
## birth_cohort1760M1765         0.14      0.09    -0.03     0.31        150
## birth_cohort1765M1770         0.09      0.09    -0.08     0.26        144
## birth_cohort1770M1775         0.06      0.09    -0.12     0.23        147
## birth_cohort1775M1780         0.04      0.09    -0.14     0.21        126
## birth_cohort1780M1785         0.15      0.09    -0.02     0.31        133
## birth_cohort1785M1790         0.12      0.08    -0.05     0.28        123
## birth_cohort1790M1795         0.02      0.08    -0.15     0.17        111
## birth_cohort1795M1800         0.02      0.08    -0.15     0.17        111
## birth_cohort1800M1805        -0.03      0.08    -0.19     0.13        106
## birth_cohort1805M1810        -0.01      0.08    -0.17     0.13        110
## birth_cohort1810M1815         0.01      0.08    -0.15     0.16        109
## birth_cohort1815M1820         0.06      0.08    -0.09     0.21        106
## birth_cohort1820M1825         0.08      0.08    -0.07     0.22        105
## birth_cohort1825M1830         0.04      0.08    -0.12     0.18        105
## birth_cohort1830M1835         0.06      0.08    -0.09     0.21        104
## birth_cohort1835M1840         0.06      0.08    -0.09     0.21        107
## birth_cohort1840M1845         0.04      0.08    -0.11     0.19        106
## birth_cohort1845M1850         0.05      0.08    -0.10     0.19        105
## male1                         0.04      0.01     0.03     0.05       3000
## maternalage.factor1020        0.04      0.03    -0.02     0.10       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       3000
## paternalage.mean              0.06      0.02     0.02     0.10        896
## paternal_loss01               0.06      0.04    -0.02     0.13       3000
## paternal_loss15               0.02      0.02    -0.02     0.07       1615
## paternal_loss510             -0.02      0.02    -0.06     0.02       1412
## paternal_loss1015            -0.02      0.02    -0.06     0.02       1379
## paternal_loss1520            -0.07      0.02    -0.11    -0.04       1357
## paternal_loss2025            -0.03      0.02    -0.06     0.00       1314
## paternal_loss2530            -0.02      0.01    -0.05     0.01       1558
## paternal_loss3035            -0.02      0.01    -0.04     0.01       1608
## paternal_loss3540             0.02      0.01     0.00     0.05       1778
## paternal_loss4045             0.03      0.01     0.00     0.05       2188
## maternal_loss01               0.07      0.05    -0.04     0.17       3000
## maternal_loss15               0.00      0.03    -0.05     0.06       2243
## maternal_loss510             -0.02      0.02    -0.07     0.03       1761
## maternal_loss1015            -0.04      0.02    -0.08     0.01       2083
## maternal_loss1520            -0.03      0.02    -0.07     0.00       2139
## maternal_loss2025            -0.07      0.02    -0.10    -0.04       1683
## maternal_loss2530            -0.03      0.02    -0.06     0.01       1698
## maternal_loss3035            -0.02      0.01    -0.05     0.01       2016
## maternal_loss3540             0.00      0.01    -0.02     0.03       2160
## maternal_loss4045            -0.02      0.01    -0.04     0.00       3000
## older_siblings1               0.02      0.01     0.00     0.04       1388
## older_siblings2               0.03      0.01     0.00     0.06        802
## older_siblings3               0.04      0.02     0.00     0.07        881
## older_siblings4               0.01      0.02    -0.03     0.06        856
## older_siblings5P              0.03      0.03    -0.03     0.08        753
## nr.siblings                   0.02      0.00     0.02     0.03        937
## last_born1                   -0.02      0.01    -0.04     0.00       3000
## hu_Intercept                 -0.08      0.20    -0.44     0.32        138
## hu_paternalage                0.05      0.06    -0.06     0.16        811
## hu_birth_cohort1750M1755      0.38      0.29    -0.20     0.96        351
## hu_birth_cohort1755M1760      0.10      0.24    -0.38     0.57        210
## hu_birth_cohort1760M1765     -0.03      0.22    -0.49     0.40        171
## hu_birth_cohort1765M1770     -0.32      0.22    -0.77     0.11        171
## hu_birth_cohort1770M1775     -0.08      0.23    -0.55     0.36        180
## hu_birth_cohort1775M1780      0.08      0.21    -0.37     0.47        151
## hu_birth_cohort1780M1785      0.01      0.22    -0.42     0.43        159
## hu_birth_cohort1785M1790      0.16      0.21    -0.27     0.54        144
## hu_birth_cohort1790M1795      0.34      0.20    -0.08     0.70        131
## hu_birth_cohort1795M1800      0.14      0.20    -0.27     0.51        132
## hu_birth_cohort1800M1805      0.06      0.19    -0.33     0.41        125
## hu_birth_cohort1805M1810      0.01      0.19    -0.39     0.36        123
## hu_birth_cohort1810M1815      0.09      0.19    -0.31     0.43        123
## hu_birth_cohort1815M1820     -0.08      0.19    -0.47     0.26        120
## hu_birth_cohort1820M1825     -0.18      0.18    -0.56     0.16        121
## hu_birth_cohort1825M1830     -0.18      0.18    -0.57     0.16        122
## hu_birth_cohort1830M1835     -0.17      0.19    -0.56     0.17        121
## hu_birth_cohort1835M1840     -0.19      0.18    -0.57     0.16        121
## hu_birth_cohort1840M1845     -0.18      0.18    -0.56     0.17        121
## hu_birth_cohort1845M1850     -0.14      0.18    -0.53     0.20        119
## hu_male1                      0.04      0.02     0.01     0.08       3000
## hu_maternalage.factor1020     0.06      0.09    -0.11     0.23       3000
## hu_maternalage.factor3559     0.07      0.03     0.02     0.13       3000
## hu_paternalage.mean          -0.07      0.06    -0.18     0.03        823
## hu_paternal_loss01            0.87      0.09     0.68     1.05       3000
## hu_paternal_loss15            0.67      0.06     0.55     0.79       3000
## hu_paternal_loss510           0.69      0.05     0.59     0.79       1271
## hu_paternal_loss1015          0.52      0.05     0.43     0.62       1029
## hu_paternal_loss1520          0.42      0.05     0.34     0.51       1186
## hu_paternal_loss2025          0.32      0.04     0.24     0.40        991
## hu_paternal_loss2530          0.22      0.04     0.14     0.31       1235
## hu_paternal_loss3035          0.16      0.04     0.09     0.24       1368
## hu_paternal_loss3540          0.12      0.04     0.05     0.19       1437
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       3000
## hu_maternal_loss01            1.86      0.12     1.63     2.09       3000
## hu_maternal_loss15            1.02      0.07     0.89     1.16       3000
## hu_maternal_loss510           0.87      0.06     0.75     0.98       3000
## hu_maternal_loss1015          0.81      0.05     0.71     0.91       3000
## hu_maternal_loss1520          0.67      0.05     0.57     0.77       3000
## hu_maternal_loss2025          0.46      0.04     0.37     0.54       3000
## hu_maternal_loss2530          0.31      0.04     0.23     0.40       3000
## hu_maternal_loss3035          0.24      0.04     0.17     0.32       3000
## hu_maternal_loss3540          0.14      0.03     0.08     0.21       3000
## hu_maternal_loss4045          0.08      0.04     0.01     0.15       3000
## hu_older_siblings1           -0.04      0.03    -0.10     0.02       1499
## hu_older_siblings2           -0.03      0.04    -0.11     0.05       1015
## hu_older_siblings3           -0.05      0.05    -0.15     0.05        840
## hu_older_siblings4           -0.08      0.06    -0.21     0.04        814
## hu_older_siblings5P          -0.15      0.08    -0.31     0.01        788
## hu_nr.siblings                0.05      0.01     0.03     0.06        974
## hu_last_born1                 0.01      0.03    -0.05     0.06       3000
##                           Rhat
## Intercept                 1.04
## paternalage               1.01
## birth_cohort1750M1755     1.01
## birth_cohort1755M1760     1.02
## birth_cohort1760M1765     1.03
## birth_cohort1765M1770     1.04
## birth_cohort1770M1775     1.03
## birth_cohort1775M1780     1.04
## birth_cohort1780M1785     1.04
## birth_cohort1785M1790     1.04
## birth_cohort1790M1795     1.04
## birth_cohort1795M1800     1.05
## birth_cohort1800M1805     1.05
## birth_cohort1805M1810     1.05
## birth_cohort1810M1815     1.05
## birth_cohort1815M1820     1.05
## birth_cohort1820M1825     1.05
## birth_cohort1825M1830     1.05
## birth_cohort1830M1835     1.05
## birth_cohort1835M1840     1.05
## birth_cohort1840M1845     1.05
## birth_cohort1845M1850     1.05
## male1                     1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    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.03
## hu_paternalage            1.01
## hu_birth_cohort1750M1755  1.02
## hu_birth_cohort1755M1760  1.03
## hu_birth_cohort1760M1765  1.03
## hu_birth_cohort1765M1770  1.03
## hu_birth_cohort1770M1775  1.03
## 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.05
## hu_birth_cohort1810M1815  1.05
## hu_birth_cohort1815M1820  1.05
## hu_birth_cohort1820M1825  1.05
## hu_birth_cohort1825M1830  1.05
## hu_birth_cohort1830M1835  1.05
## hu_birth_cohort1835M1840  1.05
## hu_birth_cohort1840M1845  1.04
## hu_birth_cohort1845M1850  1.05
## hu_male1                  1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 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.00
## 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 3.75 3.2 4.417
paternalage 0.9469 0.9127 0.9838
birth_cohort1750M1755 0.8404 0.659 1.059
birth_cohort1755M1760 1.093 0.9057 1.31
birth_cohort1760M1765 1.155 0.9689 1.366
birth_cohort1765M1770 1.097 0.9191 1.3
birth_cohort1770M1775 1.058 0.8838 1.255
birth_cohort1775M1780 1.043 0.873 1.234
birth_cohort1780M1785 1.16 0.9769 1.366
birth_cohort1785M1790 1.128 0.9538 1.323
birth_cohort1790M1795 1.022 0.8642 1.19
birth_cohort1795M1800 1.019 0.8625 1.184
birth_cohort1800M1805 0.9711 0.8233 1.133
birth_cohort1805M1810 0.9858 0.8412 1.14
birth_cohort1810M1815 1.01 0.8622 1.17
birth_cohort1815M1820 1.065 0.9126 1.229
birth_cohort1820M1825 1.083 0.9339 1.25
birth_cohort1825M1830 1.039 0.8907 1.196
birth_cohort1830M1835 1.066 0.9155 1.233
birth_cohort1835M1840 1.066 0.9151 1.231
birth_cohort1840M1845 1.043 0.8923 1.205
birth_cohort1845M1850 1.051 0.9035 1.212
male1 1.041 1.027 1.054
maternalage.factor1020 1.038 0.9794 1.102
maternalage.factor3559 1.066 1.042 1.088
paternalage.mean 1.063 1.023 1.105
paternal_loss01 1.059 0.9837 1.139
paternal_loss15 1.025 0.9754 1.075
paternal_loss510 0.98 0.9394 1.021
paternal_loss1015 0.9795 0.9441 1.016
paternal_loss1520 0.9286 0.8976 0.9595
paternal_loss2025 0.9718 0.9424 1.003
paternal_loss2530 0.979 0.951 1.007
paternal_loss3035 0.9846 0.9574 1.012
paternal_loss3540 1.021 0.9962 1.048
paternal_loss4045 1.028 1.003 1.055
maternal_loss01 1.069 0.963 1.181
maternal_loss15 1.003 0.949 1.061
maternal_loss510 0.9807 0.9369 1.026
maternal_loss1015 0.9652 0.9233 1.009
maternal_loss1520 0.9659 0.9295 1.004
maternal_loss2025 0.9327 0.9013 0.9652
maternal_loss2530 0.9739 0.9445 1.005
maternal_loss3035 0.9797 0.9538 1.006
maternal_loss3540 1.002 0.9789 1.027
maternal_loss4045 0.9807 0.9576 1.004
older_siblings1 1.017 0.9967 1.038
older_siblings2 1.03 1.002 1.06
older_siblings3 1.038 1.002 1.075
older_siblings4 1.015 0.9725 1.058
older_siblings5P 1.031 0.9743 1.089
nr.siblings 1.023 1.018 1.029
last_born1 0.9788 0.9611 0.9974
hu_Intercept 0.922 0.6413 1.384
hu_paternalage 1.047 0.9432 1.168
hu_birth_cohort1750M1755 1.458 0.8205 2.618
hu_birth_cohort1755M1760 1.1 0.6821 1.77
hu_birth_cohort1760M1765 0.971 0.6115 1.497
hu_birth_cohort1765M1770 0.7269 0.461 1.118
hu_birth_cohort1770M1775 0.9232 0.5771 1.434
hu_birth_cohort1775M1780 1.078 0.6914 1.592
hu_birth_cohort1780M1785 1.014 0.6544 1.534
hu_birth_cohort1785M1790 1.168 0.7645 1.718
hu_birth_cohort1790M1795 1.399 0.9257 2.01
hu_birth_cohort1795M1800 1.147 0.763 1.66
hu_birth_cohort1800M1805 1.057 0.7157 1.511
hu_birth_cohort1805M1810 1.011 0.6793 1.44
hu_birth_cohort1810M1815 1.09 0.7331 1.542
hu_birth_cohort1815M1820 0.9221 0.6244 1.303
hu_birth_cohort1820M1825 0.8321 0.5684 1.174
hu_birth_cohort1825M1830 0.833 0.5653 1.17
hu_birth_cohort1830M1835 0.8469 0.5719 1.19
hu_birth_cohort1835M1840 0.8282 0.5644 1.175
hu_birth_cohort1840M1845 0.8394 0.5701 1.185
hu_birth_cohort1845M1850 0.8706 0.5906 1.223
hu_male1 1.045 1.007 1.086
hu_maternalage.factor1020 1.06 0.8918 1.256
hu_maternalage.factor3559 1.074 1.016 1.138
hu_paternalage.mean 0.93 0.8328 1.035
hu_paternal_loss01 2.376 1.978 2.857
hu_paternal_loss15 1.956 1.736 2.197
hu_paternal_loss510 1.992 1.799 2.2
hu_paternal_loss1015 1.684 1.534 1.851
hu_paternal_loss1520 1.527 1.399 1.668
hu_paternal_loss2025 1.377 1.269 1.498
hu_paternal_loss2530 1.252 1.154 1.36
hu_paternal_loss3035 1.171 1.089 1.268
hu_paternal_loss3540 1.126 1.048 1.211
hu_paternal_loss4045 1.04 0.9607 1.127
hu_maternal_loss01 6.4 5.115 8.08
hu_maternal_loss15 2.787 2.435 3.191
hu_maternal_loss510 2.375 2.121 2.657
hu_maternal_loss1015 2.239 2.024 2.492
hu_maternal_loss1520 1.957 1.775 2.16
hu_maternal_loss2025 1.58 1.454 1.722
hu_maternal_loss2530 1.369 1.262 1.486
hu_maternal_loss3035 1.278 1.187 1.378
hu_maternal_loss3540 1.154 1.079 1.237
hu_maternal_loss4045 1.078 1.005 1.157
hu_older_siblings1 0.9599 0.9053 1.019
hu_older_siblings2 0.9658 0.8918 1.046
hu_older_siblings3 0.9511 0.8581 1.052
hu_older_siblings4 0.9208 0.8099 1.041
hu_older_siblings5P 0.8633 0.7326 1.011
hu_nr.siblings 1.049 1.034 1.064
hu_last_born1 1.007 0.9547 1.062

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 2.28 [1.78;2.86] [1.95;2.64]
estimate father 35y 2.11 [1.63;2.65] [1.8;2.47]
percentage change -7.25 [-13.17;-1.03] [-11;-3.12]
OR/IRR 0.95 [0.91;0.98] [0.92;0.97]
OR hurdle 1.05 [0.94;1.17] [0.98;1.12]

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/ddb/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: 56663) 
## 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: 14746) 
##                  Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)        0.33      0.01     0.32     0.34       1278 1.00
## sd(hu_Intercept)     0.73      0.02     0.70     0.77       1089 1.01
## 
## Population-Level Effects: 
##                           Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                     1.37      0.07     1.22     1.51        113
## paternalage                  -0.05      0.02    -0.09    -0.02        914
## migrated                     -0.42      0.01    -0.44    -0.40       3000
## maternalage.factor1020        0.03      0.03    -0.03     0.09       3000
## maternalage.factor3559        0.06      0.01     0.04     0.08       3000
## birth_cohort1750M1755        -0.16      0.11    -0.39     0.06        654
## birth_cohort1755M1760         0.09      0.09    -0.09     0.26        189
## birth_cohort1760M1765         0.15      0.08    -0.01     0.30        146
## birth_cohort1765M1770         0.09      0.08    -0.07     0.24        140
## birth_cohort1770M1775         0.06      0.08    -0.10     0.22        158
## birth_cohort1775M1780         0.04      0.08    -0.11     0.20        136
## birth_cohort1780M1785         0.16      0.08     0.01     0.31        151
## birth_cohort1785M1790         0.14      0.07    -0.01     0.28        131
## birth_cohort1790M1795         0.07      0.07    -0.07     0.21        128
## birth_cohort1795M1800         0.08      0.07    -0.06     0.21        119
## birth_cohort1800M1805         0.02      0.07    -0.12     0.16        117
## birth_cohort1805M1810         0.02      0.07    -0.11     0.16        119
## birth_cohort1810M1815         0.04      0.07    -0.09     0.18        123
## birth_cohort1815M1820         0.10      0.07    -0.04     0.23        112
## birth_cohort1820M1825         0.11      0.07    -0.02     0.25        114
## birth_cohort1825M1830         0.08      0.07    -0.06     0.21        110
## birth_cohort1830M1835         0.11      0.07    -0.02     0.24        111
## birth_cohort1835M1840         0.11      0.07    -0.02     0.24        113
## birth_cohort1840M1845         0.09      0.07    -0.04     0.23        115
## birth_cohort1845M1850         0.10      0.07    -0.03     0.23        112
## male1                         0.03      0.01     0.02     0.05       3000
## paternalage.mean              0.06      0.02     0.02     0.10        968
## paternal_loss01               0.09      0.04     0.02     0.16       3000
## paternal_loss15               0.03      0.02    -0.02     0.07       2036
## paternal_loss510             -0.01      0.02    -0.05     0.03       1755
## paternal_loss1015            -0.01      0.02    -0.05     0.02       1470
## paternal_loss1520            -0.06      0.02    -0.09    -0.03       1598
## paternal_loss2025            -0.02      0.02    -0.05     0.01       1362
## paternal_loss2530            -0.02      0.01    -0.04     0.01       1779
## paternal_loss3035            -0.01      0.01    -0.04     0.02       1808
## paternal_loss3540             0.02      0.01    -0.01     0.04       1690
## paternal_loss4045             0.02      0.01     0.00     0.05       3000
## maternal_loss01               0.07      0.05    -0.04     0.17       3000
## maternal_loss15               0.00      0.03    -0.05     0.06       1831
## maternal_loss510             -0.01      0.02    -0.06     0.03       1552
## maternal_loss1015            -0.03      0.02    -0.08     0.01       2118
## maternal_loss1520            -0.03      0.02    -0.07     0.01       1566
## maternal_loss2025            -0.06      0.02    -0.10    -0.03       1486
## maternal_loss2530            -0.02      0.02    -0.05     0.01       1586
## maternal_loss3035            -0.01      0.01    -0.04     0.01       1260
## maternal_loss3540             0.00      0.01    -0.02     0.03       1474
## maternal_loss4045            -0.01      0.01    -0.04     0.01       3000
## older_siblings1               0.01      0.01    -0.01     0.03       1489
## older_siblings2               0.03      0.01     0.00     0.05       1032
## older_siblings3               0.03      0.02     0.00     0.07       1008
## older_siblings4               0.01      0.02    -0.03     0.05        596
## older_siblings5P              0.02      0.03    -0.03     0.08        915
## nr.siblings                   0.02      0.00     0.02     0.03       1055
## last_born1                   -0.01      0.01    -0.03     0.00       3000
## hu_Intercept                 -0.11      0.21    -0.52     0.29        184
## hu_paternalage                0.11      0.06    -0.01     0.21        633
## hu_migrated                   0.81      0.02     0.76     0.85       3000
## hu_maternalage.factor1020     0.07      0.09    -0.10     0.24       3000
## hu_maternalage.factor3559     0.08      0.03     0.02     0.13       3000
## hu_birth_cohort1750M1755      0.33      0.29    -0.23     0.93        411
## hu_birth_cohort1755M1760      0.05      0.25    -0.44     0.55        299
## hu_birth_cohort1760M1765     -0.09      0.23    -0.54     0.38        226
## hu_birth_cohort1765M1770     -0.36      0.23    -0.81     0.10        215
## hu_birth_cohort1770M1775     -0.14      0.24    -0.60     0.32        233
## hu_birth_cohort1775M1780      0.01      0.23    -0.43     0.46        209
## hu_birth_cohort1780M1785     -0.08      0.23    -0.52     0.37        211
## hu_birth_cohort1785M1790      0.03      0.22    -0.40     0.45        187
## hu_birth_cohort1790M1795      0.15      0.21    -0.25     0.56        179
## hu_birth_cohort1795M1800     -0.08      0.20    -0.46     0.33        169
## hu_birth_cohort1800M1805     -0.14      0.20    -0.53     0.26        169
## hu_birth_cohort1805M1810     -0.17      0.20    -0.57     0.23        166
## hu_birth_cohort1810M1815     -0.10      0.20    -0.47     0.31        166
## hu_birth_cohort1815M1820     -0.26      0.20    -0.64     0.14        157
## hu_birth_cohort1820M1825     -0.37      0.20    -0.75     0.02        164
## hu_birth_cohort1825M1830     -0.37      0.20    -0.76     0.02        163
## hu_birth_cohort1830M1835     -0.36      0.20    -0.74     0.03        165
## hu_birth_cohort1835M1840     -0.40      0.20    -0.78    -0.01        165
## hu_birth_cohort1840M1845     -0.40      0.20    -0.78    -0.01        167
## hu_birth_cohort1845M1850     -0.36      0.20    -0.74     0.03        164
## hu_male1                      0.08      0.02     0.04     0.12       3000
## hu_paternalage.mean          -0.13      0.06    -0.24    -0.02        660
## hu_paternal_loss01            0.85      0.09     0.68     1.03       3000
## hu_paternal_loss15            0.63      0.06     0.51     0.75       3000
## hu_paternal_loss510           0.65      0.05     0.55     0.75       1963
## hu_paternal_loss1015          0.48      0.05     0.39     0.57       3000
## hu_paternal_loss1520          0.38      0.04     0.30     0.47       1747
## hu_paternal_loss2025          0.29      0.04     0.21     0.38       1701
## hu_paternal_loss2530          0.21      0.04     0.13     0.29       1699
## hu_paternal_loss3035          0.14      0.04     0.07     0.22       2064
## hu_paternal_loss3540          0.11      0.04     0.03     0.18       1694
## hu_paternal_loss4045          0.04      0.04    -0.04     0.12       3000
## hu_maternal_loss01            1.91      0.12     1.68     2.15       3000
## hu_maternal_loss15            1.00      0.07     0.86     1.13       3000
## hu_maternal_loss510           0.81      0.06     0.70     0.92       2083
## hu_maternal_loss1015          0.75      0.05     0.65     0.86       3000
## hu_maternal_loss1520          0.63      0.05     0.53     0.73       3000
## hu_maternal_loss2025          0.43      0.04     0.33     0.51       3000
## hu_maternal_loss2530          0.29      0.04     0.21     0.37       3000
## hu_maternal_loss3035          0.23      0.04     0.15     0.31       3000
## hu_maternal_loss3540          0.14      0.03     0.07     0.20       3000
## hu_maternal_loss4045          0.07      0.04    -0.01     0.14       3000
## hu_older_siblings1           -0.06      0.03    -0.12     0.00       1387
## hu_older_siblings2           -0.06      0.04    -0.15     0.02        841
## hu_older_siblings3           -0.09      0.05    -0.19     0.01        730
## hu_older_siblings4           -0.13      0.07    -0.26     0.01        724
## hu_older_siblings5P          -0.21      0.08    -0.37    -0.05        639
## hu_nr.siblings                0.06      0.01     0.04     0.07        749
## hu_last_born1                 0.01      0.03    -0.05     0.06       3000
##                           Rhat
## Intercept                 1.05
## paternalage               1.01
## migrated                  1.00
## maternalage.factor1020    1.00
## maternalage.factor3559    1.00
## birth_cohort1750M1755     1.02
## birth_cohort1755M1760     1.03
## birth_cohort1760M1765     1.05
## birth_cohort1765M1770     1.05
## birth_cohort1770M1775     1.04
## birth_cohort1775M1780     1.05
## birth_cohort1780M1785     1.05
## birth_cohort1785M1790     1.05
## birth_cohort1790M1795     1.05
## birth_cohort1795M1800     1.06
## birth_cohort1800M1805     1.06
## birth_cohort1805M1810     1.06
## birth_cohort1810M1815     1.06
## birth_cohort1815M1820     1.06
## birth_cohort1820M1825     1.06
## birth_cohort1825M1830     1.06
## birth_cohort1830M1835     1.06
## birth_cohort1835M1840     1.06
## birth_cohort1840M1845     1.06
## birth_cohort1845M1850     1.06
## 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.03
## hu_paternalage            1.01
## hu_migrated               1.00
## hu_maternalage.factor1020 1.00
## hu_maternalage.factor3559 1.00
## hu_birth_cohort1750M1755  1.02
## hu_birth_cohort1755M1760  1.02
## 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.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_male1                  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.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 3.93 3.401 4.542
paternalage 0.9466 0.9115 0.9851
migrated 0.6559 0.6424 0.6698
maternalage.factor1020 1.027 0.969 1.09
maternalage.factor3559 1.063 1.041 1.085
birth_cohort1750M1755 0.8516 0.6771 1.059
birth_cohort1755M1760 1.089 0.918 1.297
birth_cohort1760M1765 1.156 0.9891 1.348
birth_cohort1765M1770 1.094 0.9361 1.275
birth_cohort1770M1775 1.065 0.907 1.246
birth_cohort1775M1780 1.044 0.8949 1.22
birth_cohort1780M1785 1.176 1.011 1.367
birth_cohort1785M1790 1.146 0.9889 1.327
birth_cohort1790M1795 1.069 0.9296 1.235
birth_cohort1795M1800 1.08 0.9403 1.239
birth_cohort1800M1805 1.021 0.8905 1.169
birth_cohort1805M1810 1.024 0.8938 1.174
birth_cohort1810M1815 1.045 0.9135 1.195
birth_cohort1815M1820 1.101 0.9627 1.26
birth_cohort1820M1825 1.121 0.9842 1.283
birth_cohort1825M1830 1.081 0.9459 1.236
birth_cohort1830M1835 1.112 0.978 1.273
birth_cohort1835M1840 1.115 0.9768 1.276
birth_cohort1840M1845 1.099 0.9624 1.257
birth_cohort1845M1850 1.103 0.9665 1.262
male1 1.034 1.02 1.048
paternalage.mean 1.061 1.02 1.103
paternal_loss01 1.092 1.017 1.175
paternal_loss15 1.029 0.9811 1.077
paternal_loss510 0.9879 0.9496 1.028
paternal_loss1015 0.9858 0.9515 1.02
paternal_loss1520 0.9403 0.9103 0.9717
paternal_loss2025 0.9824 0.9524 1.012
paternal_loss2530 0.984 0.9572 1.012
paternal_loss3035 0.9898 0.9638 1.018
paternal_loss3540 1.019 0.9946 1.044
paternal_loss4045 1.024 0.9984 1.05
maternal_loss01 1.074 0.9655 1.187
maternal_loss15 1.003 0.9487 1.059
maternal_loss510 0.9889 0.9452 1.034
maternal_loss1015 0.9685 0.9269 1.011
maternal_loss1520 0.9695 0.9345 1.007
maternal_loss2025 0.9402 0.9076 0.9741
maternal_loss2530 0.9783 0.9489 1.01
maternal_loss3035 0.987 0.9605 1.013
maternal_loss3540 1.002 0.9781 1.026
maternal_loss4045 0.9866 0.9642 1.009
older_siblings1 1.014 0.9935 1.035
older_siblings2 1.026 0.9982 1.054
older_siblings3 1.036 1 1.072
older_siblings4 1.01 0.9682 1.051
older_siblings5P 1.025 0.9704 1.081
nr.siblings 1.023 1.017 1.028
last_born1 0.9852 0.9669 1.003
hu_Intercept 0.8955 0.5917 1.33
hu_paternalage 1.111 0.9939 1.234
hu_migrated 2.245 2.141 2.344
hu_maternalage.factor1020 1.073 0.9087 1.275
hu_maternalage.factor3559 1.078 1.019 1.143
hu_birth_cohort1750M1755 1.398 0.7937 2.535
hu_birth_cohort1755M1760 1.053 0.643 1.737
hu_birth_cohort1760M1765 0.9184 0.5825 1.463
hu_birth_cohort1765M1770 0.695 0.4429 1.105
hu_birth_cohort1770M1775 0.866 0.5472 1.383
hu_birth_cohort1775M1780 1.013 0.6485 1.581
hu_birth_cohort1780M1785 0.9231 0.5959 1.452
hu_birth_cohort1785M1790 1.03 0.6719 1.576
hu_birth_cohort1790M1795 1.166 0.78 1.749
hu_birth_cohort1795M1800 0.9277 0.6285 1.388
hu_birth_cohort1800M1805 0.8685 0.587 1.298
hu_birth_cohort1805M1810 0.84 0.566 1.263
hu_birth_cohort1810M1815 0.9092 0.6224 1.359
hu_birth_cohort1815M1820 0.774 0.529 1.146
hu_birth_cohort1820M1825 0.6914 0.4743 1.016
hu_birth_cohort1825M1830 0.69 0.4696 1.019
hu_birth_cohort1830M1835 0.6965 0.4766 1.028
hu_birth_cohort1835M1840 0.6732 0.4592 0.9928
hu_birth_cohort1840M1845 0.6725 0.46 0.9881
hu_birth_cohort1845M1850 0.7011 0.4788 1.03
hu_male1 1.084 1.044 1.127
hu_paternalage.mean 0.8777 0.7875 0.9841
hu_paternal_loss01 2.347 1.973 2.797
hu_paternal_loss15 1.881 1.663 2.122
hu_paternal_loss510 1.914 1.735 2.112
hu_paternal_loss1015 1.622 1.482 1.773
hu_paternal_loss1520 1.468 1.353 1.602
hu_paternal_loss2025 1.338 1.237 1.456
hu_paternal_loss2530 1.234 1.141 1.332
hu_paternal_loss3035 1.156 1.069 1.25
hu_paternal_loss3540 1.114 1.036 1.197
hu_paternal_loss4045 1.037 0.9592 1.124
hu_maternal_loss01 6.768 5.368 8.588
hu_maternal_loss15 2.714 2.37 3.097
hu_maternal_loss510 2.242 2.013 2.502
hu_maternal_loss1015 2.123 1.906 2.358
hu_maternal_loss1520 1.879 1.706 2.073
hu_maternal_loss2025 1.53 1.397 1.665
hu_maternal_loss2530 1.338 1.235 1.448
hu_maternal_loss3035 1.253 1.161 1.359
hu_maternal_loss3540 1.145 1.073 1.226
hu_maternal_loss4045 1.069 0.9944 1.146
hu_older_siblings1 0.9445 0.889 1.004
hu_older_siblings2 0.9375 0.8645 1.018
hu_older_siblings3 0.9153 0.8266 1.013
hu_older_siblings4 0.8806 0.7727 1.006
hu_older_siblings5P 0.8071 0.6888 0.9503
hu_nr.siblings 1.059 1.044 1.074
hu_last_born1 1.008 0.9552 1.061

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 1.92 [1.51;2.44] [1.64;2.27]
estimate father 35y 1.72 [1.33;2.22] [1.46;2.04]
percentage change -10.44 [-16.68;-3.48] [-14.66;-6.21]
OR/IRR 0.95 [0.91;0.99] [0.92;0.97]
OR hurdle 1.11 [0.99;1.23] [1.03;1.19]

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/ddb/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.