Skip to contents

R package dfr.dist: dynamic failure rate (DFR) distributions

Traditional survival analysis often relies on parametric distributions (Weibull, exponential, log-normal) or semi-parametric models (Cox proportional hazards) that impose strong assumptions on how failure rates behave over time. These models can be restrictive when the underlying hazard function has complex, non-standard patterns.

This package takes a different approach: instead of choosing from a fixed catalog of distributions, you directly specify the failure rate (hazard) function itself. This gives you complete flexibility to model systems where the risk of failure follows unusual patterns—bathtub curves, multiple peaks, or any other time-varying behavior that depends on covariates.

The dfr.dist package handles all the mathematical machinery (computing survival functions, cumulative hazards, quantiles, sampling) from your custom hazard specification, as long as it satisfies basic probabilistic constraints.

Installation

You can install the development version of dfr.dist from GitHub repo with:

# install.packages("devtools")
devtools::install_github("queelius/dfr_dist")

Usage

The R packge dfr_dist provides an API for specifying and estimating dynamic failure rate distributions. They can depend on the data in any way, as the failure rate is any function of time and any set of predictors, as long as the failure rate satsifies two key properties:

  1. It’s non-negative. It is not meaningful to have a negative failure rate; the failure rate can decrease some times, and even go to 0, though.

  2. At the limit as time t goes to infinity, the cumulative hazard H also goes to infinity: limt → ∞ H(t, x1, …, xp) = ∞, where H(t, x1, …, xp) = ∫0t h(u, x1, …, xp) du. This constraint ensures the survival function S(t) = exp{−H(t)} is well-defined and approaches zero as t → ∞.

The dfr_dist object satisfies all of the requirements of an algebraic distribution (see algebraic.dist) and a likelihoood model (see likelihood.model).

The package is designed to be used with the algebraic.mle package, which provides a framework for performing maximum likelihood estimation (MLE).

A vignette showing how to use it is here.