Skip to content

Commit 111547b

Browse files
queeliusclaude
andcommitted
Rename automatic_differentiation vignette, rebuild docs site
Rename vignette to custom_derivatives.Rmd to match its actual content ("Custom Derivatives for Maximum Likelihood Estimation"). Update all cross-references in vignettes, README, _pkgdown.yml, and CLAUDE.md. Rebuild pkgdown site with refreshed navbar and article structure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dc486ce commit 111547b

116 files changed

Lines changed: 2677 additions & 6595 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ Cox-Snell residuals should follow Exp(1) if model is correct.
254254
- `vignettes/failure_rate.Rmd`: Hazard-based modeling deep dive
255255
- `vignettes/custom_distributions.Rmd`: How to create custom distributions
256256
- `vignettes/reliability_engineering.Rmd`: Real-world applications
257-
- `vignettes/automatic_differentiation.Rmd`: Custom derivatives tutorial
257+
- `vignettes/custom_derivatives.Rmd`: Custom derivatives tutorial
258258

259259
## Common Pitfalls
260260

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ ll(df, par = c(0.5))
188188

189189
- [Dynamic Failure Rate Distributions](https://queelius.github.io/dfr.dist/articles/failure_rate.html) - Mathematical foundations
190190
- [Creating Custom Distributions](https://queelius.github.io/dfr.dist/articles/custom_distributions.html) - The three-level optimization paradigm
191-
- [Custom Derivatives for MLE](https://queelius.github.io/dfr.dist/articles/automatic_differentiation.html) - Analytical score and Hessian functions
191+
- [Custom Derivatives for MLE](https://queelius.github.io/dfr.dist/articles/custom_derivatives.html) - Analytical score and Hessian functions
192192

193193
**Reference:**
194194

README.md

Lines changed: 60 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,64 @@
1+
---
2+
output:
3+
github_document:
4+
toc: true
5+
---
16

27
<!-- README.md is generated from README.Rmd. Please edit that file -->
38

9+
10+
411
# dfr.dist
512

613
<!-- badges: start -->
7-
814
[![R-CMD-check](https://github.com/queelius/dfr.dist/workflows/R-CMD-check/badge.svg)](https://github.com/queelius/dfr.dist/actions)
915
<!-- badges: end -->
1016

1117
**Dynamic Failure Rate Distributions for Survival Analysis**
1218

13-
Capacitors that wear out faster than any Weibull can describe. Software
14-
systems with bathtub-shaped crash rates. Post-surgical patients whose
15-
risk drops sharply, then slowly climbs again. Standard parametric
16-
survival families cannot express these hazard patterns — but `dfr.dist`
17-
can.
19+
Capacitors that wear out faster than any Weibull can describe. Software systems
20+
with bathtub-shaped crash rates. Post-surgical patients whose risk drops sharply,
21+
then slowly climbs again. Standard parametric survival families cannot express
22+
these hazard patterns — but `dfr.dist` can.
1823

19-
**Write the hazard function you need — any R function of time and
20-
parameters — and the package derives everything else**: survival curves,
21-
CDFs, densities, quantiles, sampling, log-likelihoods, MLE fitting, and
22-
residual diagnostics.
24+
**Write the hazard function you need — any R function of time and parameters —
25+
and the package derives everything else**: survival curves, CDFs, densities,
26+
quantiles, sampling, log-likelihoods, MLE fitting, and residual diagnostics.
2327

2428
## Why dfr.dist?
2529

26-
| Feature | dfr.dist | survival | flexsurv |
27-
|----------------------------|--------------------------------------|--------------|----------|
28-
| Custom hazard functions | **Yes** | No | Limited |
29-
| Built-in distributions | Exp, Weibull, Gompertz, Log-logistic | Weibull, Exp | Many |
30-
| User-supplied derivatives | **score + Hessian** | No | No |
31-
| Censoring support | Right + Left | Right | Right |
32-
| Model diagnostics | Cox-Snell, Martingale, Q-Q | Limited | Limited |
33-
| Likelihood model interface | **Full** | Basic | Partial |
30+
| Feature | dfr.dist | survival | flexsurv |
31+
|---------|----------|----------|----------|
32+
| Custom hazard functions | **Yes** | No | Limited |
33+
| Built-in distributions | Exp, Weibull, Gompertz, Log-logistic | Weibull, Exp | Many |
34+
| User-supplied derivatives | **score + Hessian** | No | No |
35+
| Censoring support | Right + Left | Right | Right |
36+
| Model diagnostics | Cox-Snell, Martingale, Q-Q | Limited | Limited |
37+
| Likelihood model interface | **Full** | Basic | Partial |
3438

3539
## Features
3640

37-
- **Flexible hazard specification**: Define any hazard function h(t,
38-
par, …)
39-
- **Built-in distributions**: Exponential, Weibull, Gompertz,
40-
Log-logistic with optimized implementations
41-
- **Complete distribution interface**: hazard, survival, CDF, PDF,
42-
quantiles, sampling
41+
- **Flexible hazard specification**: Define any hazard function h(t, par, ...)
42+
- **Built-in distributions**: Exponential, Weibull, Gompertz, Log-logistic with optimized implementations
43+
- **Complete distribution interface**: hazard, survival, CDF, PDF, quantiles, sampling
4344
- **Likelihood model support**: Log-likelihood, score, Hessian for MLE
44-
- **Custom derivatives**: Supply analytical score and Hessian functions,
45-
or let the package fall back to numerical differentiation via numDeriv
45+
- **Custom derivatives**: Supply analytical score and Hessian functions, or let the package fall back to numerical differentiation via numDeriv
4646
- **Model diagnostics**: Residuals (Cox-Snell, Martingale) and Q-Q plots
47-
- **Censoring support**: Handle exact, right-censored, and left-censored
48-
survival data
49-
- **Ecosystem integration**: Works with `algebraic.dist`,
50-
`likelihood.model`, `algebraic.mle`
47+
- **Censoring support**: Handle exact, right-censored, and left-censored survival data
48+
- **Ecosystem integration**: Works with `algebraic.dist`, `likelihood.model`, `algebraic.mle`
5149

5250
## Installation
5351

5452
Install from GitHub:
5553

56-
``` r
54+
```r
5755
# install.packages("devtools")
5856
devtools::install_github("queelius/dfr.dist")
5957
```
6058

6159
## Quick Start
6260

61+
6362
``` r
6463
library(dfr.dist)
6564
```
@@ -68,6 +67,7 @@ library(dfr.dist)
6867

6968
Use the convenient constructors for classic survival distributions:
7069

70+
7171
``` r
7272
# Exponential: constant hazard (memoryless)
7373
exp_dist <- dfr_exponential(lambda = 0.5)
@@ -84,6 +84,7 @@ ll_dist <- dfr_loglogistic(alpha = 10, beta = 2)
8484

8585
All distribution functions are automatically available:
8686

87+
8788
``` r
8889
S <- surv(exp_dist)
8990
S(2) # Survival probability at t=2
@@ -96,6 +97,7 @@ h(1) # Hazard at t=1
9697

9798
### Maximum Likelihood Estimation
9899

100+
99101
``` r
100102
# Simulate failure times
101103
set.seed(42)
@@ -113,6 +115,7 @@ coef(result) # Estimated rate
113115

114116
Model complex failure patterns like bathtub curves:
115117

118+
116119
``` r
117120
# h(t) = a*exp(-b*t) + c + d*t^k
118121
# Infant mortality + useful life + wear-out
@@ -128,12 +131,16 @@ curve(sapply(x, h), 0, 15, xlab = "Time", ylab = "Hazard rate",
128131
main = "Bathtub hazard curve")
129132
```
130133

131-
<img src="man/figures/README-bathtub-1.png" width="100%" />
134+
<div class="figure">
135+
<img src="man/figures/README-bathtub-1.png" alt="plot of chunk bathtub" width="100%" />
136+
<p class="caption">plot of chunk bathtub</p>
137+
</div>
132138

133139
### Model Diagnostics
134140

135141
Check model fit with residual analysis:
136142

143+
137144
``` r
138145
# Fit exponential to data
139146
fitted_exp <- dfr_exponential(lambda = coef(result))
@@ -142,27 +149,32 @@ fitted_exp <- dfr_exponential(lambda = coef(result))
142149
qqplot_residuals(fitted_exp, df)
143150
```
144151

145-
<img src="man/figures/README-diagnostics-1.png" width="100%" />
152+
<div class="figure">
153+
<img src="man/figures/README-diagnostics-1.png" alt="plot of chunk diagnostics" width="100%" />
154+
<p class="caption">plot of chunk diagnostics</p>
155+
</div>
146156

147157
## Mathematical Background
148158

149-
For a lifetime $T$, the hazard function is: $$h(t) = \frac{f(t)}{S(t)}$$
159+
For a lifetime $T$, the hazard function is:
160+
$$h(t) = \frac{f(t)}{S(t)}$$
150161

151162
From the hazard, all other quantities follow:
152163

153-
| Function | Formula | Method |
154-
|-------------------|---------------------------|-------------|
164+
| Function | Formula | Method |
165+
|----------|---------|--------|
155166
| Cumulative hazard | $H(t) = \int_0^t h(u) du$ | `cum_haz()` |
156-
| Survival | $S(t) = e^{-H(t)}$ | `surv()` |
157-
| CDF | $F(t) = 1 - S(t)$ | `cdf()` |
158-
| PDF | $f(t) = h(t) \cdot S(t)$ | `density()` |
167+
| Survival | $S(t) = e^{-H(t)}$ | `surv()` |
168+
| CDF | $F(t) = 1 - S(t)$ | `cdf()` |
169+
| PDF | $f(t) = h(t) \cdot S(t)$ | `density()` |
159170

160171
## Likelihood for Survival Data
161172

162173
For exact observations: $\log L = \log h(t) - H(t)$
163174

164175
For right-censored: $\log L = -H(t)$
165176

177+
166178
``` r
167179
# Mixed data with censoring
168180
df <- data.frame(
@@ -179,40 +191,25 @@ ll(df, par = c(0.5))
179191

180192
**Start Here:**
181193

182-
- [Package
183-
Overview](https://queelius.github.io/dfr.dist/articles/dfr.dist-package.html) -
184-
Motivation, complete example, and audience guide
185-
- [Quick Start
186-
Guide](https://queelius.github.io/dfr.dist/articles/getting_started.html) -
187-
5-minute introduction
194+
- [Package Overview](https://queelius.github.io/dfr.dist/articles/dfr.dist-package.html) - Motivation, complete example, and audience guide
195+
- [Quick Start Guide](https://queelius.github.io/dfr.dist/articles/getting_started.html) - 5-minute introduction
188196

189197
**Real-World Applications:**
190198

191-
- [Reliability
192-
Engineering](https://queelius.github.io/dfr.dist/articles/reliability_engineering.html) -
193-
Five case studies
199+
- [Reliability Engineering](https://queelius.github.io/dfr.dist/articles/reliability_engineering.html) - Five case studies
194200

195201
**Going Deeper:**
196202

197-
- [Dynamic Failure Rate
198-
Distributions](https://queelius.github.io/dfr.dist/articles/failure_rate.html) -
199-
Mathematical foundations
200-
- [Creating Custom
201-
Distributions](https://queelius.github.io/dfr.dist/articles/custom_distributions.html) -
202-
The three-level optimization paradigm
203-
- [Custom Derivatives for
204-
MLE](https://queelius.github.io/dfr.dist/articles/automatic_differentiation.html) -
205-
Analytical score and Hessian functions
203+
- [Dynamic Failure Rate Distributions](https://queelius.github.io/dfr.dist/articles/failure_rate.html) - Mathematical foundations
204+
- [Creating Custom Distributions](https://queelius.github.io/dfr.dist/articles/custom_distributions.html) - The three-level optimization paradigm
205+
- [Custom Derivatives for MLE](https://queelius.github.io/dfr.dist/articles/custom_derivatives.html) - Analytical score and Hessian functions
206206

207207
**Reference:**
208208

209209
- [Function Reference](https://queelius.github.io/dfr.dist/reference/)
210210

211211
## Related Packages
212212

213-
- [`algebraic.dist`](https://github.com/queelius/algebraic.dist):
214-
Generic distribution interface
215-
- [`likelihood.model`](https://github.com/queelius/likelihood.model):
216-
Likelihood model framework
217-
- [`algebraic.mle`](https://github.com/queelius/algebraic.mle): MLE
218-
utilities
213+
- [`algebraic.dist`](https://github.com/queelius/algebraic.dist): Generic distribution interface
214+
- [`likelihood.model`](https://github.com/queelius/likelihood.model): Likelihood model framework
215+
- [`algebraic.mle`](https://github.com/queelius/algebraic.mle): MLE utilities

_pkgdown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ navbar:
2929
- text: Creating Custom Distributions
3030
href: articles/custom_distributions.html
3131
- text: Custom Derivatives for MLE
32-
href: articles/automatic_differentiation.html
32+
href: articles/custom_derivatives.html
3333

3434
articles:
3535
- title: Motivation & Applications
@@ -44,4 +44,4 @@ articles:
4444
- title: Advanced
4545
contents:
4646
- custom_distributions
47-
- automatic_differentiation
47+
- custom_derivatives

docs/404.html

Lines changed: 23 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)