Package 'BayesMFSurv'

Title: Bayesian Misclassified-Failure Survival Model
Description: Contains a split population survival estimator that models the misclassification probability of failure versus right-censored events. The split population survival estimator is described in Bagozzi et al. (2019) <doi:10.1017/pan.2019.6>.
Authors: Minnie M. Joo [aut], Nicolas Schmidt [aut, cre], Sergio Bejar [aut], Vineeta Yadav [aut], Bumba Mukherjee [aut], Benjamin Bagozzi [ctb]
Maintainer: Nicolas Schmidt <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2025-02-28 04:31:34 UTC
Source: https://github.com/nicolas-schmidt/bayesmfsurv

Help Index


Buhaugetal_2009_JCR

Description

Subsetted version of survival database extracted from Buhaug et al. (2009). It has precisely dated duration data of internal conflict as well as geographic data. Variables Y, Y0 and C were later added by Bagozzi et al. (2019). It is used to estimate the Bayesian Misclassified Failure (MF) Weibull model presented in Bagozzi et al. (2019).

Usage

data(Buhaugetal_2009_JCR)

Format

A data frame with 1562 rows and 13 variables

Details

lndistx

log conflict-capital distance.

confbord

conflict zone at border.

borddist

confbord * lndistx centred.

figcapdum

rebel fighting capacity at least moderate.

lgdp_onset

gdp capita in onset year.

sip2l_onset

Gates et al. (2006) SIP code (1 year lag) for the onset year.

pcw

post cold war period, 1989+.

frst

percentage of forest in conflict zone.

mt

percentage of mountains in conflict zone.

Y

conflict duration.

Y0

elapsed time since inception to Y (t-1).

C

censoring variable.

coupx

coup d'etat, except if overlapping with other gov't conflict (PHI 1989).

Source

Buhaug, Halvard, Scott Gates, and Päivi Lujala (2009), Geography, rebel capability, and the duration of civil conflict, Journal of Conflict Resolution 53(4), 544 - 569.


mcmcsurv

Description

mcmcsurv estimates a Bayesian Exponential or Weibull survival model via Markov Chain Monte Carlo (MCMC). Slice samplig is employed to draw the posterior sample of the model's survival stage parameters.

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

Usage

mcmcsurv(Y, Y0, C, X, N, burn, thin, w = c(1, 1, 1), m = 10, form)

## S3 method for class 'mcmcsurv'
summary(object, parameter = c("betas", "rho"), ...)

Arguments

Y

response variable.

Y0

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

C

censoring indicator.

X

covariates for betas.

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

m

limit on steps in the slice sampling.

form

type of parametric model (Exponential or Weibull).

object

an object of class mfsurv, the output of mfsurv.

parameter

one of three parameters of the mfsurv output. Indicate either "betas" or "rho".

...

additional parameter

Value

chain of the variables of interest.

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

Examples

set.seed(95)
bgl <- Buhaugetal_2009_JCR
bgl <- subset(bgl, coupx == 0)
bgl <- na.omit(bgl)
Y   <- bgl$Y
X   <- as.matrix(cbind(1, bgl[,1:7]))
C   <- bgl$C
Y0  <- bgl$Y0
model2 <- mcmcsurv(Y = Y, Y0 = Y0, C =  C,  X = X,
                   N = 50,
                   burn = 20,
                   thin = 15,
                   w = c(0.5, 0.5, 0.5),
                   m = 5,
                   form = "Weibull")

summary(model2, parameter = "betas")

mfsurv.stats

Description

A function to calculate the deviance information criterion (DIC) for fitted model objects of class mfsurv for which a log-likelihood can be obtained, according to the formula DIC = -2 * (L - P), where L is the log likelihood of the data given the posterior means of the parameter and P is the estimate of the effective number of parameters in the model.

Usage

mfsurv.stats(object)

Arguments

object

an object of class mfsurv, the output of mfsurv().

Value

list.


summary.mfsurv

Description

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

mfsurv fits a parametric Bayesian MF model via Markov Chain Monte Carlo (MCMC) to estimate the misclassification in the first stage and the hazard in the second stage. Slice sampling is employed to draw the posterior sample of the model's split and survival stage parameters.

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

Usage

mfsurv.summary(object, parameter)

mfsurv(
  formula,
  Y0,
  data = list(),
  N,
  burn,
  thin,
  w = c(1, 1, 1),
  m = 10,
  form = c("Weibull", "Exponential"),
  na.action = c("na.omit", "na.fail")
)

## S3 method for class 'mfsurv'
summary(object, parameter = c("betas", "gammas", "lambda"), ...)

Arguments

object

an object of class mfsurv, the output of mfsurv.

parameter

one of three parameters of the mfsurv output. Indicate either "betas", "gammas" or "lambda".

formula

a formula in the form Y ~ X1 + X2... | C ~ Z1 + Z2 ... where Y is the duration until failure or censoring, and C is a binary indicator of observed failure.

Y0

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

data

list object of data.

N

number of MCMC iterations.

burn

burn-ins to be discarded.

thin

thinning to prevent autocorrelation of chain of samples by only taking the n-th values.

w

size of the slice in the slice sampling for (betas, gammas, lambda). The default is c(1,1,1). This value may be changed by the user to meet one's needs.

m

limit on steps in the slice sampling. The default is 10. This value may be changed by the user to meet one's needs.

form

type of parametric model distribution to be used. Options are "Exponential" or "Weibull". The default is "Weibull".

na.action

a function indicating what should happen when NAs are included in the data. Options are "na.omit" or "na.fail". The default is "na.omit".

...

additional parameter

Value

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

mfsurv returns an object of class "mfsurv".

A "mfsurv" object has the following elements:

Y

the vector of ‘Y’.

Y0

the vector of ‘Y0’.

C

the vector of ‘C’.

X

matrix X's variables.

Z

the vector of ‘Z’.

betas

data.frame, X.intercept and X variables.

gammas

data.frame, Z.intercept and Z variables.

lambda

integer.

post

integer.

iterations

number of MCMC iterations.

burn_in

burn-ins to be discarded.

thinning

integer.

betan

integer, length of posterior sample for betas.

gamman

integer, length of posterior sample for gammas.

distribution

character, type of distribution.

call

the call.

formula

description for the model to be estimated.

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

Examples

set.seed(95)
bgl <- Buhaugetal_2009_JCR
bgl <- subset(bgl, coupx == 0)
bgl <- na.omit(bgl)
Y   <- bgl$Y
X   <- as.matrix(cbind(1, bgl[,1:7]))
C   <- bgl$C
Z1  <- matrix(1, nrow = nrow(bgl))
Y0  <- bgl$Y0
model1 <- mfsurv(Y ~ X | C ~ Z1, Y0 = Y0,
                N = 50,
                burn = 20,
                thin = 15,
                w = c(0.1, .1, .1),
                m = 5,
                form = "Weibull")

RBS

Description

The Reenock, Bernhard and Sobek (2007) dataset uses continuous-time event history techniques to code episodes of democratic breakdown in all democracies from 1961 to 1995. In addition, it provides data on a number of economic and political variables.

Usage

data(RBS)

Format

A data frame with 1794 rows and 13 variables

Details

calinv

inverse of caloric intake

lnlevel

gross domestic product per capita (logged)

calileve

interaction calinv*lnlevel

necon

economic growth

presi

presidential regime

tag

effective number of parties

rel

religious fractionalization

ethn

ethnic fractionalization

prevdem

previous democratic episodes

openc

trade openness

Y

years in current democratic episode

Y0

years in current democratic episode (lagged)

C

breakdown of democratic episode

Source

Reenock, Christopher, Bernhard, Michael, Sobek, David (2007), Regressive Socioeconomic Distribution and Democratic Survival, International Studies Quarterly, Volume 51, Issue 3, September 2007, Pages 677–699


mfsurv.stats

Description

A function to calculate the deviance information criterion (DIC) for fitted model objects of class mfsurv for which a log-likelihood can be obtained, according to the formula DIC = -2 * (L - P), where L is the log likelihood of the data given the posterior means of the parameter and P is the estimate of the effective number of parameters in the model.

Usage

stats(object)

Arguments

object

an object of class mfsurv, the output of mfsurv().

Value

list.

Examples

set.seed(95)
bgl <- Buhaugetal_2009_JCR
bgl <- subset(bgl, coupx == 0)
bgl <- na.omit(bgl)
Y   <- bgl$Y
X   <- as.matrix(cbind(1, bgl[,1:7]))
C   <- bgl$C
Z1  <- matrix(1, nrow = nrow(bgl))
Y0  <- bgl$Y0
model1 <- mfsurv(Y ~ X | C ~ Z1, Y0 = Y0,
                N = 50,
                burn = 20,
                thin = 15,
                w = c(0.1, .1, .1),
                m = 5,
                form = "Weibull",
                na.action = 'na.omit')

stats(model1)