Demographic data base (Sweden 1760-1880), selective episodes

Loading details

source("0__helpers.R")
opts_chunk$set(warning=TRUE, cache = FALSE,tidy=FALSE,dev=c('png'),fig.width=20,fig.height=12.5)

make_path = function(file) {
    get_coefficient_path(file, "ddb")
}
# options for each chunk calling knit_child
opts_chunk$set(warning=FALSE, message = FALSE, echo = 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 have the following in common:

Estimation

We fit all models using brms v. 1.2.0, a Bayesian regression analysis statistical package. brms uses Stan, a probabilistic programming langugage to fit models using Hamiltonian Monte Carlo.

Covariates

As in our main models we adjust for average paternal age in the family, birth cohort (birth years in five equally large bins), for male sex, for age at paternal and maternal loss (0-1, 2-5, 6-10, …, 41-45, 45+, unknown), for maternal age (bins of 14-20, 20-35 and 35-50), for the number of siblings, for the number of older siblings (0-5, 5+) and for being last born.

Model stratification

We added random intercepts for each family (father-mother dyad). We then controlled for the average paternal age in the family. Hence, the paternal age effects in the plot are split into those between families and those within families or between siblings. We are interested in the effect of paternal age between siblings, as this effect cannot be explained by e.g. genetic propensities of the father to reproduce late.

e1: Survival to first year

Here, we predict the probability that the anchor survives the first year of life. All children born to this father are compared, if their death date is known or their survival can be inferred (from later marriage or children).

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: bernoulli (cauchit) 
## Formula: survive1y ~ 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: 56010) 
## 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)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 14708) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     1.41      0.04     1.33     1.49        989    1
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  5.11      0.62     3.99     6.40        336
## paternalage               -1.23      0.11    -1.44    -1.01       1110
## birth_cohort1750M1755     -0.18      1.21    -2.19     2.55        783
## birth_cohort1755M1760     -1.04      0.76    -2.50     0.47        510
## birth_cohort1760M1765     -1.40      0.68    -2.79    -0.14        400
## birth_cohort1765M1770     -0.27      0.79    -1.78     1.26        503
## birth_cohort1770M1775     -0.40      0.78    -1.91     1.11        493
## birth_cohort1775M1780     -1.94      0.62    -3.27    -0.81        339
## birth_cohort1780M1785     -1.98      0.62    -3.28    -0.87        338
## birth_cohort1785M1790     -1.68      0.62    -2.99    -0.52        338
## birth_cohort1790M1795     -1.83      0.61    -3.15    -0.74        319
## birth_cohort1795M1800     -1.43      0.61    -2.75    -0.35        317
## birth_cohort1800M1805     -1.48      0.60    -2.77    -0.36        319
## birth_cohort1805M1810     -1.67      0.60    -2.98    -0.56        316
## birth_cohort1810M1815     -1.77      0.60    -3.06    -0.66        320
## birth_cohort1815M1820     -1.74      0.59    -2.99    -0.65        317
## birth_cohort1820M1825     -1.31      0.60    -2.58    -0.24        312
## birth_cohort1825M1830     -1.18      0.60    -2.47    -0.09        315
## birth_cohort1830M1835     -1.33      0.60    -2.61    -0.23        314
## birth_cohort1835M1840     -1.25      0.59    -2.54    -0.17        318
## birth_cohort1840M1845     -0.91      0.60    -2.18     0.19        316
## birth_cohort1845M1850     -0.80      0.60    -2.05     0.29        317
## male1                     -0.37      0.05    -0.46    -0.29       3000
## maternalage.factor1020    -0.09      0.20    -0.46     0.30       3000
## maternalage.factor3559    -0.21      0.07    -0.34    -0.08       3000
## paternalage.mean           1.26      0.11     1.04     1.49       1171
## paternal_loss01           -0.99      0.16    -1.31    -0.67       2106
## paternal_loss15           -0.46      0.13    -0.70    -0.21       1576
## paternal_loss510          -0.40      0.11    -0.62    -0.18       1539
## paternal_loss1015         -0.30      0.11    -0.51    -0.09       1469
## paternal_loss1520         -0.20      0.10    -0.40     0.00       1433
## paternal_loss2025         -0.08      0.10    -0.27     0.11       1646
## paternal_loss2530         -0.07      0.10    -0.26     0.12       1521
## paternal_loss3035         -0.14      0.09    -0.31     0.04       1609
## paternal_loss3540          0.00      0.09    -0.18     0.19       1686
## paternal_loss4045          0.09      0.10    -0.10     0.29       3000
## maternal_loss01           -3.45      0.14    -3.74    -3.18       2162
## maternal_loss15           -1.21      0.12    -1.43    -0.98       1565
## maternal_loss510          -0.94      0.11    -1.15    -0.73       1779
## maternal_loss1015         -0.55      0.11    -0.76    -0.34       2147
## maternal_loss1520         -0.44      0.11    -0.65    -0.23       2268
## maternal_loss2025         -0.44      0.10    -0.63    -0.24       2175
## maternal_loss2530         -0.45      0.09    -0.63    -0.27       1952
## maternal_loss3035         -0.31      0.09    -0.48    -0.14       2124
## maternal_loss3540         -0.17      0.08    -0.33     0.00       2218
## maternal_loss4045         -0.08      0.09    -0.26     0.10       3000
## older_siblings1            0.60      0.07     0.46     0.74       3000
## older_siblings2            0.92      0.09     0.74     1.09       1599
## older_siblings3            1.05      0.10     0.85     1.26       1383
## older_siblings4            1.39      0.13     1.15     1.65       1249
## older_siblings5P           1.99      0.17     1.66     2.33       1097
## nr.siblings               -0.25      0.01    -0.28    -0.22       1300
## last_born1                -0.08      0.06    -0.19     0.04       3000
##                        Rhat
## Intercept              1.02
## 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.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
## 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
## 
## 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

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$OR = exp(fixed_eff$Estimate)
fixed_eff$OR_low = exp(fixed_eff$`l-95% CI`)
fixed_eff$OR_high = exp(fixed_eff$`u-95% CI`)
pander::pander(fixed_eff)
  Estimate l-95% CI u-95% CI OR OR_low OR_high
Intercept 5.109 3.99 6.404 165.5 54.03 604.2
paternalage -1.229 -1.442 -1.013 0.2925 0.2365 0.363
birth_cohort1750M1755 -0.1832 -2.193 2.552 0.8326 0.1115 12.83
birth_cohort1755M1760 -1.045 -2.497 0.4682 0.3518 0.08236 1.597
birth_cohort1760M1765 -1.401 -2.795 -0.1434 0.2463 0.06114 0.8664
birth_cohort1765M1770 -0.2666 -1.779 1.255 0.766 0.1688 3.509
birth_cohort1770M1775 -0.4013 -1.91 1.109 0.6694 0.1481 3.031
birth_cohort1775M1780 -1.943 -3.273 -0.8112 0.1433 0.03789 0.4443
birth_cohort1780M1785 -1.982 -3.281 -0.8687 0.1378 0.0376 0.4195
birth_cohort1785M1790 -1.68 -2.99 -0.5227 0.1864 0.05028 0.5929
birth_cohort1790M1795 -1.834 -3.153 -0.7387 0.1598 0.04271 0.4777
birth_cohort1795M1800 -1.427 -2.752 -0.3452 0.24 0.06378 0.708
birth_cohort1800M1805 -1.484 -2.765 -0.3643 0.2266 0.06297 0.6947
birth_cohort1805M1810 -1.667 -2.982 -0.5553 0.1888 0.05069 0.5739
birth_cohort1810M1815 -1.767 -3.057 -0.6611 0.1708 0.04702 0.5163
birth_cohort1815M1820 -1.744 -2.991 -0.6502 0.1749 0.05021 0.5219
birth_cohort1820M1825 -1.314 -2.585 -0.2363 0.2688 0.07543 0.7895
birth_cohort1825M1830 -1.182 -2.469 -0.09196 0.3065 0.08468 0.9121
birth_cohort1830M1835 -1.331 -2.608 -0.2288 0.2642 0.07365 0.7955
birth_cohort1835M1840 -1.251 -2.535 -0.1724 0.2863 0.07922 0.8417
birth_cohort1840M1845 -0.9089 -2.175 0.1893 0.403 0.1136 1.208
birth_cohort1845M1850 -0.7952 -2.047 0.2866 0.4515 0.1292 1.332
male1 -0.3726 -0.4631 -0.2855 0.6889 0.6293 0.7517
maternalage.factor1020 -0.09087 -0.465 0.303 0.9131 0.6281 1.354
maternalage.factor3559 -0.2129 -0.3406 -0.0849 0.8082 0.7114 0.9186
paternalage.mean 1.262 1.038 1.492 3.534 2.823 4.447
paternal_loss01 -0.9912 -1.309 -0.6739 0.3711 0.2701 0.5097
paternal_loss15 -0.4573 -0.7031 -0.2054 0.633 0.495 0.8143
paternal_loss510 -0.3976 -0.6217 -0.1762 0.6719 0.537 0.8384
paternal_loss1015 -0.2995 -0.5092 -0.09283 0.7412 0.601 0.9113
paternal_loss1520 -0.1974 -0.395 -0.003379 0.8209 0.6737 0.9966
paternal_loss2025 -0.07989 -0.2703 0.1123 0.9232 0.7631 1.119
paternal_loss2530 -0.06792 -0.2569 0.1197 0.9343 0.7735 1.127
paternal_loss3035 -0.1355 -0.3123 0.04421 0.8733 0.7318 1.045
paternal_loss3540 -0.0006099 -0.1757 0.1854 0.9994 0.8389 1.204
paternal_loss4045 0.09162 -0.09984 0.293 1.096 0.905 1.34
maternal_loss01 -3.45 -3.735 -3.18 0.03174 0.02387 0.04157
maternal_loss15 -1.206 -1.432 -0.9775 0.2994 0.2389 0.3762
maternal_loss510 -0.9413 -1.152 -0.732 0.3901 0.316 0.481
maternal_loss1015 -0.5526 -0.7576 -0.3389 0.5754 0.4688 0.7126
maternal_loss1520 -0.4443 -0.6523 -0.2297 0.6413 0.5208 0.7947
maternal_loss2025 -0.4363 -0.6266 -0.2437 0.6464 0.5344 0.7838
maternal_loss2530 -0.451 -0.6349 -0.267 0.637 0.53 0.7657
maternal_loss3035 -0.3147 -0.4838 -0.1365 0.73 0.6164 0.8724
maternal_loss3540 -0.1708 -0.3344 -0.002877 0.843 0.7158 0.9971
maternal_loss4045 -0.07781 -0.2573 0.09782 0.9251 0.7731 1.103
older_siblings1 0.6033 0.4622 0.742 1.828 1.588 2.1
older_siblings2 0.9151 0.7376 1.085 2.497 2.091 2.96
older_siblings3 1.052 0.8536 1.259 2.863 2.348 3.522
older_siblings4 1.392 1.147 1.646 4.024 3.148 5.188
older_siblings5P 1.989 1.664 2.333 7.311 5.282 10.31
nr.siblings -0.2529 -0.2814 -0.2246 0.7765 0.7548 0.7988
last_born1 -0.07596 -0.1884 0.03827 0.9269 0.8283 1.039

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 0.94 [0.92;0.95] [0.93;0.95]
estimate father 35y 0.92 [0.89;0.94] [0.9;0.93]
percentage change -1.82 [-3.14;-1.08] [-2.63;-1.28]
OR/IRR 0.29 [0.24;0.36] [0.25;0.34]

Marginal effect plots

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

Coefficient estimates (95% and 80% credibility).

mcmc_intervals(as.matrix(model$fit), regex_pars = "b_[^I]")

mcmc_areas(as.matrix(model$fit), regex_pars = "b")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

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 by average sample size

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

Monte Carlo SE

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

Trace plots

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

Further plots

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

File name

coefs/ddb/e1_survive1y.rds

Cluster script

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

Cluster script

e2: Probability of surviving the first 15 years of life

Here, we predict the probability that the anchor survives the first fifteen of life. All children born to this father who lived at least one year are compared, if their death date is known or their survival can be inferred (from later marriage or children).

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: bernoulli (cauchit) 
## Formula: surviveR ~ 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: 45540) 
## 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: 13947) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     1.26      0.06     1.14     1.38        572    1
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  4.88      0.71     3.73     6.67         89
## paternalage               -0.12      0.16    -0.43     0.20        682
## birth_cohort1750M1755     -0.23      1.02    -2.24     1.82        180
## birth_cohort1755M1760      0.52      1.03    -1.47     2.68        179
## birth_cohort1760M1765      0.04      0.83    -1.77     1.59        125
## birth_cohort1765M1770      0.84      0.98    -1.08     2.83        157
## birth_cohort1770M1775     -0.61      0.74    -2.30     0.65        103
## birth_cohort1775M1780     -0.74      0.74    -2.50     0.48         93
## birth_cohort1780M1785     -0.43      0.74    -2.17     0.85         99
## birth_cohort1785M1790     -0.81      0.71    -2.57     0.32         88
## birth_cohort1790M1795     -1.15      0.68    -2.87    -0.09         82
## birth_cohort1795M1800     -0.61      0.68    -2.39     0.48         80
## birth_cohort1800M1805     -0.60      0.68    -2.34     0.44         80
## birth_cohort1805M1810     -0.82      0.68    -2.54     0.23         80
## birth_cohort1810M1815     -0.51      0.67    -2.23     0.54         79
## birth_cohort1815M1820      0.00      0.67    -1.72     1.05         80
## birth_cohort1820M1825      0.35      0.67    -1.34     1.40         80
## birth_cohort1825M1830     -0.13      0.67    -1.79     0.89         79
## birth_cohort1830M1835     -0.01      0.67    -1.73     1.03         80
## birth_cohort1835M1840      0.16      0.67    -1.58     1.19         80
## birth_cohort1840M1845      0.41      0.67    -1.34     1.46         80
## birth_cohort1845M1850      0.01      0.67    -1.70     1.07         80
## male1                     -0.35      0.07    -0.48    -0.23       3000
## maternalage.factor1020    -0.27      0.34    -0.89     0.45       3000
## maternalage.factor3559    -0.01      0.09    -0.19     0.16       2292
## paternalage.mean           0.20      0.17    -0.13     0.53        739
## paternal_loss01           -1.87      0.21    -2.28    -1.46       1202
## paternal_loss15           -1.34      0.17    -1.66    -1.00        959
## paternal_loss510          -1.39      0.15    -1.70    -1.11        905
## paternal_loss1015         -1.05      0.15    -1.35    -0.75        924
## paternal_loss1520         -0.73      0.15    -1.03    -0.43        933
## paternal_loss2025         -0.68      0.15    -0.98    -0.39        924
## paternal_loss2530         -0.69      0.14    -0.98    -0.40        850
## paternal_loss3035         -0.44      0.15    -0.73    -0.14        908
## paternal_loss3540         -0.22      0.15    -0.53     0.09       1001
## paternal_loss4045         -0.35      0.17    -0.67    -0.02       1110
## maternal_loss01           -2.01      0.24    -2.46    -1.51       1737
## maternal_loss15           -1.57      0.16    -1.87    -1.26       1682
## maternal_loss510          -1.19      0.15    -1.47    -0.90       1336
## maternal_loss1015         -1.00      0.14    -1.27    -0.71       1336
## maternal_loss1520         -0.84      0.14    -1.12    -0.57       1311
## maternal_loss2025         -0.64      0.14    -0.91    -0.36       1450
## maternal_loss2530         -0.62      0.14    -0.87    -0.34       1412
## maternal_loss3035         -0.53      0.13    -0.77    -0.28       1376
## maternal_loss3540         -0.42      0.12    -0.66    -0.17       1592
## maternal_loss4045         -0.23      0.14    -0.50     0.04       1638
## older_siblings1           -0.23      0.11    -0.45     0.00       1301
## older_siblings2           -0.26      0.13    -0.53     0.00        852
## older_siblings3           -0.25      0.16    -0.57     0.06        719
## older_siblings4           -0.31      0.20    -0.70     0.07        696
## older_siblings5P          -0.10      0.25    -0.59     0.40        617
## nr.siblings               -0.08      0.02    -0.12    -0.04        875
## last_born1                -0.03      0.08    -0.19     0.13       3000
##                        Rhat
## Intercept              1.05
## paternalage            1.00
## birth_cohort1750M1755  1.03
## birth_cohort1755M1760  1.03
## birth_cohort1760M1765  1.04
## birth_cohort1765M1770  1.03
## birth_cohort1770M1775  1.04
## birth_cohort1775M1780  1.05
## birth_cohort1780M1785  1.05
## birth_cohort1785M1790  1.05
## birth_cohort1790M1795  1.06
## 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
## 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.01
## paternal_loss3540      1.01
## paternal_loss4045      1.01
## maternal_loss01        1.00
## maternal_loss15        1.00
## maternal_loss510       1.00
## maternal_loss1015      1.00
## maternal_loss1520      1.00
## maternal_loss2025      1.00
## maternal_loss2530      1.00
## maternal_loss3035      1.00
## maternal_loss3540      1.00
## maternal_loss4045      1.00
## older_siblings1        1.00
## older_siblings2        1.00
## older_siblings3        1.00
## older_siblings4        1.01
## older_siblings5P       1.01
## nr.siblings            1.00
## 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

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$OR = exp(fixed_eff$Estimate)
fixed_eff$OR_low = exp(fixed_eff$`l-95% CI`)
fixed_eff$OR_high = exp(fixed_eff$`u-95% CI`)
pander::pander(fixed_eff)
  Estimate l-95% CI u-95% CI OR OR_low OR_high
Intercept 4.879 3.729 6.666 131.4 41.64 785.2
paternalage -0.1201 -0.4323 0.2048 0.8868 0.649 1.227
birth_cohort1750M1755 -0.2342 -2.239 1.82 0.7912 0.1066 6.172
birth_cohort1755M1760 0.521 -1.469 2.681 1.684 0.2301 14.61
birth_cohort1760M1765 0.04457 -1.77 1.593 1.046 0.1704 4.918
birth_cohort1765M1770 0.8415 -1.077 2.829 2.32 0.3406 16.93
birth_cohort1770M1775 -0.6148 -2.304 0.6465 0.5407 0.09981 1.909
birth_cohort1775M1780 -0.7439 -2.5 0.4842 0.4752 0.08211 1.623
birth_cohort1780M1785 -0.4331 -2.167 0.8544 0.6485 0.1145 2.35
birth_cohort1785M1790 -0.8129 -2.572 0.3211 0.4436 0.07638 1.379
birth_cohort1790M1795 -1.149 -2.873 -0.09373 0.3169 0.05651 0.9105
birth_cohort1795M1800 -0.6141 -2.389 0.4791 0.5411 0.09169 1.615
birth_cohort1800M1805 -0.5997 -2.343 0.4435 0.549 0.09602 1.558
birth_cohort1805M1810 -0.8242 -2.541 0.2342 0.4386 0.07876 1.264
birth_cohort1810M1815 -0.512 -2.233 0.5437 0.5993 0.1072 1.722
birth_cohort1815M1820 0.0001279 -1.717 1.048 1 0.1796 2.853
birth_cohort1820M1825 0.3544 -1.343 1.401 1.425 0.2611 4.059
birth_cohort1825M1830 -0.1276 -1.792 0.891 0.8802 0.1667 2.437
birth_cohort1830M1835 -0.01084 -1.731 1.032 0.9892 0.1771 2.807
birth_cohort1835M1840 0.1648 -1.578 1.191 1.179 0.2063 3.29
birth_cohort1840M1845 0.4148 -1.34 1.457 1.514 0.262 4.292
birth_cohort1845M1850 0.01306 -1.698 1.066 1.013 0.1831 2.905
male1 -0.3531 -0.4816 -0.2253 0.7025 0.6178 0.7983
maternalage.factor1020 -0.2743 -0.8941 0.4517 0.7601 0.409 1.571
maternalage.factor3559 -0.007444 -0.1888 0.1649 0.9926 0.828 1.179
paternalage.mean 0.2017 -0.1274 0.5313 1.223 0.8804 1.701
paternal_loss01 -1.872 -2.283 -1.459 0.1538 0.102 0.2324
paternal_loss15 -1.339 -1.663 -0.998 0.2621 0.1895 0.3686
paternal_loss510 -1.393 -1.697 -1.109 0.2483 0.1832 0.33
paternal_loss1015 -1.048 -1.352 -0.7525 0.3505 0.2588 0.4712
paternal_loss1520 -0.7264 -1.031 -0.4274 0.4837 0.3567 0.6522
paternal_loss2025 -0.683 -0.9829 -0.3883 0.5051 0.3742 0.6782
paternal_loss2530 -0.6914 -0.9804 -0.3999 0.5009 0.3752 0.6704
paternal_loss3035 -0.4361 -0.727 -0.1375 0.6465 0.4834 0.8715
paternal_loss3540 -0.2229 -0.5299 0.0861 0.8002 0.5887 1.09
paternal_loss4045 -0.3505 -0.6688 -0.0207 0.7043 0.5123 0.9795
maternal_loss01 -2.006 -2.463 -1.515 0.1345 0.08518 0.2198
maternal_loss15 -1.565 -1.868 -1.261 0.2091 0.1544 0.2832
maternal_loss510 -1.19 -1.468 -0.9041 0.3041 0.2303 0.4049
maternal_loss1015 -0.995 -1.265 -0.7065 0.3697 0.2821 0.4934
maternal_loss1520 -0.8433 -1.115 -0.5685 0.4303 0.3279 0.5664
maternal_loss2025 -0.6372 -0.9079 -0.3626 0.5288 0.4034 0.6959
maternal_loss2530 -0.6199 -0.8742 -0.3447 0.538 0.4172 0.7084
maternal_loss3035 -0.5276 -0.7695 -0.2815 0.59 0.4632 0.7546
maternal_loss3540 -0.4248 -0.6645 -0.1728 0.6539 0.5145 0.8413
maternal_loss4045 -0.2329 -0.499 0.03962 0.7922 0.6072 1.04
older_siblings1 -0.2278 -0.4499 0.001095 0.7963 0.6377 1.001
older_siblings2 -0.257 -0.5259 0.0008484 0.7733 0.591 1.001
older_siblings3 -0.2517 -0.5745 0.06315 0.7775 0.563 1.065
older_siblings4 -0.3127 -0.7019 0.0693 0.7315 0.4957 1.072
older_siblings5P -0.1023 -0.5907 0.3953 0.9027 0.554 1.485
nr.siblings -0.07967 -0.1222 -0.03629 0.9234 0.885 0.9644
last_born1 -0.03224 -0.1922 0.132 0.9683 0.8251 1.141

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 0.93 [0.92;0.95] [0.92;0.95]
estimate father 35y 0.93 [0.91;0.95] [0.92;0.94]
percentage change -0.16 [-0.68;0.27] [-0.47;0.12]
OR/IRR 0.89 [0.65;1.23] [0.71;1.09]

Marginal effect plots

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

Coefficient estimates (95% and 80% credibility).

mcmc_intervals(as.matrix(model$fit), regex_pars = "b_[^I]")

mcmc_areas(as.matrix(model$fit), regex_pars = "b")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

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 by average sample size

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

Monte Carlo SE

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

Trace plots

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

Further plots

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

File name

coefs/ddb/e2_surviveR.rds

Cluster script

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

Cluster script

e3: Probability of ever marrying

Here, we predict the probability that the anchor ever marries. All anchors who reached reproductive age (15) are included.

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: bernoulli (cauchit) 
## Formula: ever_married ~ 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: 43048) 
## 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: 13901) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     1.11      0.03     1.06     1.17        922    1
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  0.96      0.24     0.50     1.43        212
## paternalage                0.42      0.07     0.28     0.56        593
## birth_cohort1750M1755     -0.35      0.32    -1.01     0.27        485
## birth_cohort1755M1760      0.05      0.30    -0.54     0.64        328
## birth_cohort1760M1765      0.21      0.28    -0.32     0.77        283
## birth_cohort1765M1770      0.32      0.28    -0.21     0.87        251
## birth_cohort1770M1775      0.31      0.28    -0.23     0.84        245
## birth_cohort1775M1780      0.39      0.27    -0.14     0.91        254
## birth_cohort1780M1785      0.41      0.28    -0.12     0.98        256
## birth_cohort1785M1790      0.19      0.26    -0.31     0.70        215
## birth_cohort1790M1795     -0.11      0.24    -0.58     0.36        192
## birth_cohort1795M1800      0.18      0.23    -0.28     0.64        188
## birth_cohort1800M1805      0.32      0.23    -0.13     0.78        182
## birth_cohort1805M1810      0.44      0.23     0.01     0.88        181
## birth_cohort1810M1815      0.29      0.23    -0.15     0.73        170
## birth_cohort1815M1820      0.35      0.23    -0.08     0.79        167
## birth_cohort1820M1825      0.41      0.23    -0.02     0.84        161
## birth_cohort1825M1830      0.38      0.23    -0.05     0.81        166
## birth_cohort1830M1835      0.43      0.23     0.00     0.86        173
## birth_cohort1835M1840      0.39      0.23    -0.04     0.83        167
## birth_cohort1840M1845      0.30      0.22    -0.13     0.73        163
## birth_cohort1845M1850      0.28      0.23    -0.14     0.73        172
## male1                     -0.16      0.02    -0.20    -0.11       3000
## maternalage.factor1020     0.05      0.12    -0.18     0.29       2490
## maternalage.factor3559    -0.07      0.04    -0.15     0.00       1723
## paternalage.mean          -0.41      0.07    -0.55    -0.26        628
## paternal_loss01           -0.94      0.12    -1.17    -0.72       1839
## paternal_loss15           -0.73      0.08    -0.88    -0.58       1167
## paternal_loss510          -0.85      0.07    -0.98    -0.71       1158
## paternal_loss1015         -0.64      0.06    -0.76    -0.52       1064
## paternal_loss1520         -0.56      0.06    -0.67    -0.45        879
## paternal_loss2025         -0.46      0.05    -0.57    -0.36       1015
## paternal_loss2530         -0.30      0.05    -0.40    -0.20       1029
## paternal_loss3035         -0.23      0.05    -0.33    -0.13       1121
## paternal_loss3540         -0.20      0.05    -0.29    -0.11       1257
## paternal_loss4045         -0.04      0.05    -0.14     0.06       1515
## maternal_loss01           -1.24      0.15    -1.54    -0.93       3000
## maternal_loss15           -1.07      0.09    -1.24    -0.89       1711
## maternal_loss510          -0.99      0.07    -1.14    -0.85       1511
## maternal_loss1015         -1.00      0.07    -1.12    -0.87       1038
## maternal_loss1520         -0.85      0.06    -0.97    -0.73       1455
## maternal_loss2025         -0.59      0.06    -0.70    -0.48        833
## maternal_loss2530         -0.33      0.05    -0.43    -0.23       1207
## maternal_loss3035         -0.28      0.05    -0.38    -0.19       1218
## maternal_loss3540         -0.18      0.05    -0.27    -0.09        932
## maternal_loss4045         -0.08      0.05    -0.17     0.01       1409
## older_siblings1           -0.06      0.04    -0.14     0.02        936
## older_siblings2           -0.18      0.05    -0.28    -0.08        693
## older_siblings3           -0.25      0.07    -0.39    -0.13        617
## older_siblings4           -0.31      0.08    -0.47    -0.15        625
## older_siblings5P          -0.40      0.11    -0.61    -0.19        558
## nr.siblings                0.01      0.01    -0.01     0.03        596
## last_born1                -0.01      0.03    -0.07     0.06       3000
##                        Rhat
## Intercept              1.02
## paternalage            1.01
## birth_cohort1750M1755  1.01
## birth_cohort1755M1760  1.01
## birth_cohort1760M1765  1.01
## 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_loss15        1.00
## paternal_loss510       1.00
## paternal_loss1015      1.00
## paternal_loss1520      1.01
## paternal_loss2025      1.00
## paternal_loss2530      1.01
## paternal_loss3035      1.00
## paternal_loss3540      1.00
## paternal_loss4045      1.00
## maternal_loss01        1.00
## maternal_loss15        1.00
## maternal_loss510       1.00
## maternal_loss1015      1.00
## maternal_loss1520      1.00
## maternal_loss2025      1.00
## maternal_loss2530      1.00
## maternal_loss3035      1.00
## maternal_loss3540      1.00
## maternal_loss4045      1.00
## older_siblings1        1.00
## older_siblings2        1.00
## older_siblings3        1.01
## older_siblings4        1.00
## older_siblings5P       1.00
## nr.siblings            1.00
## 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

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$OR = exp(fixed_eff$Estimate)
fixed_eff$OR_low = exp(fixed_eff$`l-95% CI`)
fixed_eff$OR_high = exp(fixed_eff$`u-95% CI`)
pander::pander(fixed_eff)
  Estimate l-95% CI u-95% CI OR OR_low OR_high
Intercept 0.961 0.5017 1.434 2.614 1.652 4.195
paternalage 0.4212 0.2796 0.5569 1.524 1.323 1.745
birth_cohort1750M1755 -0.3549 -1.013 0.2669 0.7012 0.3633 1.306
birth_cohort1755M1760 0.05458 -0.5413 0.6435 1.056 0.582 1.903
birth_cohort1760M1765 0.2118 -0.3169 0.7675 1.236 0.7284 2.154
birth_cohort1765M1770 0.3241 -0.2091 0.8713 1.383 0.8113 2.39
birth_cohort1770M1775 0.3139 -0.2324 0.8393 1.369 0.7927 2.315
birth_cohort1775M1780 0.3896 -0.1354 0.9075 1.476 0.8734 2.478
birth_cohort1780M1785 0.4132 -0.1153 0.9758 1.512 0.8911 2.653
birth_cohort1785M1790 0.1893 -0.3098 0.7043 1.208 0.7336 2.022
birth_cohort1790M1795 -0.1069 -0.5822 0.3623 0.8986 0.5587 1.437
birth_cohort1795M1800 0.1788 -0.2777 0.6395 1.196 0.7575 1.896
birth_cohort1800M1805 0.3248 -0.133 0.7774 1.384 0.8755 2.176
birth_cohort1805M1810 0.4405 0.01303 0.8832 1.554 1.013 2.419
birth_cohort1810M1815 0.2899 -0.1526 0.7323 1.336 0.8585 2.08
birth_cohort1815M1820 0.3524 -0.07981 0.7892 1.422 0.9233 2.202
birth_cohort1820M1825 0.4104 -0.02261 0.8433 1.507 0.9776 2.324
birth_cohort1825M1830 0.3771 -0.04926 0.8098 1.458 0.9519 2.247
birth_cohort1830M1835 0.4313 0.000461 0.8647 1.539 1 2.374
birth_cohort1835M1840 0.3946 -0.0381 0.8297 1.484 0.9626 2.293
birth_cohort1840M1845 0.2972 -0.1349 0.73 1.346 0.8738 2.075
birth_cohort1845M1850 0.2825 -0.1394 0.7266 1.326 0.8699 2.068
male1 -0.1563 -0.2039 -0.1066 0.8553 0.8156 0.8989
maternalage.factor1020 0.04972 -0.1816 0.2886 1.051 0.8339 1.335
maternalage.factor3559 -0.07084 -0.1465 0.002723 0.9316 0.8637 1.003
paternalage.mean -0.4083 -0.5492 -0.2626 0.6648 0.5774 0.769
paternal_loss01 -0.943 -1.168 -0.7177 0.3895 0.311 0.4879
paternal_loss15 -0.7303 -0.8845 -0.5761 0.4817 0.4129 0.5621
paternal_loss510 -0.851 -0.9818 -0.7107 0.427 0.3746 0.4913
paternal_loss1015 -0.6417 -0.7622 -0.5229 0.5264 0.4666 0.5928
paternal_loss1520 -0.5637 -0.6732 -0.4515 0.5691 0.5101 0.6366
paternal_loss2025 -0.459 -0.5665 -0.3557 0.6319 0.5675 0.7007
paternal_loss2530 -0.2993 -0.4003 -0.1966 0.7413 0.6701 0.8216
paternal_loss3035 -0.2292 -0.3259 -0.1326 0.7952 0.7219 0.8759
paternal_loss3540 -0.2024 -0.2946 -0.1073 0.8168 0.7449 0.8982
paternal_loss4045 -0.04263 -0.1437 0.05735 0.9583 0.8662 1.059
maternal_loss01 -1.236 -1.543 -0.9322 0.2905 0.2137 0.3937
maternal_loss15 -1.066 -1.241 -0.8905 0.3443 0.2892 0.4105
maternal_loss510 -0.9926 -1.137 -0.8465 0.3706 0.3208 0.4289
maternal_loss1015 -0.9977 -1.124 -0.8712 0.3687 0.3249 0.4185
maternal_loss1520 -0.8502 -0.974 -0.7273 0.4273 0.3776 0.4832
maternal_loss2025 -0.5883 -0.696 -0.482 0.5553 0.4986 0.6176
maternal_loss2530 -0.3303 -0.4342 -0.231 0.7187 0.6478 0.7938
maternal_loss3035 -0.2847 -0.3793 -0.1855 0.7523 0.6843 0.8307
maternal_loss3540 -0.1782 -0.2685 -0.08933 0.8368 0.7645 0.9145
maternal_loss4045 -0.07811 -0.1674 0.01355 0.9249 0.8458 1.014
older_siblings1 -0.05966 -0.1379 0.01699 0.9421 0.8712 1.017
older_siblings2 -0.1803 -0.2811 -0.08111 0.835 0.7549 0.9221
older_siblings3 -0.2547 -0.3897 -0.1258 0.7751 0.6773 0.8818
older_siblings4 -0.3103 -0.4662 -0.1455 0.7332 0.6274 0.8646
older_siblings5P -0.4017 -0.6064 -0.1943 0.6692 0.5453 0.8234
nr.siblings 0.007633 -0.01057 0.02623 1.008 0.9895 1.027
last_born1 -0.00767 -0.07283 0.05767 0.9924 0.9298 1.059

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 0.68 [0.56;0.76] [0.6;0.74]
estimate father 35y 0.76 [0.67;0.81] [0.7;0.8]
percentage change 7.94 [4.47;12.38] [5.48;10.83]
OR/IRR 1.53 [1.32;1.75] [1.38;1.67]

Marginal effect plots

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

Coefficient estimates (95% and 80% credibility).

mcmc_intervals(as.matrix(model$fit), regex_pars = "b_[^I]")

mcmc_areas(as.matrix(model$fit), regex_pars = "b")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

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 by average sample size

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

Monte Carlo SE

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

Trace plots

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

Further plots

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

File name

coefs/ddb/e3_ever_married.rds

Cluster script

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

Cluster script

e4: Number of children

Here, we predict the number of children that the anchor had. To separate this effect from previous selective episodes, we include only ever-married anchors and control for their number of spouses (interacted with sex, because men tend to have more additional children from further spouses).

Model summary

Full summary

model_summary = summary(model, use_cache = FALSE, priors = TRUE)
print(model_summary)
##  Family: poisson (log) 
## Formula: children ~ paternalage + birth_cohort + spouses * male + maternalage.factor + paternalage.mean + paternal_loss + maternal_loss + older_siblings + nr.siblings + last_born + (1 | idParents) 
##    Data: model_data (Number of observations: 25518) 
## Samples: 6 chains, each with iter = 800; warmup = 300; thin = 1; 
##          total post-warmup samples = 3000
##    WAIC: Not computed
##  
## Priors: 
## b ~ normal(0,5)
## sd ~ student_t(3, 0, 5)
## 
## Group-Level Effects: 
## ~idParents (Number of levels: 11129) 
##               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sd(Intercept)     0.45      0.01     0.44     0.46        950    1
## 
## Population-Level Effects: 
##                        Estimate Est.Error l-95% CI u-95% CI Eff.Sample
## Intercept                  0.79      0.10     0.59     0.97         48
## paternalage               -0.05      0.02    -0.09    -0.01        564
## birth_cohort1750M1755     -0.09      0.12    -0.32     0.14        134
## birth_cohort1755M1760      0.15      0.10    -0.03     0.36         70
## birth_cohort1760M1765      0.24      0.10     0.05     0.43         54
## birth_cohort1765M1770      0.21      0.09     0.02     0.39         53
## birth_cohort1770M1775      0.15      0.10    -0.03     0.35         52
## birth_cohort1775M1780      0.10      0.10    -0.07     0.30         52
## birth_cohort1780M1785      0.21      0.10     0.03     0.40         49
## birth_cohort1785M1790      0.22      0.09     0.05     0.41         47
## birth_cohort1790M1795      0.10      0.09    -0.06     0.29         46
## birth_cohort1795M1800      0.06      0.09    -0.10     0.25         45
## birth_cohort1800M1805      0.03      0.09    -0.13     0.21         45
## birth_cohort1805M1810      0.07      0.09    -0.09     0.25         43
## birth_cohort1810M1815      0.08      0.09    -0.08     0.26         43
## birth_cohort1815M1820      0.16      0.09     0.00     0.34         43
## birth_cohort1820M1825      0.18      0.09     0.03     0.36         43
## birth_cohort1825M1830      0.16      0.09     0.01     0.34         43
## birth_cohort1830M1835      0.18      0.09     0.02     0.36         43
## birth_cohort1835M1840      0.18      0.09     0.03     0.36         42
## birth_cohort1840M1845      0.16      0.09    -0.01     0.33         43
## birth_cohort1845M1850      0.16      0.09     0.00     0.33         43
## spouses                    0.24      0.02     0.20     0.28       1091
## male1                      0.03      0.03    -0.02     0.09        945
## maternalage.factor1020     0.03      0.03    -0.03     0.09       2366
## maternalage.factor3559     0.06      0.01     0.04     0.08       1959
## paternalage.mean           0.06      0.02     0.02     0.10        599
## paternal_loss01            0.09      0.04     0.01     0.16        744
## paternal_loss15            0.00      0.03    -0.05     0.05        790
## paternal_loss510          -0.01      0.02    -0.05     0.04        796
## paternal_loss1015         -0.01      0.02    -0.05     0.03        792
## paternal_loss1520         -0.08      0.02    -0.11    -0.04        734
## paternal_loss2025         -0.01      0.02    -0.05     0.02        745
## paternal_loss2530         -0.01      0.02    -0.04     0.02        815
## paternal_loss3035          0.00      0.01    -0.03     0.03        850
## paternal_loss3540          0.03      0.01     0.00     0.06        899
## paternal_loss4045          0.03      0.01     0.00     0.05       1558
## maternal_loss01            0.06      0.05    -0.04     0.16       1696
## maternal_loss15           -0.01      0.03    -0.07     0.05       1155
## maternal_loss510          -0.03      0.03    -0.08     0.02       1005
## maternal_loss1015         -0.04      0.02    -0.08     0.01       1035
## maternal_loss1520         -0.05      0.02    -0.09     0.00        970
## maternal_loss2025         -0.07      0.02    -0.10    -0.03        840
## maternal_loss2530         -0.02      0.02    -0.05     0.01        932
## maternal_loss3035         -0.01      0.01    -0.04     0.01        830
## maternal_loss3540          0.00      0.01    -0.02     0.03       1106
## maternal_loss4045         -0.02      0.01    -0.05     0.00       1610
## older_siblings1            0.00      0.01    -0.02     0.03       1229
## older_siblings2            0.02      0.01    -0.01     0.05        834
## older_siblings3            0.02      0.02    -0.01     0.06        655
## older_siblings4            0.01      0.02    -0.03     0.05        577
## older_siblings5P           0.01      0.03    -0.04     0.07        602
## nr.siblings                0.02      0.00     0.02     0.03        535
## last_born1                -0.01      0.01    -0.03     0.01       3000
## spouses:male1              0.06      0.03     0.02     0.11        922
##                        Rhat
## Intercept              1.11
## paternalage            1.00
## birth_cohort1750M1755  1.04
## birth_cohort1755M1760  1.07
## birth_cohort1760M1765  1.09
## birth_cohort1765M1770  1.10
## birth_cohort1770M1775  1.10
## birth_cohort1775M1780  1.09
## birth_cohort1780M1785  1.10
## birth_cohort1785M1790  1.11
## birth_cohort1790M1795  1.11
## birth_cohort1795M1800  1.11
## birth_cohort1800M1805  1.11
## birth_cohort1805M1810  1.11
## birth_cohort1810M1815  1.12
## birth_cohort1815M1820  1.12
## birth_cohort1820M1825  1.12
## birth_cohort1825M1830  1.12
## birth_cohort1830M1835  1.12
## birth_cohort1835M1840  1.12
## birth_cohort1840M1845  1.12
## birth_cohort1845M1850  1.12
## spouses                1.00
## male1                  1.00
## maternalage.factor1020 1.00
## maternalage.factor3559 1.00
## paternalage.mean       1.01
## paternal_loss01        1.01
## paternal_loss15        1.00
## paternal_loss510       1.01
## paternal_loss1015      1.00
## paternal_loss1520      1.01
## 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.01
## maternal_loss510       1.00
## maternal_loss1015      1.00
## maternal_loss1520      1.00
## maternal_loss2025      1.00
## maternal_loss2530      1.01
## maternal_loss3035      1.01
## maternal_loss3540      1.01
## 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
## spouses: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

fixed_eff = data.frame(model_summary$fixed, check.names = F)
fixed_eff$Est.Error = fixed_eff$Eff.Sample = fixed_eff$Rhat = NULL
fixed_eff$OR = exp(fixed_eff$Estimate)
fixed_eff$OR_low = exp(fixed_eff$`l-95% CI`)
fixed_eff$OR_high = exp(fixed_eff$`u-95% CI`)
pander::pander(fixed_eff)
  Estimate l-95% CI u-95% CI OR OR_low OR_high
Intercept 0.7909 0.5911 0.9714 2.205 1.806 2.642
paternalage -0.05442 -0.09302 -0.01368 0.947 0.9112 0.9864
birth_cohort1750M1755 -0.08822 -0.3158 0.1384 0.9156 0.7292 1.148
birth_cohort1755M1760 0.1548 -0.02884 0.3555 1.167 0.9716 1.427
birth_cohort1760M1765 0.2411 0.05476 0.4344 1.273 1.056 1.544
birth_cohort1765M1770 0.2054 0.02307 0.3916 1.228 1.023 1.479
birth_cohort1770M1775 0.1508 -0.02616 0.3481 1.163 0.9742 1.416
birth_cohort1775M1780 0.1016 -0.0748 0.2957 1.107 0.9279 1.344
birth_cohort1780M1785 0.2079 0.03449 0.4019 1.231 1.035 1.495
birth_cohort1785M1790 0.2198 0.04896 0.4097 1.246 1.05 1.506
birth_cohort1790M1795 0.103 -0.06411 0.288 1.108 0.9379 1.334
birth_cohort1795M1800 0.0643 -0.09769 0.2523 1.066 0.9069 1.287
birth_cohort1800M1805 0.03241 -0.1281 0.2145 1.033 0.8798 1.239
birth_cohort1805M1810 0.06879 -0.08786 0.2512 1.071 0.9159 1.286
birth_cohort1810M1815 0.07929 -0.08176 0.2574 1.083 0.9215 1.294
birth_cohort1815M1820 0.1645 0.004264 0.3413 1.179 1.004 1.407
birth_cohort1820M1825 0.1846 0.02506 0.359 1.203 1.025 1.432
birth_cohort1825M1830 0.1628 0.005863 0.3411 1.177 1.006 1.407
birth_cohort1830M1835 0.1794 0.01908 0.3584 1.197 1.019 1.431
birth_cohort1835M1840 0.1845 0.02534 0.3624 1.203 1.026 1.437
birth_cohort1840M1845 0.1557 -0.006188 0.3331 1.168 0.9938 1.395
birth_cohort1845M1850 0.1566 -0.002421 0.3307 1.169 0.9976 1.392
spouses 0.2389 0.1952 0.2809 1.27 1.216 1.324
male1 0.03136 -0.02329 0.08591 1.032 0.977 1.09
maternalage.factor1020 0.03154 -0.02572 0.08924 1.032 0.9746 1.093
maternalage.factor3559 0.05829 0.03611 0.08059 1.06 1.037 1.084
paternalage.mean 0.06018 0.01785 0.09956 1.062 1.018 1.105
paternal_loss01 0.08862 0.009738 0.1623 1.093 1.01 1.176
paternal_loss15 -0.001212 -0.05476 0.04899 0.9988 0.9467 1.05
paternal_loss510 -0.008503 -0.05255 0.03689 0.9915 0.9488 1.038
paternal_loss1015 -0.006687 -0.04728 0.03202 0.9933 0.9538 1.033
paternal_loss1520 -0.07606 -0.113 -0.03877 0.9268 0.8931 0.962
paternal_loss2025 -0.01325 -0.04617 0.02054 0.9868 0.9549 1.021
paternal_loss2530 -0.01014 -0.04059 0.01995 0.9899 0.9602 1.02
paternal_loss3035 -0.001064 -0.02967 0.0282 0.9989 0.9708 1.029
paternal_loss3540 0.02891 0.002086 0.05543 1.029 1.002 1.057
paternal_loss4045 0.02553 0.0004206 0.05223 1.026 1 1.054
maternal_loss01 0.06107 -0.04331 0.1639 1.063 0.9576 1.178
maternal_loss15 -0.01352 -0.07488 0.04703 0.9866 0.9279 1.048
maternal_loss510 -0.03195 -0.08177 0.0156 0.9686 0.9215 1.016
maternal_loss1015 -0.037 -0.08062 0.008072 0.9637 0.9225 1.008
maternal_loss1520 -0.04518 -0.0871 -0.0001487 0.9558 0.9166 0.9999
maternal_loss2025 -0.06787 -0.1029 -0.03202 0.9344 0.9022 0.9685
maternal_loss2530 -0.01796 -0.05054 0.01492 0.9822 0.9507 1.015
maternal_loss3035 -0.01368 -0.0412 0.01378 0.9864 0.9596 1.014
maternal_loss3540 0.0004971 -0.0236 0.02554 1 0.9767 1.026
maternal_loss4045 -0.02163 -0.04533 0.002406 0.9786 0.9557 1.002
older_siblings1 0.00475 -0.01542 0.02542 1.005 0.9847 1.026
older_siblings2 0.01951 -0.007211 0.04676 1.02 0.9928 1.048
older_siblings3 0.02335 -0.009364 0.05681 1.024 0.9907 1.058
older_siblings4 0.01359 -0.02938 0.05483 1.014 0.9711 1.056
older_siblings5P 0.0139 -0.03963 0.06901 1.014 0.9611 1.071
nr.siblings 0.02384 0.01826 0.02954 1.024 1.018 1.03
last_born1 -0.01189 -0.03104 0.005574 0.9882 0.9694 1.006
spouses:male1 0.06484 0.01604 0.1139 1.067 1.016 1.121

Paternal age effect

pander::pander(paternal_age_10y_effect(model))
effect median_estimate ci_95 ci_80
estimate father 25y 3.41 [2.85;3.97] [3.03;3.79]
estimate father 35y 3.23 [2.69;3.79] [2.86;3.61]
percentage change -5.35 [-8.88;-1.36] [-7.63;-2.9]
OR/IRR 0.95 [0.91;0.99] [0.92;0.97]

Marginal effect plots

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

Coefficient estimates (95% and 80% credibility).

mcmc_intervals(as.matrix(model$fit), regex_pars = "b_[^I]")

mcmc_areas(as.matrix(model$fit), regex_pars = "b")

Diagnostics

These plots were made to diagnose misfit and nonconvergence.

Posterior predictive checks

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 by average sample size

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

Monte Carlo SE

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

Trace plots

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

Further plots

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

File name

coefs/ddb/e4_children.rds

Cluster script

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

Cluster script

e5: Probability of ever divorcing

Here, we predict the probability of ever divorcing. To separate this effect from previous selective episodes, we include only ever-married anchors. Divorce data was only analysed in modern Sweden.

All episodes

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