exchangeSPsurv {BayesSPsurv}R Documentation

exchangeSPsurv

Description

Markov Chain Monte Carlo (MCMC) to run Bayesian split population survival model with exchangeable frailties.

Returns a summary of a exchangeSPsurv object via summary.mcmc.

Print method for a exchangeSPsurv x.

Returns a plot of a exchangeSPsurv object via plot.mcmc.

Usage

exchangeSPsurv(
  duration,
  immune,
  Y0,
  LY,
  S,
  data,
  N,
  burn,
  thin,
  w = c(1, 1, 1),
  m = 10,
  ini.beta = 0,
  ini.gamma = 0,
  ini.W = 0,
  ini.V = 0,
  form = c("Weibull", "exponential", "loglog"),
  prop.varV,
  prop.varW,
  id_WV = unique(data[, S])
)

## S3 method for class 'frailtySPsurv'
summary(object, parameter = character(), ...)

## S3 method for class 'frailtySPsurv'
print(x, ...)

## S3 method for class 'frailtySPsurv'
plot(x, parameter = character(), ...)

Arguments

duration

survival stage equation written in a formula of the form Y ~ X1 + X2 + ... where Y is duration until failure or censoring.

immune

split stage equation written in a formula of the form C ~ Z1 + Z2 + ... where C is a binary indicator of immunity.

Y0

the elapsed time since inception until the beginning of time period (t-1).

LY

last observation year (coded as 1; 0 otherwise) due to censoring or failure.

S

spatial information (e.g. district ID) for each observation that matches the spatial matrix row/column information.

data

data.frame.

N

number of MCMC iterations.

burn

burn-in to be discarded.

thin

thinning to prevent from autocorrelation.

w

size of the slice in the slice sampling for (betas, gammas, rho). Write it as a vector. E.g. c(1,1,1).

m

limit on steps in the slice sampling. A vector of values for beta, gamma, rho.

ini.beta

initial value for the parameter vector beta. By default is 0.

ini.gamma

initial value for the parameter vector gamma. By default is 0.

ini.W

initial value for the parameter vector W. By default is 0.

ini.V

initial value for the parameter vector V. By default is 0.

form

type of parametric model (Weibull, Exponential, or Log-Logistic).

prop.varV

proposed variance for V in Metropolis-Hastings.

prop.varW

proposed variance for W in Metropolis-Hastings.

id_WV

vector of type character that modifies the colnames of W and V in the model’s result. By default is unique(data[,S]).

object

an object of class frailtySPsurv, the output of exchangeSPsurv.

parameter

one of five parameters of the spatialSPsurv output. Indicate either "betas," "gammas," "rho", "lambda" or "delta".

...

additional parameter.

x

an object of class frailtySPsurv, the output of exchangeSPsurv.

Value

exchangeSPsurv returns an object of class "frailtySPsurv".

An "exchangeSPsurv" object has the following elements:

betas

matrix, numeric values of the posterior for each variable in the duration equation .

gammas

matrix, numeric values of the posterior for each variable in the immune equation.

rho

vector, numeric values of rho.

lambda

vector, numeric values of lambda.

delta

vector, numeric values of delta.

W

matrix, numeric values of the posterior for Ws.

V

matrix, numeric values of the posterior for Vs.

X

matrix of X's variables.

Z

matrix of Z's variables.

Y

vector of ‘Y’.

Y0

vector of ‘Y0’.

C

vector of ‘C’.

S

vector of ‘S’.

ini.beta

numeric initial values of beta.

ini.gamma

numeric initial values of gamma.

ini.W

numeric initial values of W.

ini.V

numeric initial values of V.

form

character, type of distribution.

call

description for the model to be estimated.

list. Empirical mean, standard deviation and quantiles for each variable.

list. Empirical mean, standard deviation and quantiles for each variable.

Examples




## 1

walter <- spduration::add_duration(Walter_2015_JCR,"renewed_war",
                                   unitID = "ccode", tID = "year",
                                   freq = "year", ongoing = FALSE)

# add S
walter <- spatial_SA(data = walter, var_ccode = "ccode", threshold = 800L)

set.seed(123456)

model <-
    exchangeSPsurv(
           duration  = duration ~ fhcompor1 + lgdpl + comprehensive + victory +
                       instabl + intensityln + ethfrac + unpko,
           immune    = cured ~ fhcompor1 + lgdpl + victory,
           Y0        = 't.0',
           LY        = 'lastyear',
           S         = 'sp_id' ,
           data      = walter[[1]],
           N         = 100,
           burn      = 10,
           thin      = 10,
           w         = c(1,1,1),
           m         = 10,
           form      = "Weibull",
           prop.varV = 1e-05,
           prop.varW = 1e-05,
)

print(model)

summary(model, parameter = "betas")

# plot(model)


## 2

walter   <- spduration::add_duration(Walter_2015_JCR,"renewed_war",
                                   unitID = "ccode", tID = "year",
                                   freq = "year", ongoing = FALSE)

walter$S <- rep(x = 1:length(unique(walter$ccode)), times = rle(walter$ccode)$lengths)
country  <- countrycode::countrycode(unique(walter$ccode),'gwn','iso3c')

set.seed(123456)

model <-
    exchangeSPsurv(
        duration  = duration ~ fhcompor1 + lgdpl + comprehensive + victory +
                    instabl + intensityln + ethfrac + unpko,
        immune    = cured ~ fhcompor1 + lgdpl + victory,
        Y0        = 't.0',
        LY        = 'lastyear',
        S         = 'S' ,
        data      = walter,
        N         = 100,
        burn      = 10,
        thin      = 10,
        w         = c(1,1,1),
        m         = 10,
        form      = "loglog",
        prop.varV = 1e-05,
        prop.varW = 1e-05,
        id_WV     = country
    )

print(model)



[Package BayesSPsurv version 0.1.4 Index]