# load the data set in the package
library("xhaz")
library("numDeriv")
# load the data sets 'simuData
data("simuData", package = "xhaz")
#define the levels of variable sex
levels(simuData$sex) <- c("male", "female")
# Esteve et al. model
set.seed(1980)
simuData2 <- simuData[sample(nrow(simuData), size = 500), ]
fit.estv2 <- xhaz(formula = Surv(time_year, status) ~ agec + race,
data = simuData2,
ratetable = survexp.us,
interval = c(0, NA, NA, NA, NA, NA, 6),
rmap = list(age = 'age', sex = 'sex', year = 'date'),
baseline = "constant", pophaz = "classic")
predict_est <- predict(object = fit.estv2,
new.data = simuData2,
times.pts = c(seq(0, 4, 1)),
baseline = TRUE)
predict_est
Run the code above in your browser using DataLab