# Example of a hazard function
b_func <- function(x)
cbind(1, sin(2 * pi * x), x)
omega <- c(-3, 3, .25)
haz_fun <- function(x)
exp(drop(b_func(x) %*% omega))
plot(haz_fun, xlim = c(0, 10))
# plot the hazard
library(SimSurvNMarker)
gl_dat <- get_gl_rule(60L)
plot(function(x) eval_surv_base_fun(ti = x, omega = omega,
b_func = b_func, gl_dat = gl_dat),
xlim = c(1e-4, 10), ylim = c(0, 1), bty = "l", xlab = "time",
ylab = "Survival", yaxs = "i")
# using to few nodes gives a wrong result in this case!
gl_dat <- get_gl_rule(15L)
plot(function(x) eval_surv_base_fun(ti = x, omega = omega,
b_func = b_func, gl_dat = gl_dat),
xlim = c(1e-4, 10), ylim = c(0, 1), bty = "l", xlab = "time",
ylab = "Survival", yaxs = "i")
Run the code above in your browser using DataLab