https://github.com/andybega/spduration
Split-population duration model in R
https://github.com/andybega/spduration
mixture-model r regression split-population survival-analysis
Last synced: 18 days ago
JSON representation
Split-population duration model in R
- Host: GitHub
- URL: https://github.com/andybega/spduration
- Owner: andybega
- Created: 2012-10-31T19:15:33.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2024-02-08T10:20:35.000Z (over 1 year ago)
- Last Synced: 2024-02-09T09:47:57.414Z (over 1 year ago)
- Topics: mixture-model, r, regression, split-population, survival-analysis
- Language: R
- Homepage: https://andybeger.com/spduration/
- Size: 21.6 MB
- Stars: 4
- Watchers: 8
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,
fig.path = "man/figures/README-")
```# spduration
[](https://github.com/andybega/spduration/actions/workflows/R-CMD-check.yaml)
[](https://cran.r-project.org/package=spduration)
[](https://app.codecov.io/gh/andybega/spduration?branch=master)spduration implements a split-population duration model for duration data with time-varying covariates where a significant subset of the population or spells will not experience failure.
```{r}
library("spduration")# Prepare data
data(coups)
dur.coups <- add_duration(coups, "succ.coup", unitID="gwcode", tID="year",
freq="year")# Estimate model
model.coups <- spdur(duration ~ polity2, atrisk ~ polity2, data = dur.coups,
silent = TRUE)
summary(model.coups)
``````{r, fig.width=6, fig.height = 5, fig.align='center'}
#| fig.alt: >
#| Plot of the conditional hazard rate over time for coups. It shows a relatively
#| constant hazard of around 0.013, going almost 40 years on the x-axis. The plot
#| includes confidence bands, which range from around 0.005 to 0.020, with slightly
#| less uncertainty around 2-3 years out.
plot(model.coups, type = "hazard")
```## Install
* the latest released version from CRAN:
```{r, eval = FALSE}
install.packages("spduration")
```* the latest development version:
```{r, eval = FALSE}
library(devtools)
install_github("andybega/spduration")
```## Contact
- submit suggestions, bugs, issues, questions at: [https://github.com/andybega/spduration/issues](https://github.com/andybega/spduration/issues)
- email: [adbeger+spduration@gmail.com](mailto:adbeger+spduration@gmail.com)