An implementation of split-population duration regression models.
Unlike regular duration models, split-population duration models are
mixture models that accommodate the presence of a sub-population that is
not at risk for failure, e.g. cancer patients who have been cured by
treatment. This package implements Weibull and Loglogistic forms for the
duration component, and focuses on data with time-varying covariates.
These models were originally formulated in Boag (1949)
< http://www.jstor.org/stable/2983694> and Berkson and Gage (1952)
< http://www.jstor.org/stable/2281318>, and extended in Schmidt and Witte
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)data(coups)dur.coups <- add_duration(coups, "succ.coup", unitID="gwcode", tID="year",freq="year")# Estimate modelmodel.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")
forecastgeneric function from
forecastpackage rather than re-defining it. Adds
forecastto neccessary imports.
separationplotis a standalone function so change the
spdurversion to a simple wrapper.
statsto imported package in description and removed all associated explicit namespace generic imports.
init.cwith calls to
R_useDynamicSymbols(); also use
NAMESPACE. R-devel (and R 3.4.0 in the future)
R CMD checkissues a NOTE for registration of routines, this is to avoid that note.
summary.spdurthat would return wrong estimates for
summary.spdurwhen called on a model with factor variables or without intercept terms.
plot_hazard(ci = TRUE)), where CIs coud be wrong because coefficients were sampled by equation rather than using the full variance covariance matrix.
plot_hazard, added support for loglog models, and other internal streamlining of plotting code.