# \donttest{
library("survival")
library("numDeriv")
library("survexp.fr")
library("splines")
data("dataCancer", package = "xhaz") # load the data set in the package
fit.phBS <- xhaz(
formula = Surv(obs_time_year, event) ~ ageCentre + immuno_trt,
data = dataCancer, ratetable = survexp.fr,
interval = c(0, NA, NA, max(dataCancer$obs_time_year)),
rmap = list(age = 'age', sex = 'sexx', year = 'year_date'),
baseline = "bsplines", pophaz = "classic")
print(fit.phBS)
predicted <- predict(object = fit.phBS,
new.data = dataCancer[1:10,],
times.pts = c(seq(0,10,1)),
baseline = TRUE)
#a list of predicted hazard and survival at different time points
print(predicted)
#predicted hazard and survival at time points 10 years
do.call("cbind",predicted)[11,]
# }
Run the code above in your browser using DataLab