eval_surv_base_fun: Evaluates the Survival Function without a Marker

View source: R/sim.R

eval_surv_base_funR Documentation

Evaluates the Survival Function without a Marker

Description

Evaluates the survival function at given points where the hazard is given by

h(t) = \exp(\vecω^\top\vec b(t) + δ).

Usage

eval_surv_base_fun(ti, omega, b_func, gl_dat = get_gl_rule(30L), delta = NULL)

Arguments

ti

numeric vector with time points.

omega

numeric vector with coefficients for the baseline hazard.

b_func

basis function for the baseline hazard like poly.

gl_dat

Gauss–Legendre quadrature data. See get_gl_rule.

delta

offset on the log hazard scale. Use NULL if there is no effect.

Examples

# 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")

SimSurvNMarker documentation built on Nov. 10, 2022, 5:12 p.m.