Learn R Programming

spduration

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.

library("spduration")
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
# 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)
## Call:
## spdur(duration = duration ~ polity2, atrisk = atrisk ~ polity2, 
##     data = dur.coups, silent = TRUE)
## 
## Duration equation: 
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.00150    0.23762  16.840  < 2e-16 ***
## polity2      0.20588    0.03037   6.779 1.21e-11 ***
## 
## Risk equation: 
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   6.5278     3.2556   2.005   0.0449 *
## polity2       0.8966     0.4084   2.196   0.0281 *
## 
##            Estimate Std. Error t value Pr(>|t|)
## log(alpha) -0.03204    0.11899  -0.269    0.788
## ---
## Signif. codes: *** = 0.001, ** = 0.01, * = 0.05, . = 0.1
plot(model.coups, type = "hazard")

Install

  • the latest released version from CRAN:
install.packages("spduration")
  • the latest development version:
library(devtools)
install_github("andybega/spduration")

Contact

Copy Link

Version

Install

install.packages('spduration')

Monthly Downloads

146

Version

0.17.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Andreas Beger

Last Published

February 8th, 2024

Functions in spduration (0.17.2)

sploglog_lnl

Split-population Log-logistic log likelihood
xtable.spdur

Create export table for a split-duration model
weibull

Regular Weibull regression
sploglog

Split-population Log-logistic regression
plot_hazard2

Simulate and plot hazard function
predict.spdur

Predict methods for spdur Objects
sepplot

Generate a Separation Plot
spdur

Split-population duration (cure) regression
plot_hazard1

Plot conditional hazard rate
print.summary.spdur

Print a split-population duration model results summary
plot_hazard

Plot hazard function
spduration

Split-Population Duration (Cure) Regression Models
loglog_lnl

Regular Log-logistic likelihood
summary.spdur

Summarize split-population duration results
model.coups

Model of global coups from 1979 to 2010
spweib_lnl

Split-population Weibull log likelihood
weib_lnl

Regular weibull log likelihood
spweibull

Split-population Weibull regression
accessors

Accessor methods for spdur Objects
forecast.spdur

Forecast from a spdur model
AIC.spdur

AIC method for spdur
as.data.frame.spdur

Convert spdur results to summary data frame
add_duration

Add duration variables to panel data
attempt_date

Attempt to convert to R date format
bscoup

B&S 2003 coup data
BIC.spdur

BIC method for spdur
expand.call

Expand call to full names.
coups

Global coups, 1979 to 2010
plot.spdur

Plot split-duration model results.
panel_lag

Lag panel data
hazard

Calculate hazard function values
loglog

Regular Log-logistic regression