Learn R Programming

bayesSurv (version 0.1)

predictive: Compute predictive quantities based on a Bayesian survival regression model.

Description

This function runs additional McMC to compute predictive survivor and hazard curves and predictive event times for specified values of covariates.

Firstly, the function bayessurvreg1 has to be used to obtain a sample from the posterior distribution of unknown quantities.

Directly, posterior predictive quantiles and means of asked quantities are computed and stored in files. Function predictive.control serves only to perform some input checks inside the main function predictive.

Usage

predictive(
     formula,
     random,
     time0 = 0,
     data = parent.frame(),
     grid,
     type,
     subset,
     na.action = na.fail,
     quantile = c(0, 0.025, 0.5, 0.975, 1),                       
     nsimul = list(niter = 10, nwrite = 10),
     predict = list(Et=TRUE, t=FALSE, Surv=TRUE,
                    hazard=FALSE, cum.hazard=FALSE),
     store = list(Et=TRUE, t = FALSE, Surv = FALSE,
                  hazard = FALSE, cum.hazard=FALSE),
     Eb0.depend.mix = FALSE,
     dir = getwd(),
     toler.chol = 1e-10,
     toler.qr = 1e-10,
     ...)

predictive.control(predict, store, quantile)

Arguments

formula
same formula as that one used to sample from the posterior distribution of unknown quantities by the function bayessurvreg1.
random
same random statement as that one used to sample from the posterior distribution of unknown quantities by the function bayessurvreg1.
time0
starting time for the survival model. This option is used to get correct hazard function in the case that the original model was $\log(T-time0) = \dots$.
data
optional data frame in which to interpret the variables occuring in the formulas. Usually, you create a new data.frame similar to that one used to obtain a sample from the posterior distribution. In this new data.frame
grid
a list of length as number of observations in data or a vector giving grids of values where predictive survivor functions, hazards, cumulative hazards are to be evaluated. If it is a vector, same grid is used for all observations
type
a character string giving the type of assumed error distribution. Currently, valid are substrings of "mixture". In the future, "spline", "polya.tree" might be also implemented.
subset
subset of the observations from the data to be used. This option will normally not be needed.
na.action
function to be used to handle any NAs in the data. The user is discouraged to change a default value na.fail.
quantile
a vector of quantiles that are to be computed for each predictive quantity.
nsimul
a list giving the length of the simulation used to sample from posterior predictive distribution. It should be consistent with already simulated values obtained by bayessurvreg1 function.
predict
a list of logical values indicating which predictive quantities are to be sampled. Components of the list: [object Object],[object Object],[object Object],[object Object],[object Object]
store
a list of logical values indicating which predictive quantities are to be stored in files as `predET*.sim', `predT*.sim', `predS*.sim', `predhazard*.sim', `predcumhazard*.sim'. If you are interested only in posterior means or quantiles of the
Eb0.depend.mix
a logical value indicating whether the mean of the random intercept (if included in the model) was given in a hierarchical model as an overall mean of the mixture in the error term. With FALSE (default) you have the same model as
dir
a string giving a directory where previously simulated values were stored and where newly obtained quantities will be stored. On Unix, do not use `~/' to specify your home directory. A full path must be given, e.g. `/home/arnost/'.
toler.chol
tolerance for the Cholesky decomposition.
toler.qr
tolerance for the QR decomposition.
...
who knows?

Value

  • An integer which should be equal to zero if everything ran fine.

Examples

Run this code
## See attached files.

Run the code above in your browser using DataLab