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 |
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).
data(Buhaugetal_2009_JCR)
data(Buhaugetal_2009_JCR)
A data frame with 1562 rows and 13 variables
log conflict-capital distance.
conflict zone at border.
confbord * lndistx centred.
rebel fighting capacity at least moderate.
gdp capita in onset year.
Gates et al. (2006) SIP code (1 year lag) for the onset year.
post cold war period, 1989+.
percentage of forest in conflict zone.
percentage of mountains in conflict zone.
conflict duration.
elapsed time since inception to Y (t-1).
censoring variable.
coup d'etat, except if overlapping with other gov't conflict (PHI 1989).
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
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
.
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"), ...)
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"), ...)
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 |
parameter |
one of three parameters of the mfsurv output. Indicate either "betas" or "rho". |
... |
additional parameter |
chain of the variables of interest.
list. Empirical mean, standard deviation and quantiles for each variable.
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")
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")
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.
mfsurv.stats(object)
mfsurv.stats(object)
object |
an object of class |
list.
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
.
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"), ...)
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"), ...)
object |
an object of class |
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 |
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.
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")
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")
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.
data(RBS)
data(RBS)
A data frame with 1794 rows and 13 variables
inverse of caloric intake
gross domestic product per capita (logged)
interaction calinv*lnlevel
economic growth
presidential regime
effective number of parties
religious fractionalization
ethnic fractionalization
previous democratic episodes
trade openness
years in current democratic episode
years in current democratic episode (lagged)
breakdown of democratic episode
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
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.
stats(object)
stats(object)
object |
an object of class |
list.
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)
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)