Package 'BayesReversePLLH'

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

Help Index


Returns the approximate restricted posterior mean survival for the PLLH model.

Description

Uses a grid and parameter values to approximate the restricted posterior mean survival for the PLLH model using the integral of the survival function.

Usage

ApproxMean(Y, s, lam, J)

Arguments

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.

Value

Returns the approximate restricted posterior mean survival time for the PLLH model.

Examples

##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 PEH model without covariates.

Description

Samples from the Piecewise Exponential Hazard (PEH) model and returns a list containing posterior parameters and posterior restricted mean survival.

Usage

BayesPiecewiseHazard(Y, I1, Poi, B)

Arguments

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.

Value

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.

Examples

##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 PEH Cox model with a patient covariate vector.

Description

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.

Usage

BayesPiecewiseHazardCOV(Y, I1, COV, Poi, B)

Arguments

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.

Value

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.

Examples

##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 PEH Cox model with a patient covariate vector.

Description

Samples from the Piecewise Linear Log-Hazard (PLLH) Cox model and returns a list containing posterior parameters and posterior restricted mean survival.

Usage

BayesPiecewiseHazardTrt(Y, I1, Trt, Poi, B)

Arguments

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.

Value

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.

Examples

##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 PLLH model without covariates.

Description

Samples from the Piecewise Linear Log-Hazard (PLLH) model and returns a list containing posterior parameters and posterior restricted mean survival.

Usage

BayesPiecewiseLinearLogHazard(Y, I1, Poi, B)

Arguments

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.

Value

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.

Examples

##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 PLLH Cox model with a patient covariate vector.

Description

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.

Usage

BayesPiecewiseLinearLogHazardCOV(Y, I1, COV, Poi, B)

Arguments

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.

Value

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.

Examples

##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 PEH Cox model with a treatment indicator.

Description

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.

Usage

BayesPiecewiseLinearLogHazardTrt(Y, I1, Trt, Poi, B)

Arguments

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.

Value

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.

Examples

##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)

Description

Computes the posterior distribution of hazard value for a vector x for the Piecewise Linear Log Hazard model (PLLH)

Usage

GetALLHazLogSlope(x, G1)

Arguments

x

Vector of times to compute the posterior mean hazard function

G1

List of posterior samples from the BayesPiecewiseLinearLogHazard function.

Value

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)

Description

Computes the posterior hazard values for a vector x for the Piecewise Exponential Hazard model (PEH)

Usage

GetALLHazPiece(x, G1)

Arguments

x

Vector of times to compute the hazard.

G1

List of posterior samples from the BayesPiecewiseHazard function.

Value

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)

Description

Computes the posterior distribution of survival probabilities for a vector x for the Piecewise Exponential Hazard model (PEH)

Usage

GetALLSurvPEH(x, G1)

Arguments

x

Vector of times to compute the posterior mean survival probability.

G1

List of posterior samples from the BayesPiecewiseLinearHazard function.

Value

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)

Description

Computes posterior distribution of survival probabilities for a vector x for the Piecewise Linear Log Hazard model (PLLH)

Usage

GetALLSurvPLLH(x, G1)

Arguments

x

Vector of times to compute the posterior mean survival probability.

G1

List of posterior samples from the BayesPiecewiseLinearLogHazard function.

Value

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)

Description

Computes the posterior mean hazard value for a vector x for the Piecewise Linear Log Hazard model (PLLH)

Usage

PostMeanHazLogSlope(x, G1)

Arguments

x

Vector of times to compute the posterior mean hazard function

G1

List of posterior samples from the BayesPiecewiseLinearLogHazard function.

Value

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)

Description

Computes the posterior mean hazard values for a vector x for the Piecewise Exponential Hazard model (PEH)

Usage

PostMeanHazPiece(x, G1)

Arguments

x

Vector of times to compute the posterior mean hazard.

G1

List of posterior samples from the BayesPiecewiseHazard function.

Value

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)

Description

Computes the posterior mean survival probabilities for a vector x for the Piecewise Exponential Hazard model (PEH)

Usage

PostMeanSurvPEH(x, G1)

Arguments

x

Vector of times to compute the posterior mean survival probability.

G1

List of posterior samples from the BayesPiecewiseLinearHazard function.

Value

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)

Description

Computes the posterior mean survival probabilities for a vector x for the Piecewise Linear Log Hazard model (PLLH)

Usage

PostMeanSurvPLLH(x, G1)

Arguments

x

Vector of times to compute the posterior mean survival probability.

G1

List of posterior samples from the BayesPiecewiseLinearLogHazard function.

Value

Vector containing the posterior mean survival probabilities S(x)