eval_surv_base_fun: Evaluates the Survival Function without a Marker

Description Usage Arguments Examples

View source: R/sim.R

Description

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

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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 Jan. 8, 2021, 2:05 a.m.