-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
161 lines (108 loc) · 5.78 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
## The `BayesMFSurv` package
_Minnie M. Joo, Nicolas Schmidt, Sergio Bejar, Bumba Mukherjee, Vineeta Yadav_
<!-- badges: start -->
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/BayesMFSurv)](https://cran.r-project.org/package=BayesMFSurv)
`r badger::badge_devel("Nicolas-Schmidt/BayesMFSurv", "blue")`
[![R build status](https://github.com/Nicolas-Schmidt/BayesMFSurv/workflows/R-CMD-check/badge.svg)](https://github.com/Nicolas-Schmidt/BayesMFSurv/actions)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Travis build status](https://travis-ci.com/Nicolas-Schmidt/BayesMFSurv.svg?branch=master)](https://travis-ci.com/Nicolas-Schmidt/BayesMFSurv)
[![CRAN RStudio mirrordownloads](https://cranlogs.r-pkg.org/badges/grand-total/BayesMFSurv?color=blue)](https://www.r-pkg.org/pkg/BayesMFSurv)
[![CRAN RStudio mirrordownloads](https://cranlogs.r-pkg.org/badges/BayesMFSurv?color=blue)](https://www.r-pkg.org/pkg/BayesMFSurv)
[![DOI](https://zenodo.org/badge/226979997.svg)](https://zenodo.org/badge/latestdoi/226979997)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02164/status.svg)](https://doi.org/10.21105/joss.02164)
<!-- badges: end -->
### 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>.
### Installation
You can install the released version (`0.1.0`) of `BayesMFSurv` from [CRAN](https://cran.r-project.org/) with:
``` r
install.packages("BayesMFSurv")
```
And the development version (`0.2.0`) from GitHub with:
``` r
if (!require("remotes")) install.packages("remotes")
remotes::install_github("Nicolas-Schmidt/BayesMFSurv")
```
## Functions
| Function |Description |
| ----------------- | -------------------------------------------------------------- |
|`mfsurv`|fits a parametric Bayesian MF model via Markov Chain Monte Carlo (MCMC) to estimate the probability of 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.|
|`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.|
|`stats`|a function to calculate the deviance information criterion (DIC) and the log-likelihood for fitted model objects of class mfsurv or mcmcsurv.|
|`summary`|returns a summary of a mfsurv or mcmcsurv object via `coda::summary.mcmc`.|
### Example
The data used to estimate the following examples come from Reenock, Bernhard and Sobek (2007) -DOI: 10.111/j.1468-2478.2007.00469.x-. The RBS (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.
|Variable| Description|
| ----------------- | -------------------------------------------------------------- |
|__calinv__|inverse of per capita daily caloric supply|
|__lnlevel__|natural log of economic development|
|__calileve__|inverse of per capita daily caloric supply*lnlevel|
|__necon__|economic performance|
|__presi__|presidential regime|
|__tag__|effective number of parties|
|__rel__|religious fractionalization|
|__ethn__|ethnic fractionalization|
|__prevdem__|numbers of previous democratic episodes|
|__openc__|trade openness|
|__Y__|years in current democratic episode |
|__Y0__|years in current democratic episode (lagged)|
|__C__|breakdown of democratic episode|
#### Misclassified-Failure
`mfsurv` estimated the probability of misclassification failure in the first (split) stage and hazard in the second (survival) stage.
`mfsurv` should be used when user suspects that data of survival cases could be right-sensored (i.e. when there is a probability that failure events are misclassified).
Example with N = 100000 is [here](https://github.com/Nicolas-Schmidt/BayesMFSurv/tree/master/data-raw).
```{r}
# Baseline Bayesian misclassified failure (MF) model.
# Misclassification stage only includes the intercept while the survival stage
# includes all covariates described above.
library(BayesMFSurv)
set.seed(95)
data(RBS)
RBS <- na.omit(RBS)
Y <- RBS$Y
X <- as.matrix(cbind(1, RBS[,1:10]))
C <- RBS$C
Z1 <- cbind(rep(1,nrow(RBS)))
Y0 <- RBS$Y0
model1 <- mfsurv(Y ~ X | C ~ Z1, Y0 = Y0,
N = 100,
burn = 50,
thin = 5,
w = c(0.5, 0.5, 0.5),
m = 20,
form = 'Weibull')
stats(model1)
summary(model1, parameter = c("betas"))
```
#### Non Misclassified-Failure
`mcmcsurv` estimates a Bayesian equivalent of standard survival models (i.e. Exponential or Weibull).
Example with N = 15000 can be found [here]( https://github.com/Nicolas-Schmidt/BayesMFSurv/tree/master/data-raw).
```{r}
set.seed(95)
model2 <- mcmcsurv(Y = Y, Y0 = Y0, C = C, X = X,
N = 100,
burn = 50,
thin = 5,
w = c(0.5, 0.5, 0.5),
m = 20,
form = 'Weibull')
stats(model2)
summary(model2, parameter = c("betas"))
```
#### Citation
To cite package`BayesMFSurv` in publications, please use:
```{r}
citation(package = 'BayesMFSurv')
```