Skip to content

Refactor R functions, enhance README, and update documentation#47

Open
hreinwald wants to merge 766 commits into
DoseResponse:masterfrom
hreinwald:main_beta
Open

Refactor R functions, enhance README, and update documentation#47
hreinwald wants to merge 766 commits into
DoseResponse:masterfrom
hreinwald:main_beta

Conversation

@hreinwald
Copy link
Copy Markdown

This pull request introduces a comprehensive update to the package, including new model functions, improvements to documentation, expanded export/imports, and updates to package metadata. The main themes are: expanding dose-response modeling capabilities, improving documentation and usability, updating package infrastructure, and enhancing compatibility with modern R standards.

Dose-response modeling enhancements:

  • Added new model functions such as CRS.6 (generalized Cedergreen-Ritz-Streibig model for hormesis), additional variants for Cedergreen models, and new helper/model functions for effective dose calculations (ED.drc, ED.lin, EDhelper) and relative potency comparisons (EDcomp, fieller, splitInd, createsifct). All new functions are documented with roxygen comments for clarity and usability. [1] [2] [3] [4] [5] [6] [7] [8]

  • Expanded the list of exported functions in NAMESPACE to include new and previously unexported models and utilities, improving accessibility for users.

Documentation and usability improvements:

  • Added comprehensive roxygen documentation to new and existing functions, including detailed descriptions, parameter explanations, references, examples, and usage notes. This improves discoverability and ease of use for both new and experienced users. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Package infrastructure and compatibility:

  • Updated DESCRIPTION for new version (3.3.0), new author, modern R dependency (>=4.0.0), updated URLs, encoding, roxygen version, testthat configuration, and additional suggested packages.

  • Improved .Rbuildignore to exclude more files and folders, and removed .travis.yml for modern CI compatibility. [1] [2]

Namespace and S3 methods updates:

  • Added new S3 methods for mrdrc class and additional confint, plot, print, ED methods, and improved imports for graphics, MASS, sandwich, lifecycle, and utils.

These changes collectively modernize the package, expand its modeling capabilities, and improve its usability and maintainability for dose-response analysis in R.

Copy link
Copy Markdown

@eduardszoecs eduardszoecs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 100 files

Comment thread README.Rmd Outdated
Comment thread R/genRetFct.R Outdated
Comment thread R/iband.R Outdated
#' @title Confidence band calculation
#' @keywords internal
"iband" <- function(object)
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intendation

Comment thread R/max.r
Comment thread R/mselect.R
Comment thread R/noEffect.R
Comment thread R/noEffect.R
if (identical(object$"type", "Poisson"))
{
llNull <- logLik(glm(resp ~ 1, family = poisson))
respVec <- object$"dataList"$resp
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is triplicated and can be moved outside of the ifs()

@eduardszoecs
Copy link
Copy Markdown

I think this PR is not reviewable (too many changes) and suggest a fork?

@eduardszoecs
Copy link
Copy Markdown

Although I do not think this is the case here: Such massive PRs are also a gateway for possible exploits.

For example there are many hard-coded links to an external repo which can hide anything: repo:hreinwald/drc https://github.com/hreinwald/drc/blob/HEAD...

Moreover there are changes to .rda files , which can hide exploits: https://github.com/hrbrmstr/rdaradar

@eduardszoecs
Copy link
Copy Markdown

Instead of a separate fork,you could also split this up into separate, smaller & meaningful PR (by topic).

Copilot AI and others added 25 commits March 18, 2026 22:11
…TION.cff to .Rbuildignore

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
The otrace parameter in drmc() was being passed directly as silentVal
to drmOpt(), which uses it as the `silent` argument in try(optim()).
This meant otrace=TRUE caused silent=TRUE, suppressing error messages
- the opposite of what the documentation and parameter name suggested.

Fix: negate otrace when passing to silentVal, so otrace=TRUE means
silent=FALSE (errors are displayed) and otrace=FALSE (default) means
silent=TRUE (errors are suppressed).

Also update the documentation to accurately describe otrace's behavior
and remove an outdated uncertainty comment in drmOpt.R.

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Fix searchdrc regex crash and clean devtools::check() to 0 errors/warnings/notes
…issue

Fix inverted otrace/silentVal logic in drmOpt
Document which self-starter method is used by default ("1") and describe
all four methods in weibull2(), weibull1(), and their wrapper functions
(W2.2, W2.3, W2.3u, W2.4, AR.2, AR.3, W1.2, W1.3, W1.3u, W1.4, EXD.2,
EXD.3). Clarify that the method parameter can be passed via ... in wrapper
functions.

Closes the issue about understanding which method W2.2() uses for
obtaining starting values.

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Document Weibull starting value method parameter and default behavior
…ion from asymptote parameters

When type="absolute", the absolute-to-relative response level conversion
(via absToRel/EDhelper) makes the relative response level a function of
the lower (c) and upper (d) asymptote parameters. The model-specific
edfct gradient functions treated these as constants, yielding zero
derivatives for c and d. This underestimated the standard error.

Use numerical central differences in ED.drc to compute the complete
gradient when type="absolute", correctly capturing the chain-rule
contributions from all parameters including c and d.

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Fixes:
1. fct: Add missing +c term (parmMat[,2] + parmMat[,3] - numTerm/denTerm)
2. edfct: Fix signature to match framework (parm, respl, reference, type, ...)
3. deriv1: Fix c-derivative to 1+1/t3, xlogx now available from xlogx.R
4. method: Add match.arg() validation, switch to named methods
5. Replace | with || in all if() guards (ucedergreen + wrappers)
6. Compute useFixed flag and pass to cedergreen.ssf
7. Fix maxfct signature and safe parameter reconstruction via parmVec[notFixed]
8. Fix ssfct to delegate to cedergreen.ssf() and negate b
9. Add fctName/fctText parameters with match.call() fallback
10. Add deriv1 and deriv2=NULL to returnList
11. Fix documentation (@param alpha, @param method, @return, @author)
12. Remove all commented-out dead code
13. Fix || in UCRS.4a/4b/4c/5a/5b/5c wrapper functions

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
…match

Fix SE calculation in ED() for type="absolute": missing chain-rule gradient through absToRel
…on-issues

Fix all issues in `ucedergreen()` — align with `cedergreen()` reference implementation
hreinwald and others added 30 commits April 24, 2026 15:18
…wald-vs-doseresponse

Add comparative analysis report as vignette
When NULL (default), error bars inherit the lwd value used for the main
curve (passed via ...). If lwd is also not set, falls back to par("lwd").
Users can also manually specify errbar.lwd to decouple error bar width
from curve width.

Agent-Logs-Url: https://github.com/hreinwald/drc/sessions/b98f8f53-8388-489f-ac7c-5c4965ad0fd5

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
…-width

Add errbar.lwd parameter to plot.drc as suggested in issue: #192
… docs/index.md

Agent-Logs-Url: https://github.com/hreinwald/drc/sessions/35d3f22c-4525-4853-a5e6-83c0d3bc8350

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Replace bare solve() in vcDisc with the same fallback chain used by
vcCont: try solve(), then chol(), then regularised chol(), and finally
return an NA matrix with a warning. This prevents summary() from
crashing for binomial drm models with singular Hessians.

Agent-Logs-Url: https://github.com/hreinwald/drc/sessions/e4568012-e9ea-4d83-ba1b-68458dde4827

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
…-to-3-3-1

Update stale version references to 3.3.1 in docs
…hs fail

A zero matrix passes the regularization step (0.99*0 + 0.01*I = 0.01*I),
so the NA/warning path is never reached. Use -100*I instead, which remains
non-positive-definite after regularization and correctly triggers the
warning + NA matrix return.

Agent-Logs-Url: https://github.com/hreinwald/drc/sessions/04f66d91-3372-406c-98fb-c38397241261

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
solve() succeeds on negative definite matrices (e.g. -100*I), returning
an inverse with negative diagonal elements (negative variances). Add
isValidVcov() check after each inversion attempt to verify all diagonal
elements are non-negative. If no valid inverse is found, issue warning
and return NA matrix.

Agent-Logs-Url: https://github.com/hreinwald/drc/sessions/8b88540c-a755-4e0a-8ba7-9a5c0bd0409c

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
…ssue

Fix vcDisc singular Hessian crash for binomial drm models
…ibility

The optimizer's relative tolerance controls when convergence is declared.
With the previous default of 1e-7, platform-specific floating-point
differences could cause the optimizer to stop at slightly different points
on different OSes (e.g., macOS vs Linux), producing noticeably different
parameter estimates.

Tightening to 1e-10 forces the optimizer closer to the true optimum on all
platforms, greatly reducing cross-platform variability in results.

Fixes #2

Agent-Logs-Url: https://github.com/hreinwald/drc/sessions/6b14c484-e053-4df7-9118-3b628afbc054

Co-authored-by: hreinwald <115988583+hreinwald@users.noreply.github.com>
Tighten default relTol from 1e-7 to 1e-10 for cross-platform reproducibility
…lvable

When drm() is called inside purrr::map() or lapply(), the stored $call
contains symbols like .x that don't exist outside the lambda scope.
update.drc() now detects when call$data cannot be resolved in the calling
frame and substitutes the stored origData from the fitted object.

Adds tests for update() and boxcox() with models fitted inside lapply().

Fixes #198
…avior

The two failing tests assumed that LL.5/W1.4 models with the algae data
would always produce non-finite ED values, but convergence behavior
varies across platforms and R versions. Updated the tests to accept
either outcome (exclusion or successful convergence) while still
verifying structural correctness of the results.
Fix update.drc() failure when model fitted inside purrr::map() or lapply()
…sion

Bump version to 3.3.2 and add changelog for all changes since 3.3.1
Added a note about the outdated CRAN version and linked to the comparative analysis.
Add comparative analysis report and enhance error bar functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants