Bayesian Age-Period-Cohort Modeling

Volker Schmid

2018-10-30

Data example

BAMP includes a data example.

data(apc)
plot(cases[,1],type="l",ylim=range(cases), ylab="cases", xlab="year", main="cases per age group")
for (i in 2:8)lines(cases[,i], col=i)
plot of chunk loadplot

plot of chunk loadplot

APC model with random walk first order prior

model1 <- bamp(cases, population, age="rw1", period="rw1", cohort="rw1",
              periods_per_agegroup = 5)

bamp() automatically performs a check for MCMC convergence using Gelman and Rubin’s convergence diagnostic. We can manually check the convergence again:

checkConvergence(model1)
## [1] TRUE

Now we have a look at the model results. This includes estimates of smoothing parameters and deviance and DIC:

print(model1)
## 
##  Model:
## age (rw1)  - period (rw1)  - cohort (rw1) model
## Deviance:     231.03
## pD:            36.69
## DIC:          267.73
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.404        1.047        2.236
## period                          68.994      200.213      607.918
## cohort                          34.270       59.168       97.495

We can plot the main APC effects using point-wise quantiles:

plot(model1)

plot of chunk plot_modelplot of chunk plot_modelplot of chunk plot_model

More quantiles are possible:

plot(model1, quantiles = c(0.025,0.1,0.5,0.9,0.975))

plot of chunk plot_model_with_more_quantilesplot of chunk plot_model_with_more_quantilesplot of chunk plot_model_with_more_quantiles

model2 <- bamp(cases, population, age="rw2", period="rw2", cohort="rw2",
              periods_per_agegroup = 5)
checkConvergence(model2)
## [1] TRUE
print(model2)
## 
##  Model:
## age (rw2)  - period (rw2)  - cohort (rw2) model
## Deviance:     246.32
## pD:            33.69
## DIC:          280.01
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              2.014        6.246       16.696
## period                          55.490      307.804     2827.581
## cohort                          37.044       74.924      146.403
plot(model2)

plot of chunk Model2_resultsplot of chunk Model2_resultsplot of chunk Model2_results

model3<-bamp(cases, population, age="rw1", period=" ", cohort="rw2",
              periods_per_agegroup = 5)
checkConvergence(model3)
## [1] TRUE
print(model3)
## 
##  Model:
## age (rw1) cohort (rw2) model
## Deviance:     276.60
## pD:            29.99
## DIC:          306.59
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.301        0.797        1.644
## cohort                          38.018       74.193      139.638
plot(model3)

plot of chunk model3plot of chunk model3

(model4<-bamp(cases, population, age="rw1", period="rw1", cohort="rw1",
             cohort_covariate = cov_c, periods_per_agegroup = 5))
## 
##  Model:
## age (rw1)  - period (rw1)  - cohort (rw1) model
## Deviance:     231.32
## pD:            36.92
## DIC:          268.25
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.406        1.040        2.252
## period                          65.700      196.123      626.652
## cohort                          34.013       59.356       97.958
plot(model4)

plot of chunk model4plot of chunk model4plot of chunk model4plot of chunk model4plot of chunk model4plot of chunk model4

(model5<-bamp(cases, population, age="rw1", period="rw1", cohort="rw1",
             period_covariate = cov_p, periods_per_agegroup = 5))
## 
##  Model:
## age (rw1)  - period (rw1)  - cohort (rw1) model
## Deviance:     231.22
## pD:            36.81
## DIC:          268.04
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.394        1.039        2.197
## period                          66.652      195.959      625.782
## cohort                          34.518       59.524       98.195
plot(model5)

plot of chunk model5plot of chunk model5plot of chunk model5plot of chunk model5plot of chunk model5plot of chunk model5