Package: flexhaz 0.5.2

flexhaz: Dynamic Failure Rate Distributions for Survival Analysis

Flexible framework for specifying survival distributions through their hazard (failure rate) functions. Define arbitrary time-varying hazard functions to model complex failure patterns including bathtub curves, proportional hazards with covariates, and other non-standard hazard behaviors. Provides automatic computation of survival, CDF, PDF, quantiles, and sampling. Implements the likelihood model interface for maximum likelihood estimation with right-censored and left-censored survival data.

Authors:Alexander Towell [aut, cre]

flexhaz_0.5.2.tar.gz
flexhaz_0.5.2.zip(r-4.7-any)flexhaz_0.5.2.zip(r-4.6-any)flexhaz_0.5.2.zip(r-4.5-any)
flexhaz_0.5.2.tgz(r-4.6-any)flexhaz_0.5.2.tgz(r-4.5-any)
flexhaz_0.5.2.tar.gz(r-4.7-any)flexhaz_0.5.2.tar.gz(r-4.6-any)
flexhaz_0.5.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
flexhaz/json (API)

# Install 'flexhaz' in R:
install.packages('flexhaz', repos = c('https://queelius.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/queelius/flexhaz/issues

Pkgdown/docs site:https://queelius.github.io

On CRAN:

Conda:

automatic-differentiationcensored-datafailure-ratehazard-functionlikelihood-functionsmlereliabilitystatistical-inferencesurvival-analysis

6.90 score 3 packages 39 scripts 338 downloads 21 exports 9 dependencies

Last updated from:2cde3faff8. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK154
source / vignettesOK181
linux-release-x86_64OK129
macos-release-arm64OK102
macos-oldrel-arm64OK136
windows-devel-x86_64OK76
windows-release-x86_64OK112
windows-oldrel-x86_64OK84
wasm-releaseOK106

Exports:assumptionscdfcum_hazdfr_distdfr_exponentialdfr_gompertzdfr_loglogisticdfr_weibullfithazardhess_loglikinv_cdfis_dfr_distis_likelihood_modelloglikparamsqqplot_residualssamplerscoresupsurv

Dependencies:algebraic.distalgebraic.mlebootgenericslikelihood.modelMASSmvtnormnumDerivR6

Reliability Engineering Applications
Introduction | Case Study 1: Capacitor Lifetime Analysis | The Data | Model Comparison | Model Selection | Interpretation | Case Study 2: B-Life Calculations | Visual Representation | Case Study 3: Warranty Analysis | Case Study 4: Maintenance Scheduling | Case Study 5: Competing Failure Modes | Model Diagnostics | Summary | Best Practices

Last update: 2026-02-24
Started: 2026-02-02

Creating Custom Distributions
The Power of Custom Hazards | The Three Functions | Level 1: Just the Hazard | Level 2: Add Analytical Cumulative Hazard | Level 3: Add Analytical Score Function | Complete Example: Makeham Distribution | Step 1: Derive the Mathematics | Step 2: Implement | Step 3: Test | Writing Custom Derivative Functions | Use Standard R Indexing | Return Correct Types | Handle Censoring | Performance Comparison | Real-World Example: Bathtub Curve | Summary | Next Steps

Last update: 2026-02-18
Started: 2026-02-02

Custom Derivatives for Maximum Likelihood Estimation
Introduction | Setup | The Weibull Distribution | Simulating Data | Approach 1: Minimal — Just the Hazard Rate | Approach 2: Analytical Score + Analytical Hessian | Approach 3: Provide Score Only, Let numDeriv Handle the Hessian | Using Pre-Built Constructors | Computing Standard Errors | Distribution Reference | Next Steps

Last update: 2026-02-18
Started: 2026-02-13

Dynamic Failure Rate Distributions
Introduction | Why hazard-based parameterization? | Mathematical background | Getting Started | Using Built-in Distributions | Creating Custom Distributions | Distribution Methods | Hazard and cumulative hazard | Survival and CDF | PDF (Density) | Quantile function (inverse CDF) | Sampling | Overriding parameters | Likelihood Model Interface | Log-likelihood for survival data | Creating test data | Computing log-likelihood | Score function (gradient) | Hessian of log-likelihood | Maximum Likelihood Estimation | Working with censored data | Example: Weibull MLE | Custom Hazard Functions | Bathtub hazard | Time-covariate interaction | Integration with algebraic.dist | Model Diagnostics | Cox-Snell Residuals | Martingale Residuals | Summary | Next Steps

Last update: 2026-02-18
Started: 2023-06-16

flexhaz: Hazard-First Survival Modeling
The Problem | The Idea | Installation | Your First Distribution | Get Distribution Functions | Generate Samples | Fitting to Data | Maximum Likelihood Estimation | Model Diagnostics | Working with Censored Data | Right-Censoring | Left-Censoring | Custom Column Names | Beyond Exponential: Weibull | The Real Power: Custom Hazards | Define a bathtub hazard | Plot the hazard curve | Plot the survival curve | Simulate data and fit via MLE | Inspect the fit | Residual diagnostics | Built-in Distributions | Key Functions | Where to Go Next

Last update: 2026-02-18
Started: 2026-02-14

Readme and manuals

Help Manual

Help pageTopics
Retrieve the assumptions a DFR distribution makes about the dataassumptions.dfr_dist
Method for obtaining the cdf of a 'dfr_dist' object.cdf.dfr_dist
Method for obtaining the cumulative hazard function of an object.cum_haz
Method for obtaining the cumulative hazard function of a 'dfr_dist' object.cum_haz.dfr_dist
Method for obtaining the density (pdf) of a 'dfr_dist' object.density.dfr_dist
Constructor for 'dfr_dist' objectsdfr_dist
Exponential Distribution (Constant Hazard)dfr_exponential
Gompertz Distribution (Exponential Growth Hazard)dfr_gompertz
Log-Logistic Distribution (Non-Monotonic Hazard)dfr_loglogistic
Weibull Distribution (Power-Law Hazard)dfr_weibull
Diagnostic Methods for DFR Distributionsdiagnostics
Classic Survival Distribution Constructorsdistributions
MLE solver for dfr_dist objectsfit.dfr_dist
Method for obtaining the hazard function of a 'dfr_dist' object.hazard.dfr_dist
Hessian of log-likelihood for dfr_disthess_loglik.dfr_dist
Method for obtaining the quantile (inverse cdf) of an object.inv_cdf.dfr_dist
Function for determining whether an object is a 'dfr_dist' object.is_dfr_dist
Log-likelihood method for 'dfr_dist' objectsloglik.dfr_dist
Method for obtaining the parameters of a 'dfr_dist' object.params.dfr_dist
Plot DFR Distribution Functionsplot.dfr_dist
Print method for 'dfr_dist' objects.print.dfr_dist
Q-Q Plot for Cox-Snell Residualsqqplot_residuals
Residuals for DFR Distribution Fitsresiduals.dfr_dist
Sampling function for 'dfr_dist' objects.sampler.dfr_dist
Score function (gradient of log-likelihood) for dfr_distscore.dfr_dist
Method for retrieving the support of an object 'x'.sup.dfr_dist
Method for obtaining the survival function of a 'dfr_dist' object.surv.dfr_dist