sampleSurv: Samples fitted survival function

View source: R/user_utilities.R

sampleSurvR Documentation

Samples fitted survival function

Description

Samples fitted survival function

Usage

sampleSurv(fit, newdata = NULL, p = NULL, q = NULL, samples = 100)

Arguments

fit

Either an ic_bayes or ic_par fit

newdata

A data.frame with a single row of covariates

p

A set of survival probabilities to sample corresponding time for

q

A set of times to sample corresponding cumulative probability for

samples

Number of samples to draw

Details

For Bayesian models, draws samples from the survival distribution with a given set of covariates. Does this by first drawing a set of parameters (both regression and baseline) from fit$samples and then computing the quantiles of the distribution (if p is provided) or the CDF at q.

If a ic_par model is provided, the procedure is the same, but the sampled parameters are drawn using the normal approximation.

Not compatible with ic_np or ic_sp objects.

Author(s)

Clifford Anderson-Bergman

Examples

data("IR_diabetes")
fit <- ic_par(cbind(left, right) ~ gender, data = IR_diabetes)

newdata <- data.frame(gender = "male")
time_samps <- sampleSurv(fit, newdata, 
                         p = c(0.5, .9), 
                         samples = 100)
# 100 samples of the median and 90th percentile for males                        

prob_samps <- sampleSurv(fit, newdata, 
                         q = c(10, 20),
                         samples = 100)
# 100 samples of the cumulative probability at t = 10 and 20 for males                        

icenReg documentation built on May 29, 2024, 5:32 a.m.