Package 'BASSLINE'

Title: Bayesian Survival Analysis Using Shape Mixtures of Log-Normal Distributions
Description: Mixtures of life distributions provide a convenient framework for survival analysis: particularly when standard models such as the Weibull are unable to capture some features from the data. These mixtures can also account for unobserved heterogeneity or outlying observations. BASSLINE uses shape mixtures of log-normal distributions and has particular applicability to data with fat tails.
Authors: Catalina Vallejos [aut], Nathan Constantine-Cooke [cre, aut]
Maintainer: Nathan Constantine-Cooke <[email protected]>
License: GPL-3
Version: 0.0.0.9010
Built: 2024-06-15 04:30:39 UTC
Source: https://github.com/nathansam/BASSLINE

Help Index


Convert dataframe with mixed variables to a numeric matrix

Description

BASSLINE's functions require a numeric matrix be provided. This function converts a dataframe of mixed variable types (numeric and factors) to a matrix. A factor with $m$ levels is converted to $m$ columns with binary values used to denote which level the observation belongs to.

Usage

BASSLINE_convert(df)

Arguments

df

A dataframe intended for conversion

Value

A numeric matrix suitable for BASSLINE functions

Examples

library(BASSLINE)
Time <- c(5,15,15)
Cens <- c(1,0,1)
experiment <- as.factor(c("chem1", "chem2", "chem3"))
age <- c(15,35,20)
df <- data.frame(Time, Cens, experiment, age)
converted <- BASSLINE_convert(df)

Outlier detection for observation for the log-Laplace model

Description

This returns a unique number corresponding to the Bayes Factor associated to the test M0:Λobs=λrefM_0: \Lambda_{obs} = \lambda_{ref} versus M1:ΛobsλrefM_1: \Lambda_{obs}\neq \lambda_{ref} (with all other Λj,obs\Lambda_j,\neq obs free). The value of λref\lambda_{ref} is required as input. The user should expect long running times for the log-Student’s t model, in which case a reduced chain given Λobs=λref\Lambda_{obs} = \lambda_{ref} needs to be generated

Usage

BF_lambda_obs_LLAP(obs, ref, X, chain)

Arguments

obs

Indicates the number of the observation under analysis

ref

Reference value λref\lambda_{ref} or urefu_{ref}

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function updates

Examples

#' library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLAP <- MCMC_LLAP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLAP.outlier <- BF_lambda_obs_LLAP(1,1, X = cancer[, 3:11], chain = LLAP)

Outlier detection for observation for the log-logistic model

Description

This returns a unique number corresponding to the Bayes Factor associated to the test M0:Λobs=λrefM_0: \Lambda_{obs} = \lambda_{ref} versus M1:ΛobsλrefM_1: \Lambda_{obs}\neq \lambda_{ref} (with all other Λj,obs\Lambda_j,\neq obs free). The value of λref\lambda_{ref} is required as input. The user should expect long running times for the log-Student’s t model, in which case a reduced chain given Λobs=λref\Lambda_{obs} = \lambda_{ref} needs to be generated

Usage

BF_lambda_obs_LLOG(ref, obs, X, chain)

Arguments

ref

Reference value λref\lambda_{ref} or urefu_{ref}

obs

Indicates the number of the observation under analysis

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLOG <- MCMC_LLOG(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLOG.Outlier <- BF_lambda_obs_LLOG(1,1, X = cancer[, 3:11], chain = LLOG)

Outlier detection for observation for the log-student's t model

Description

This returns a unique number corresponding to the Bayes Factor associated to the test M0:Λobs=λrefM_0: \Lambda_{obs} = \lambda_{ref} versus M1:ΛobsλrefM_1: \Lambda_{obs}\neq \lambda_{ref} (with all other Λj,obs\Lambda_j,\neq obs free). The value of λref\lambda_{ref} is required as input. The user should expect long running times for the log-Student’s t model, in which case a reduced chain given Λobs=λref\Lambda_{obs} = \lambda_{ref} needs to be generated

Usage

BF_lambda_obs_LST(
  N,
  thin,
  burn,
  ref,
  obs,
  Time,
  Cens,
  X,
  chain,
  Q = 1,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5,
  ar = 0.44
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period

ref

Reference value λref\lambda_{ref} or urefu_{ref}

obs

Indicates the number of the observation under analysis

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

Q

Update period for the λi\lambda_{i}’s

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

ar

Optimal acceptance rate for the adaptive Metropolis-Hastings updates

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LST <- MCMC_LST(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])

LST.Outlier <- BF_lambda_obs_LST(N = 100, thin = 20 , burn = 1, ref = 1,
                                 obs = 1, Time = cancer[, 1],
                                 Cens = cancer[, 2], X = cancer[, 3:11],
                                 chain = LST)

Outlier detection for observation for the log-exponential power model

Description

This returns a unique number corresponding to the Bayes Factor associated to the test M0:Λobs=λrefM_0: \Lambda_{obs} = \lambda_{ref} versus M1:ΛobsλrefM_1: \Lambda_{obs}\neq \lambda_{ref} (with all other Λj,obs\Lambda_j,\neq obs free). The value of λref\lambda_{ref} is required as input. The user should expect long running times for the log-Student’s t model, in which case a reduced chain given Λobs=λref\Lambda_{obs} = \lambda_{ref} needs to be generated

Usage

BF_u_obs_LEP(
  N,
  thin,
  burn,
  ref,
  obs,
  Time,
  Cens,
  X,
  chain,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5,
  ar = 0.44
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period

ref

Reference value urefu_{ref}. Vallejos & Steel recommends this value be set to 1.6+1α1.6 +1_\alpha for the LEP model.

obs

Indicates the number of the observation under analysis

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

ar

Optimal acceptance rate for the adaptive Metropolis-Hastings updates

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations (especially for the log-exponential power model).

LEP <- MCMC_LEP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])
alpha <- mean(LEP[, 11])
uref <- 1.6 + 1 / alpha
LEP.Outlier <- BF_u_obs_LEP(N = 100, thin = 20, burn =1 , ref = uref,
                            obs = 1, Time = cancer[, 1], Cens = cancer[, 2],
                            cancer[, 3:11], chain = LEP)

VA Lung Cancer Trial Dataset

Description

Data from a trial in which a therapy (standard or test chemotherapy) was randomly applied to 137 patients who were diagnosed with inoperable lung cancer. The survival times of the patients were measured in days since treatment.

Usage

cancer

Format

A matrix with 137 rows and 8 variables:

Time

Survival time (in days)

Cens

0 or 1. If 0 the observation is right censored

Intercept

The intercept

Treat

The treatment applied to the patient (0: standard, 1: test)

Type.1

The histological type of the tumor (1: type 1, 0: otherwise)

Type.2

The histological type of the tumor (1: type 2, 0: otherwise)

Type.3

The histological type of the tumor (1: type 3, 0: otherwise)

Status

A continuous index representing the status of the patient: 10—30 completely hospitalized, 40—60 partial confinement, 70—90 able to care for self.

MFD

The time between the diagnosis and the treatment (in months)

Age

Age (in years)

Prior

Prior therapy, 0 or 10

Source

Appendix I of Kalbfleisch and Prentice (1980).


Case deletion analysis for the log-exponential power model

Description

Leave-one-out cross validation analysis. The function returns a matrix with n rows. The first column contains the logarithm of the CPO (Geisser and Eddy, 1979). Larger values of the CPO indicate better predictive accuracy of the model. The second and third columns contain the KL divergence between π(β,σ2,θti)\pi(\beta, \sigma^2, \theta | t_{-i}) and π(β,σ2,θt)\pi(\beta, \sigma^2, \theta | t) and its calibration index pip_i, respectively.

Usage

CaseDeletion_LEP(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations (especially for the log-exponential power model).

LEP <- MCMC_LEP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])
LEP.CD <- CaseDeletion_LEP(Time = cancer[, 1], Cens = cancer[, 2],
                           X = cancer[, 3:11], chain = LEP)

Case deletion analysis for the log-Laplace model

Description

Leave-one-out cross validation analysis. The function returns a matrix with n rows. The first column contains the logarithm of the CPO (Geisser and Eddy, 1979). Larger values of the CPO indicate better predictive accuracy of the model. The second and third columns contain the KL divergence between π(β,σ2,θti)\pi(\beta, \sigma^2, \theta | t_{-i}) and π(β,σ2,θt)\pi(\beta, \sigma^2, \theta | t) and its calibration index pip_i, respectively.

Usage

CaseDeletion_LLAP(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLAP <- MCMC_LLAP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLAP.CD <- CaseDeletion_LLAP(Time = cancer[, 1], Cens = cancer[, 2],
                             X = cancer[, 3:11], chain = LLAP)

Case deletion analysis for the log-logistic model

Description

Leave-one-out cross validation analysis. The function returns a matrix with n rows. The first column contains the logarithm of the CPO (Geisser and Eddy, 1979). Larger values of the CPO indicate better predictive accuracy of the model. The second and third columns contain the KL divergence between π(β,σ2,θti)\pi(\beta, \sigma^2, \theta | t_{-i}) and π(β,σ2,θt)\pi(\beta, \sigma^2, \theta | t) and its calibration index pip_i, respectively.

Usage

CaseDeletion_LLOG(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLOG <- MCMC_LLOG(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLOG.CD <- CaseDeletion_LLOG(Time = cancer[, 1], Cens = cancer[, 2],
                             X = cancer[, 3:11], chain = LLOG)

Case deletion analysis for the log-normal model

Description

Leave-one-out cross validation analysis. The function returns a matrix with n rows. The first column contains the logarithm of the CPO (Geisser and Eddy, 1979). Larger values of the CPO indicate better predictive accuracy of the model. The second and third columns contain the KL divergence between π(β,σ2,θti)\pi(\beta, \sigma^2, \theta | t_{-i}) and π(β,σ2,θt)\pi(\beta, \sigma^2, \theta | t) and its calibration index pip_i, respectively.

Usage

CaseDeletion_LN(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.LM

LN <- MCMC_LN(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
              Cens = cancer[, 2], X = cancer[, 3:11])
LN.CD <- CaseDeletion_LN(Time = cancer[, 1], Cens = cancer[, 2],
                         X = cancer[, 3:11], chain = LN)

Case deletion analysis for the log-student's t model

Description

Leave-one-out cross validation analysis. The function returns a matrix with n rows. The first column contains the logarithm of the CPO (Geisser and Eddy, 1979). Larger values of the CPO indicate better predictive accuracy of the model. The second and third columns contain the KL divergence between π(β,σ2,θti)\pi(\beta, \sigma^2, \theta | t_{-i}) and π(β,σ2,θt)\pi(\beta, \sigma^2, \theta | t) and its calibration index pip_i, respectively.

Usage

CaseDeletion_LST(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LST <- MCMC_LST(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])
LST.CD <- CaseDeletion_LST(Time = cancer[, 1], Cens = cancer[, 2],
                           cancer[, 3:11], chain = LST)

Deviance information criterion for the log-exponential power model

Description

Deviance information criterion is based on the deviance function D(θ,y)=2log(f(yθ))D(\theta, y) = -2 log(f(y|\theta)) but also incorporates a penalization factor of the complexity of the model

Usage

DIC_LEP(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations (especially for the log-exponential power model).

LEP <- MCMC_LEP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])
LEP.DIC <- DIC_LEP(Time = cancer[, 1], Cens = cancer[, 2],
                   X = cancer[, 3:11], chain = LEP)

Deviance information criterion for the log-Laplace model

Description

Deviance information criterion is based on the deviance function D(θ,y)=2log(f(yθ))D(\theta, y) = -2 log(f(y|\theta)) but also incorporates a penalization factor of the complexity of the model

Usage

DIC_LLAP(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLAP <- MCMC_LLAP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLAP.DIC <- DIC_LLAP(Time = cancer[, 1], Cens = cancer[, 2],
                     X = cancer[, 3:11], chain = LLAP)

Deviance information criterion for the log-logistic model

Description

Deviance information criterion is based on the deviance function D(θ,y)=2log(f(yθ))D(\theta, y) = -2 log(f(y|\theta)) but also incorporates a penalization factor of the complexity of the model

Usage

DIC_LLOG(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLOG <- MCMC_LLOG(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLOG.DIC <- DIC_LLOG(Time = cancer[, 1], Cens = cancer[, 2],
                     X = cancer[, 3:11], chain = LLOG)

Deviance information criterion for the log-normal model

Description

Deviance information criterion is based on the deviance function D(θ,y)=2log(f(yθ))D(\theta, y) = -2 log(f(y|\theta)) but also incorporates a penalization factor of the complexity of the model

Usage

DIC_LN(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.LM

LN <- MCMC_LN(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
              Cens = cancer[, 2], X = cancer[, 3:11])
LN.DIC <- DIC_LN(Time = cancer[, 1], Cens = cancer[, 2], X = cancer[, 3:11],
                 chain = LN)

Deviance information criterion for the log-student's t model

Description

Deviance information criterion is based on the deviance function D(θ,y)=2log(f(yθ))D(\theta, y) = -2 log(f(y|\theta)) but also incorporates a penalization factor of the complexity of the model

Usage

DIC_LST(Time, Cens, X, chain, set = TRUE, eps_l = 0.5, eps_r = 0.5)

Arguments

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LST <- MCMC_LST(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])
LST.DIC <- DIC_LST(Time = cancer[, 1], Cens = cancer[, 2],
                   X = cancer[, 3:11], chain = LST)

Log-marginal likelihood estimator for the log-exponential power model

Description

Log-marginal likelihood estimator for the log-exponential power model

Usage

LML_LEP(
  thin,
  Time,
  Cens,
  X,
  chain,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5
)

Arguments

thin

Thinning period.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=100 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations (especially for the log-exponential power model).

LEP <- MCMC_LEP(N = 100, thin = 2, burn = 20, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])
LEP.LML <- LML_LEP(thin = 2, Time = cancer[, 1], Cens = cancer[, 2],
                   X = cancer[, 3:11], chain = LEP)

Log-marginal likelihood estimator for the log-Laplace model

Description

Log-marginal likelihood estimator for the log-Laplace model

Usage

LML_LLAP(
  thin,
  Time,
  Cens,
  X,
  chain,
  Q = 1,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5
)

Arguments

thin

Thinning period.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

Q

Update period for the λi\lambda_{i}’s

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLAP <- MCMC_LLAP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])

Log-marginal likelihood estimator for the log-logistic model

Description

Log-marginal likelihood estimator for the log-logistic model

Usage

LML_LLOG(
  thin,
  Time,
  Cens,
  X,
  chain,
  Q = 10,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5,
  N.AKS = 3
)

Arguments

thin

Thinning period.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

Q

Update period for the λi\lambda_{i}’s

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

N.AKS

Maximum number of terms of the Kolmogorov-Smirnov density used for the rejection sampling when updating mixing parameters (default value: 3)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLOG <- MCMC_LLOG(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])
LLOG.LML <- LML_LLOG(thin = 20, Time = cancer[, 1], Cens = cancer[, 2],
                     X = cancer[, 3:11], chain = LLOG)

Log-marginal Likelihood estimator for the log-normal model

Description

Log-marginal Likelihood estimator for the log-normal model

Usage

LML_LN(
  thin,
  Time,
  Cens,
  X,
  chain,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5
)

Arguments

thin

Thinning period.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.LM

LN <- MCMC_LN(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
              Cens = cancer[, 2], X = cancer[, 3:11])
LN.LML <- LML_LN(thin = 20, Time = cancer[, 1], Cens = cancer[, 2],
                         X = cancer[, 3:11], chain = LN)

Log-marginal Likelihood estimator for the log-student's t model

Description

Log-marginal Likelihood estimator for the log-student's t model

Usage

LML_LST(
  thin,
  Time,
  Cens,
  X,
  chain,
  Q = 1,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5
)

Arguments

thin

Thinning period.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

chain

MCMC chains generated by a BASSLINE MCMC function

Q

Update period for the λi\lambda_{i}’s

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LST <- MCMC_LST(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])

LST.LML <- LML_LST(thin = 20, Time = cancer[, 1], Cens = cancer[, 2],
                   X = cancer[, 3:11], chain = LST)

MCMC algorithm for the log-exponential power model

Description

Adaptive Metropolis-within-Gibbs algorithm with univariate Gaussian random walk proposals for the log-exponential model

Usage

MCMC_LEP(
  N,
  thin,
  burn,
  Time,
  Cens,
  X,
  beta0 = NULL,
  sigma20 = NULL,
  alpha0 = NULL,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5,
  ar = 0.44
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period. Must be a multiple of thin.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

beta0

Starting values for β\beta. If not provided, they will be randomly generated from a normal distribution.

sigma20

Starting value for σ2\sigma^2. If not provided, it will be randomly generated from a gamma distribution.

alpha0

Starting value for α\alpha. If not provided, then it will be randomly generated from a uniform distribution.

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

ar

Optimal acceptance rate for the adaptive Metropolis-Hastings updates

Value

A matrix with N/thin+1N / thin + 1 rows. The columns are the MCMC chains for β\beta (kk columns), σ2\sigma^2 (1 column), θ\theta (1 column, if appropriate), uu (nn columns, not provided for log-normal model), log(t)\log(t) (nn columns, simulated via data augmentation) and the logarithm of the adaptive variances (the number varies among models). The latter allows the user to evaluate if the adaptive variances have been stabilized.

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations (especially for the log-exponential power model).

LEP <- MCMC_LEP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])

MCMC algorithm for the log-Laplace model

Description

Adaptive Metropolis-within-Gibbs algorithm with univariate Gaussian random walk proposals for the log-Laplace model

Usage

MCMC_LLAP(
  N,
  thin,
  burn,
  Time,
  Cens,
  X,
  Q = 1,
  beta0 = NULL,
  sigma20 = NULL,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period. Must be a multiple of thin.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

Q

Update period for the λi\lambda_{i}’s

beta0

Starting values for β\beta. If not provided, they will be randomly generated from a normal distribution.

sigma20

Starting value for σ2\sigma^2. If not provided, it will be randomly generated from a gamma distribution.

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Value

A matrix with N/thin+1N / thin + 1 rows. The columns are the MCMC chains for β\beta (kk columns), σ2\sigma^2 (1 column), θ\theta (1 column, if appropriate), λ\lambda (nn columns, not provided for log-normal model), log(t)\log(t) (nn columns, simulated via data augmentation) and the logarithm of the adaptive variances (the number varies among models). The latter allows the user to evaluate if the adaptive variances have been stabilized.

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLAP <- MCMC_LLAP(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])

MCMC algorithm for the log-logistic model

Description

Adaptive Metropolis-within-Gibbs algorithm with univariate Gaussian random walk proposals for the log-logistic model

Usage

MCMC_LLOG(
  N,
  thin,
  burn,
  Time,
  Cens,
  X,
  Q = 10,
  beta0 = NULL,
  sigma20 = NULL,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5,
  N.AKS = 3
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period. Must be a multiple of thin.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

Q

Update period for the λi\lambda_{i}’s

beta0

Starting values for β\beta. If not provided, they will be randomly generated from a normal distribution.

sigma20

Starting value for σ2\sigma^2. If not provided, it will be randomly generated from a gamma distribution.

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

N.AKS

Maximum number of terms of the Kolmogorov-Smirnov density used for the rejection sampling when updating mixing parameters (default value: 3)

Value

A matrix with N/thin+1N / thin + 1 rows. The columns are the MCMC chains for β\beta (kk columns), σ2\sigma^2 (1 column), θ\theta (1 column, if appropriate), λ\lambda (nn columns, not provided for log-normal model), log(t)\log(t) (nn columns, simulated via data augmentation) and the logarithm of the adaptive variances (the number varies among models). The latter allows the user to evaluate if the adaptive variances have been stabilized.

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LLOG <- MCMC_LLOG(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                  Cens = cancer[, 2], X = cancer[, 3:11])

MCMC algorithm for the log-normal model

Description

Adaptive Metropolis-within-Gibbs algorithm with univariate Gaussian random walk proposals for the log-normal model (no mixture)

Usage

MCMC_LN(
  N,
  thin,
  burn,
  Time,
  Cens,
  X,
  beta0 = NULL,
  sigma20 = NULL,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period. Must be a multiple of thin.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

beta0

Starting values for β\beta. If not provided, they will be randomly generated from a normal distribution.

sigma20

Starting value for σ2\sigma^2. If not provided, it will be randomly generated from a gamma distribution.

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

Value

A matrix with (Nburn)/thin+1(N - burn) / thin + 1 rows. The columns are the MCMC chains for β\beta (kk columns), σ2\sigma^2 (1 column), θ\theta (1 column, if appropriate), log(t)\log(t) (nn columns, simulated via data augmentation) and the logarithm of the adaptive variances (the number varies among models). The latter allows the user to evaluate if the adaptive variances have been stabilized.

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LN <- MCMC_LN(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
              Cens = cancer[, 2], X = cancer[, 3:11])

MCMC algorithm for the log-student's t model

Description

Adaptive Metropolis-within-Gibbs algorithm with univariate Gaussian random walk proposals for the log-student's T model (no mixture)

Usage

MCMC_LST(
  N,
  thin,
  burn,
  Time,
  Cens,
  X,
  Q = 1,
  beta0 = NULL,
  sigma20 = NULL,
  nu0 = NULL,
  prior = 2,
  set = TRUE,
  eps_l = 0.5,
  eps_r = 0.5,
  ar = 0.44
)

Arguments

N

Total number of iterations. Must be a multiple of thin.

thin

Thinning period.

burn

Burn-in period. Must be a multiple of thin.

Time

Vector containing the survival times.

Cens

Censoring indication (1: observed, 0: right-censored).

X

Design matrix with dimensions nn x kk where nn is the number of observations and kk is the number of covariates (including the intercept).

Q

Update period for the λi\lambda_{i}’s

beta0

Starting values for β\beta. If not provided, they will be randomly generated from a normal distribution.

sigma20

Starting value for σ2\sigma^2. If not provided, it will be randomly generated from a gamma distribution.

nu0

Starting value for vv. If not provided, then it will be randomly generated from a gamma distribution.

prior

Indicator of prior (1: Jeffreys, 2: Type I Ind. Jeffreys, 3: Ind. Jeffreys).

set

Indicator for the use of set observations (1: set observations, 0: point observations). The former is strongly recommended over the latter as point observations cause problems in the context of Bayesian inference (due to continuous sampling models assigning zero probability to a point).

eps_l

Lower imprecision (ϵl)(\epsilon_l) for set observations (default value: 0.5).

eps_r

Upper imprecision (ϵr)(\epsilon_r) for set observations (default value: 0.5)

ar

Optimal acceptance rate for the adaptive Metropolis-Hastings updates

Value

A matrix with N/thin+1N / thin + 1 rows. The columns are the MCMC chains for β\beta (kk columns), σ2\sigma^2 (1 column), θ\theta (1 column, if appropriate), λ\lambda (nn columns, not provided for log-normal model), log(t)\log(t) (nn columns, simulated via data augmentation) and the logarithm of the adaptive variances (the number varies among models). The latter allows the user to evaluate if the adaptive variances have been stabilized.

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LST <- MCMC_LST(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
                Cens = cancer[, 2], X = cancer[, 3:11])

Produce a trace plot of a variable's MCMC chain

Description

Plots the chain across (non-discarded) iterations for a specified observation

Usage

Trace_plot(variable = NULL, chain = NULL)

Arguments

variable

Indicates the index of the variable

chain

MCMC chains generated by a BASSLINE MCMC function

Value

A ggplot2 object

Examples

library(BASSLINE)

# Please note: N=1000 is not enough to reach convergence.
# This is only an illustration. Run longer chains for more accurate
# estimations.

LN <- MCMC_LN(N = 1000, thin = 20, burn = 40, Time = cancer[, 1],
              Cens = cancer[, 2], X = cancer[, 3:11])
Trace_plot(1, LN)