# \donttest{
library("numDeriv")
library("survexp.fr")
library("splines")
data("simuData", "dataCancer", package = "xhaz")
# load the data sets 'simuData' and 'dataCancer'.
# Esteve et al. model: baseline excess hazard is a piecewise function
# linear and proportional effects for the covariates on
# baseline excess hazard.
fit.estv1 <- xhaz(formula = Surv(time_year, status) ~ agec + race,
data = simuData,
ratetable = survexp.us,
interval = c(0, NA, NA, NA, NA, NA, max(simuData$time_year)),
rmap = list(age = 'age', sex = 'sex', year = 'date'),
baseline = "constant",
pophaz = "classic")
fit.estv1
# Touraine et al. model: baseline excess hazard is a piecewise function
# with a linear and proportional effects for the
# covariates on the baseline excess hazard.
# An additionnal cavariate (here race) missing in the life table is
# considered by the model.
fit.corrected1 <- xhaz(formula = Surv(time_year, status) ~ agec + race,
data = simuData,
ratetable = survexp.us,
interval = c(0, NA, NA, NA, NA, NA,
max(simuData$time_year)),
rmap = list(age = 'age', sex = 'sex', year = 'date'),
baseline = "constant", pophaz = "corrected",
add.rmap = "race")
fit.corrected1
# An additionnal cavariate (here race) missing in the life table is
# considered by the model with a breakpoint at 75 years
fit.corrected2 <- xhaz(formula = Surv(time_year, status) ~ agec + race,
data = simuData, ratetable = survexp.us,
interval = c(0, NA, NA, NA, NA, 6),
rmap = list(age = 'age', sex = 'sex', year = 'date'),
baseline = "constant", pophaz = "corrected",
add.rmap = "race",
add.rmap.cut = list(breakpoint = TRUE, cut = 75))
fit.corrected2
data("breast")
#load the data sets 'breast'.
# Flexible mexhaz model: baseline excess hazard with cubic B-splines
# assumption on the life table available :
# other cause mortality in the cohort is comparable to the mortality
# observed in the general population with the same characteristics.
# The life table to be used is survexp.us. Note that SEX is coded 2 instead of female in survexp.us.
breast$sexe <- "female"
fit.haz <- exphaz(
formula = Surv(temps, statut) ~ 1,
data = breast, ratetable = survexp.us,
only_ehazard = FALSE,
rmap = list(age = 'age', sex = 'sexe', year = 'date'))
breast$expected <- fit.haz$ehazard
breast$expectedCum <- fit.haz$ehazardInt
mod.bs <- mexhazLT(formula = Surv(temps, statut) ~ agecr + armt,
data = breast,
ratetable = survexp.us, degree = 3,
knots=quantile(breast[breast$statut==1,]$temps, probs=c(1:2/3)),
expected = "expected",expectedCum = "expectedCum",
base = "exp.bs", pophaz = "classic")
mod.bs
# Flexible mexhaz model: baseline excess hazard with cubic B-splines
# assumption on the life table available :
# other cause mortality in the cohort is different to the mortality
# observed in the general population with the same characteristics.
mod.bs2 <- mexhazLT(formula = Surv(temps, statut) ~ agecr + armt,
data = breast, degree = 3,
knots=quantile(breast[breast$statut==1,]$temps, probs=c(1:2/3)),
expected = "expected",expectedCum = "expectedCum",
base = "exp.bs", pophaz = "rescaled")
mod.bs2
# Flexible mexhaz model with a random effects at cluster level:
# baseline excess hazard with cubic B-splines
# assumption on the life table used :
# other cause mortality in the cohort is different to the mortality
# observed in the general population with the same characteristics.
mod.bs3 <- mexhazLT(formula = Surv(temps, statut) ~ agecr + armt,
data = breast, degree = 3,
knots=quantile(breast[breast$statut==1,]$temps, probs=c(1:2/3)),
expected = "expected",expectedCum = "expectedCum",
base = "exp.bs", pophaz = "rescaled", random = "hosp")
mod.bs3
# }
Run the code above in your browser using DataLab