# This example reproduces Fig. 1 of Mackenbach et al. 2015, p.5
# 40 simulated time points, with an initial rate ratio of 2 and
# a rate difference of 100 (i.e. low status group starts with a
# prevalence rate of 200, the high status group with 100)
# annual decline of prevalence is 1% for the low, and 3% for the
# high status group
n <- 40
time <- seq(1, n, by = 1)
lo <- rep(200, times = n)
for (i in 2:n) lo[i] <- lo[i - 1] * .99
hi <- rep(100, times = n)
for (i in 2:n) hi[i] <- hi[i - 1] * .97
prev.data <- data.frame(lo, hi)
# print values
inequ_trend(prev.data, lo, hi)
# plot trends - here we see that the relative inequalities
# are increasing over time, while the absolute inequalities
# are first increasing as well, but later are decreasing
# (while rel. inequ. are still increasing)
plot(inequ_trend(prev.data, lo, hi))
Run the code above in your browser using DataLab