Title: | Fits the Bayesian Piecewise Linear Log-Hazard Model |
---|---|
Description: | Contains posterior samplers for the Bayesian piecewise linear log-hazard and piecewise exponential hazard models, including Cox models. Posterior mean restricted survival times are also computed for non-Cox an Cox models with only treatment indicators. The ApproxMean() function can be used to estimate restricted posterior mean survival times given a vector of patient covariates in the Cox model. Functions included to return the posterior mean hazard and survival functions for the piecewise exponential and piecewise linear log-hazard models. Chapple, AG, Peak, T, Hemal, A (2020). Under Revision. |
Authors: | Andrew G Chapple |
Maintainer: | Andrew G Chapple <[email protected]> |
License: | GPL-2 |
Version: | 1.5 |
Built: | 2024-12-18 06:27:35 UTC |
Source: | CRAN |
Uses a grid and parameter values to approximate the restricted posterior mean survival for the PLLH model using the integral of the survival function.
ApproxMean(Y, s, lam, J)
ApproxMean(Y, s, lam, J)
Y |
Sequence from 0.01 to the maximum observed event time used to compute the approximate restricted mean survival time. Smaller spaced sequences results in better approximation but longer computation time. |
s |
Vector of split points. The first and last entries must be 0 and max(Y). |
lam |
Vector of log-hazard values at each split point location. Must be same length as s. |
J |
Number of split points. |
Returns the approximate restricted posterior mean survival time for the PLLH model.
##Generate Data Y1=rweibull(100,4,1) ##Create sequence from (0,max(Y1)) for approximation Y=seq(.01,max(Y1),.01) ##Parameters used to approximate the mean s=c(0,1,max(Y1)) lam=c(-2,0,-2) J=1 ApproxMean( Y, s, lam, J)
##Generate Data Y1=rweibull(100,4,1) ##Create sequence from (0,max(Y1)) for approximation Y=seq(.01,max(Y1),.01) ##Parameters used to approximate the mean s=c(0,1,max(Y1)) lam=c(-2,0,-2) J=1 ApproxMean( Y, s, lam, J)
Samples from the Piecewise Exponential Hazard (PEH) model and returns a list containing posterior parameters and posterior restricted mean survival.
BayesPiecewiseHazard(Y, I1, Poi, B)
BayesPiecewiseHazard(Y, I1, Poi, B)
Y |
Vector of event or censoring times. |
I1 |
Vector of event indicators. |
Poi |
Prior mean number of split points. |
B |
Number of iterations for MCMC. |
Returns a list containing posterior samples of (1) the split point locations, (2) the log-hazards at each split point, (3) the number of split points, (4) the variance parameter for the log-hazard values, (5) the posterior mean restricted survivial time.
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseHazard( Y, I, Poi, B)
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseHazard( Y, I, Poi, B)
Samples from the Piecewise Exponential Hazard (PEH) Cox model with a patient covariate vector and returns a list containing posterior parameters and posterior restricted mean survival.
BayesPiecewiseHazardCOV(Y, I1, COV, Poi, B)
BayesPiecewiseHazardCOV(Y, I1, COV, Poi, B)
Y |
Vector of event or censoring times. |
I1 |
Vector of event indicators. |
COV |
Matrix of size nxp containing p patient covariates. |
Poi |
Prior mean number of split points. |
B |
Number of iterations for MCMC. |
Returns a list containing posterior samples of (1) the split point locations, (2) the log-hazards at each split point, (3) the number of split points, (4) the variance parameter for the log-hazard values, (5) the coefficients in the Cox model.
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) COV = matrix(rnorm(40,0,1),ncol=2) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseHazardCOV( Y, I,COV, Poi, B)
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) COV = matrix(rnorm(40,0,1),ncol=2) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseHazardCOV( Y, I,COV, Poi, B)
Samples from the Piecewise Linear Log-Hazard (PLLH) Cox model and returns a list containing posterior parameters and posterior restricted mean survival.
BayesPiecewiseHazardTrt(Y, I1, Trt, Poi, B)
BayesPiecewiseHazardTrt(Y, I1, Trt, Poi, B)
Y |
Vector of event or censoring times. |
I1 |
Vector of event indicators. |
Trt |
Vector containing patient treatment/control assignment. |
Poi |
Prior mean number of split points. |
B |
Number of iterations for MCMC. |
Returns a list containing posterior samples of (1) the split point locations, (2) the log-hazards at each split point, (3) the number of split points, (4) the variance parameter for the log-hazard values, (5) the treatment coefficient, (6) the mean restricted survivial time of the control therapy, (7) the mean restricted survival time of the treatment therapy.
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) Trt=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseHazardTrt( Y, I,Trt, Poi, B)
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) Trt=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseHazardTrt( Y, I,Trt, Poi, B)
Samples from the Piecewise Linear Log-Hazard (PLLH) model and returns a list containing posterior parameters and posterior restricted mean survival.
BayesPiecewiseLinearLogHazard(Y, I1, Poi, B)
BayesPiecewiseLinearLogHazard(Y, I1, Poi, B)
Y |
Vector of event or censoring times. |
I1 |
Vector of event indicators. |
Poi |
Prior mean number of split points. |
B |
Number of iterations for MCMC. |
Returns a list containing posterior samples of (1) the split point locations, (2) the log-hazards at each split point, (3) the number of split points, (4) the variance parameter for the log-hazard values, (5) the posterior mean restricted survivial time.
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseLinearLogHazard( Y, I, Poi, B)
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseLinearLogHazard( Y, I, Poi, B)
Samples from the Piecewise Linear Log-Hazard (PLLH) Cox model with a patient covariate vector and returns a list containing posterior parameters and posterior restricted mean survival.
BayesPiecewiseLinearLogHazardCOV(Y, I1, COV, Poi, B)
BayesPiecewiseLinearLogHazardCOV(Y, I1, COV, Poi, B)
Y |
Vector of event or censoring times. |
I1 |
Vector of event indicators. |
COV |
Matrix of size nxp containing p patient covariates. |
Poi |
Prior mean number of split points. |
B |
Number of iterations for MCMC. |
Returns a list containing posterior samples of (1) the split point locations, (2) the log-hazards at each split point, (3) the number of split points, (4) the variance parameter for the log-hazard values, (5) the coefficients in the Cox model.
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) COV = matrix(rnorm(40,0,1),ncol=2) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseLinearLogHazardCOV( Y, I,COV, Poi, B)
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) COV = matrix(rnorm(40,0,1),ncol=2) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseLinearLogHazardCOV( Y, I,COV, Poi, B)
Samples from the Piecewise Exponential Hazard (PEH) Cox model with a treatment indicator and returns a list containing posterior parameters and posterior restricted mean survival.
BayesPiecewiseLinearLogHazardTrt(Y, I1, Trt, Poi, B)
BayesPiecewiseLinearLogHazardTrt(Y, I1, Trt, Poi, B)
Y |
Vector of event or censoring times. |
I1 |
Vector of event indicators. |
Trt |
Vector containing patient treatment/control assignment. |
Poi |
Prior mean number of split points. |
B |
Number of iterations for MCMC. |
Returns a list containing posterior samples of (1) the split point locations, (2) the log-hazards at each split point, (3) the number of split points, (4) the variance parameter for the log-hazard values, (5) the treatment coefficient, (6) the mean restricted survivial time of the control therapy, (7) the mean restricted survival time of the treatment therapy.
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) Trt=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseLinearLogHazardTrt( Y, I,Trt, Poi, B)
##Generate Data Y=rweibull(20,4,1) I=rbinom(20,1,.5) Trt=rbinom(20,1,.5) ##Hyperparameter for number of split points Poi=5 ##Number of iterations for MCMC B=200 BayesPiecewiseLinearLogHazardTrt( Y, I,Trt, Poi, B)
Computes the posterior distribution of hazard value for a vector x for the Piecewise Linear Log Hazard model (PLLH)
GetALLHazLogSlope(x, G1)
GetALLHazLogSlope(x, G1)
x |
Vector of times to compute the posterior mean hazard function |
G1 |
List of posterior samples from the BayesPiecewiseLinearLogHazard function. |
Matrix containing the posterior distribution of hazard values h(x)
Computes the posterior hazard values for a vector x for the Piecewise Exponential Hazard model (PEH)
GetALLHazPiece(x, G1)
GetALLHazPiece(x, G1)
x |
Vector of times to compute the hazard. |
G1 |
List of posterior samples from the BayesPiecewiseHazard function. |
Matrix containing the posterior distribution of hazard values h(x)
Computes the posterior distribution of survival probabilities for a vector x for the Piecewise Exponential Hazard model (PEH)
GetALLSurvPEH(x, G1)
GetALLSurvPEH(x, G1)
x |
Vector of times to compute the posterior mean survival probability. |
G1 |
List of posterior samples from the BayesPiecewiseLinearHazard function. |
Matrix containing the posterior distribution of survival probabilities S(x)
Computes posterior distribution of survival probabilities for a vector x for the Piecewise Linear Log Hazard model (PLLH)
GetALLSurvPLLH(x, G1)
GetALLSurvPLLH(x, G1)
x |
Vector of times to compute the posterior mean survival probability. |
G1 |
List of posterior samples from the BayesPiecewiseLinearLogHazard function. |
Matrix containing the posterior distribution survival probabilities S(x)
Computes the posterior mean hazard value for a vector x for the Piecewise Linear Log Hazard model (PLLH)
PostMeanHazLogSlope(x, G1)
PostMeanHazLogSlope(x, G1)
x |
Vector of times to compute the posterior mean hazard function |
G1 |
List of posterior samples from the BayesPiecewiseLinearLogHazard function. |
Vector containing the posterior mean hazard values h(x)
Computes the posterior mean hazard values for a vector x for the Piecewise Exponential Hazard model (PEH)
PostMeanHazPiece(x, G1)
PostMeanHazPiece(x, G1)
x |
Vector of times to compute the posterior mean hazard. |
G1 |
List of posterior samples from the BayesPiecewiseHazard function. |
Vector containing the posterior mean hazard values h(x)
Computes the posterior mean survival probabilities for a vector x for the Piecewise Exponential Hazard model (PEH)
PostMeanSurvPEH(x, G1)
PostMeanSurvPEH(x, G1)
x |
Vector of times to compute the posterior mean survival probability. |
G1 |
List of posterior samples from the BayesPiecewiseLinearHazard function. |
Vector containing the posterior mean survival probabilities S(x)
Computes the posterior mean survival probabilities for a vector x for the Piecewise Linear Log Hazard model (PLLH)
PostMeanSurvPLLH(x, G1)
PostMeanSurvPLLH(x, G1)
x |
Vector of times to compute the posterior mean survival probability. |
G1 |
List of posterior samples from the BayesPiecewiseLinearLogHazard function. |
Vector containing the posterior mean survival probabilities S(x)