SurvEval: Evaluate whether a true survival function is contained in the...

Description Usage Arguments Value References See Also Examples

View source: R/SurvEval.R

Description

This function is intended to evaluate the Bayesian procedure in a simulation study. To that end, this function can be used to check whether the true (user-defined) survival function is contained in the credible set generated by the function BayesSurv.

Usage

1
SurvEval(time.grid, true.surv, post.mean, radius)

Arguments

time.grid

The time grid on which to evaluate the survival function.

true.surv

The true survival function.

post.mean

The posterior mean of the survival function, given as a function.

radius

The radius of the credible set for the survival function

Value

covered

Indicator whether the true survival function is completely covered by the credible set on the times contained in time.grid. 0 = not completely covered, 1 = completely covered.

References

Castillo and Van der Pas (2020). Multiscale Bayesian survival analysis. <arXiv:2005.02889>.

See Also

BayesSurv, which computes the posterior mean of the survival function as well as the radius for its credible set.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#Demonstration on a simulated data set
library(simsurv)
library(ggplot2)
hazard.true <- function(t,x, betas, ...){1.2*(5*(t+0.05)^3 - 10*(t+0.05)^2 + 5*(t+0.05) ) + 0.7}
cumhaz.true <- Vectorize( function(t){integrate(hazard.true, 0, t)$value} )
surv.true <- function(t){exp(-cumhaz.true(t))}

sim.df <- data.frame(id = 1:1000)
df <- simsurv(x = sim.df, maxt = 1, hazard = hazard.true)

bs <- BayesSurv(df, "eventtime", "status")
surv.pm <- approxfun(bs$surv.eval.grid, bs$surv.post.mean)
SurvEval(bs$surv.eval.grid, surv.true, surv.pm, bs$surv.radius)

BayesSurvival documentation built on March 13, 2021, 1:07 a.m.