The Nordpred software package is a package of R and S-PLUS functions for predicting trends in cancer incidence, using a special version of the Age-Period-Cohort model (APC). The package is originally written by Harald Fekjaer and Bjorn Moller at the Cancer Registry of Norway as part of a larger cancer prediction project with financial support from the Nordic Cancer Union (NCU).
library(nordpred)
Assume we have thre data sets, all with the following properties:
In this example, all data concerns Norwegian males. Cancer incidence concerns colon cancer.
The example data set inpop1
gives observed population numbers for five year intervals from 1958 to 1997.
knitr::kable(inpop1)
The example data set inpop2
gives predicted population numbers for five year intervals from 1998 to 2022.
knitr::kable(inpop2)
The example data set indata
gives observed number of cancer incidences from the same time period as inpop1
.
knitr::kable(inpop2)
Functions in the nordpred package expect one data set for population data (both observed and predicted values).
inpop <- cbind(inpop1, inpop2)
Use nordpred.estimate
to estimate a model
est <- nordpred.estimate(cases=indata, pyr = inpop, noperiod = 4, startestage = 5)
Then, use the outcome (a nordpred
object) for prediction by nordpred.prediction
res <- nordpred.prediction(est, startuseage = 6, cuttrend = c(0,.25,.5,.75,.75), recent=TRUE)
Or estimate and predict simultaneously using nordpred
(same result)
res <- nordpred(cases = indata, pyr = inpop, startestage = 5, startuseage = 6, noperiods = 4, cuttrend = c(0, .25, .5, .75, .75))
The "nordpred"-function can also choose number periods to base predictions on: This is done by listing candidate number of periods in "noperiods". If the goodness of fit test is rejected based on the widest base, the first period is excluded etc.
res <- nordpred(indata, inpop, startestage = 5, startuseage = 6, noperiods = 4:6, cuttrend=c(0, .25, .5, .75, .75))
We can also use a poisson link function (instead of the powerlink as used in the nordpred predictions).
est2 <- nordpred.estimate(indata, inpop, 4, 5, linkfunc = "poisson") res2 <- nordpred.prediction(est2, startuseage = 6, cuttrend = c(0, .25, .5, .75, .75), recent = TRUE)
print(res) nordpred.getpred(res) summary(res, printpred = FALSE)
## World population standard wstand <- c(0.12, 0.1, 0.09, 0.09, 0.08, 0.08, 0.06, 0.06, 0.06, 0.06,0.05, 0.04, 0.04, 0.03, 0.02, 0.01, 0.005, 0.005) round(nordpred.getpred(res, incidence = TRUE, standpop = NULL), 2) round(nordpred.getpred(res, incidence = TRUE, standpop = wstand), 2)
plot(res, standpop = wstand)
plot(res2, standpop = wstand) plot(res, new = FALSE, lty = c(1, 2), standpop = wstand)
using average drift (recent = FALSE)
plot(nordpred.prediction(est, startuseage = 6, cuttrend = c(0, 0, 0, 0, 0), recent = FALSE), standpop = wstand, new = TRUE) plot(nordpred.prediction(est, startuseage = 6, cuttrend = c(1, 1, 1, 1, 1), recent = FALSE), standpop = wstand, new = FALSE, lty = c(1, 2)) plot(nordpred.prediction(est, startuseage = 6, cuttrend = c(0, .25, .5, .75, .75), recent = FALSE), standpop = wstand, new = FALSE, lty = c(1, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.