Bayesian Age-Period-Cohort Modeling

Volker Schmid

2021-06-10

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)

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.46
## pD:            36.99
## DIC:          268.45
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.360        0.901        1.997
## period                          66.801      200.355      630.834
## cohort                          33.961       59.218       97.429
## 
## 
## Markov Chains convergence checked succesfully using Gelman's R (potential scale reduction factor).

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

plot(model1)

More quantiles are possible:

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

APC model with random walk second order prior

model2 <- bamp(cases, population, age="rw2", period="rw2", cohort="rw2",
              periods_per_agegroup = 5,
              mcmc.options=list("number_of_iterations"=200000, "burn_in"=100000, "step"=50, "tuning"=500),
              hyperpar=list("age"=c(1,.5), "period"=c(1,0.05), "cohort"=c(1,0.05)))
checkConvergence(model2)
## [1] TRUE
print(model2)
## 
##  Model:
## age (rw2)  - period (rw2)  - cohort (rw2) model
## Deviance:     234.38
## pD:            37.07
## DIC:          271.44
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              1.041        2.942        6.574
## period                          16.373       41.251       90.391
## cohort                          23.480       44.714       80.963
## 
## 
## Markov Chains convergence checked succesfully using Gelman's R (potential scale reduction factor).
plot(model2)

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.77
## pD:            30.38
## DIC:          307.15
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.291        0.714        1.500
## cohort                          37.705       74.057      138.728
## 
## 
## Markov Chains convergence checked succesfully using Gelman's R (potential scale reduction factor).
plot(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.24
## pD:            36.87
## DIC:          268.11
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.344        0.922        1.899
## period                          69.196      203.391      636.627
## cohort                          34.668       58.941       98.535
## 
## 
## Markov Chains convergence checked succesfully using Gelman's R (potential scale reduction factor).
plot(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.32
## pD:            36.83
## DIC:          268.15
## 
## 
##  Hyper parameters:                 5%           50%          95%         
## age                              0.342        0.905        1.922
## period                          69.944      203.613      639.038
## cohort                          34.877       59.449       97.862
## 
## 
## Markov Chains convergence checked succesfully using Gelman's R (potential scale reduction factor).
plot(model5)