An open API service indexing awesome lists of open source software.

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

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

[![R-CMD-check](https://github.com/andybega/spduration/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andybega/spduration/actions/workflows/R-CMD-check.yaml)
[![CRAN version](http://www.r-pkg.org/badges/version/spduration)](https://cran.r-project.org/package=spduration)
[![Codecov test coverage](https://codecov.io/gh/andybega/spduration/branch/master/graph/badge.svg)](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)