Conversation
…nd tests
The analytical score_fn and hess_fn in all helper constructors (exponential,
Weibull, Gompertz, log-logistic) only derive from delta in {0,1}. When
left-censored data (delta=-1) was present, these functions silently produced
wrong gradients, causing the BFGS optimizer to receive inconsistent
function/gradient information. Added guards in score.dfr_dist and
hess_loglik.dfr_dist to detect left-censored observations and fall back to
numDeriv automatically.
Also:
- Merge getting_started.Rmd into flexhaz-package.Rmd with new left-censoring
and custom column name sections
- Fix log-logistic docs (was claiming "no closed form" despite having one)
- Update @param docs for score_fn/hess_fn/delta_col
- Add 57 new tests (322 total, 99.47% coverage)
- Suppress expected NaN optimizer warnings in all vignette fitting chunks
- Remove stale docs artifacts, rename .Rproj, update .gitignore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request addresses a critical bugfix for left-censored data handling, consolidates documentation, and significantly expands test coverage. The changes properly implement automatic fallback to numerical derivatives when analytical score/Hessian functions encounter left-censored observations (delta = -1), which they weren't designed to handle.
Changes:
- Critical bugfix: Score/Hessian functions now detect left-censored data and fall back to numerical derivatives automatically
- Vignette consolidation: Merged
getting_started.Rmdintoflexhaz-package.Rmdwith expanded coverage of left-censoring and custom column names - Test expansion: Added 57 new tests covering left-censoring, score/hessian fallback, custom column names, and regression tests
Reviewed changes
Copilot reviewed 74 out of 81 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
R/dfr_dist.R |
Implements left-censoring guards in score/hess, fixes vectorization in inv_cdf/cum_haz, adds NaN handling |
R/distributions.R |
Updates score_fn/hess_fn signatures to accept ob_col/delta_col parameters |
man/dfr_loglogistic.Rd |
Corrects documentation (was incorrectly claiming no closed form for cumulative hazard) |
man/dfr_dist.Rd |
Updates parameter documentation for score_fn/hess_fn/delta_col |
vignettes/flexhaz-package.Rmd |
Expands with left-censoring and custom column examples from deleted getting_started vignette |
vignettes/getting_started.Rmd |
Deleted (content merged into flexhaz-package.Rmd) |
tests/testthat/test-likelihood_model.R |
Adds comprehensive left-censoring tests for all distributions |
tests/testthat/test-bugfixes.R |
New file with regression tests for vectorization and column name issues |
DESCRIPTION |
Updated to mention left-censored data support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
score_fn/hess_fnsilently produced wrong results with left-censored data (delta=-1). Added guards inscore.dfr_distandhess_loglik.dfr_distto detect left-censored observations and fall back tonumDerivautomatically.getting_started.Rmdintoflexhaz-package.Rmdwith new left-censoring and custom column name (ob_col/delta_col) sections.cum_haz_rate), updated@paramdocs forscore_fn/hess_fn/delta_col.Test plan
devtools::test()— 322 pass, 0 faildevtools::document()— NAMESPACE and .Rd files regenerateddevtools::build_vignettes()— all 5 vignettes build cleanlydevtools::check()— full R CMD check🤖 Generated with Claude Code