Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of likelihood profiling #37

Merged
merged 28 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4ca65f4
Initial implementation of likelihood profiling (fix #1)
billdenney Dec 13, 2022
6c540b8
Additional feature updates
billdenney Dec 13, 2022
f4503f4
Intermediate work
billdenney Dec 19, 2022
612ca73
Merge branch 'main' into fix-1
billdenney Jan 21, 2023
fc6e1b5
Update documentation
billdenney Jan 21, 2023
b516473
Merge branch 'main' into fix-1
billdenney Aug 8, 2024
c7a3a63
Update documentation
billdenney Aug 8, 2024
725830e
Fix check issues
billdenney Aug 8, 2024
56ac86e
A much-improved work-in-progress. `profile.nlmixr2FitCore()` now wor…
billdenney Aug 18, 2024
f8d87f5
Stop estimation based on number of significant digits in estimated pa…
billdenney Aug 19, 2024
589a622
Use the default RSE when it is not available
billdenney Aug 19, 2024
d3c5272
Rename rse_theta to rseTheta
billdenney Aug 19, 2024
114ccf2
Update CI
billdenney Aug 19, 2024
1a7b123
Remove `quiet` argument
billdenney Aug 19, 2024
26b965a
Add more development version packages for CI
billdenney Aug 19, 2024
c482d93
correct dparser repo location
billdenney Aug 19, 2024
4c1891d
Remove unused `ignoreBounds` argument
billdenney Aug 19, 2024
5159186
Fix check issues
billdenney Aug 19, 2024
98805e1
Remove unused `maxpts` argument
billdenney Aug 19, 2024
3bfb925
Switch to a generalized profile method with `method` and `control` ar…
billdenney Aug 20, 2024
8e5f79f
Ensure that initial estimates are within the limits for the parameter…
billdenney Aug 20, 2024
cd720f6
Test residual error profiling
billdenney Aug 20, 2024
8e42770
Update documentation
billdenney Aug 20, 2024
101d16a
Documentation fix
billdenney Aug 20, 2024
1b705ca
Add omega values and covariances to profiling output
billdenney Aug 20, 2024
509db7b
Add rxUiDeparse method for llpControl
mattfidler Sep 17, 2024
64a4f43
Version bump
mattfidler Sep 17, 2024
b17bbe1
Update check config
mattfidler Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -22,17 +24,14 @@ jobs:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
#- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
_R_CHECK_FORCE_SUGGESTS_: false
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -44,16 +43,20 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
extra-packages: |
any::rcmdcheck
nlmixr2/lotri
nlmixr2/rxode2ll
nlmixr2/rxode2
nlmixr2/nlmixr2est
nlmixr2/nlmixr2plot
nlmixr2/PreciseSums
nlmixr2/lbfgsb3c
nlmixr2/n1qn1c
nlmixr2/dparser-R
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
14 changes: 11 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
Expand All @@ -19,8 +21,10 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -37,6 +41,10 @@ jobs:
nlmixr2/rxode2
nlmixr2/nlmixr2est
nlmixr2/nlmixr2plot
nlmixr2/PreciseSums
nlmixr2/lbfgsb3c
nlmixr2/n1qn1c
nlmixr2/dparser-R
local::.
needs: website

Expand All @@ -46,7 +54,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
Expand All @@ -15,7 +17,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -25,32 +27,46 @@ jobs:
with:
extra-packages: |
any::covr
any::xml2
nlmixr2/lotri
nlmixr2/rxode2ll
nlmixr2/rxode2
nlmixr2/nlmixr2est
nlmixr2/nlmixr2plot
nlmixr2/PreciseSums
nlmixr2/lbfgsb3c
nlmixr2/n1qn1c
nlmixr2/dparser-R
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: nlmixr2extra
Title: Nonlinear Mixed Effects Models in Population PK/PD, Extra Support
Functions
Version: 2.0.10
Version: 3.0.0
Authors@R: c(
person("Matthew", "Fidler", email="matthew.fidler@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8538-6691")),
Expand Down Expand Up @@ -32,6 +32,7 @@ Imports:
crayon,
data.table,
digest,
dplyr,
ggplot2,
ggtext,
knitr,
Expand All @@ -49,7 +50,6 @@ Suggests:
nlmixr2data,
testthat (>= 3.0.0),
withr,
dplyr,
devtools
LinkingTo:
Rcpp,
Expand All @@ -59,5 +59,5 @@ Config/testthat/edition: 3
Encoding: UTF-8
NeedsCompilation: yes
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
LazyData: true
19 changes: 19 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Generated by roxygen2: do not edit by hand

S3method(bootplot,nlmixr2FitCore)
S3method(extractEqHelper,"(")
S3method(extractEqHelper,"function")
S3method(extractEqHelper,"{")
S3method(extractEqHelper,call)
S3method(extractEqHelper,character)
S3method(extractEqHelper,default)
S3method(extractEqHelper,name)
S3method(extractEqHelper,nlmixr2FitCore)
S3method(extractEqHelper,numeric)
S3method(extractEqHelper,rxUi)
S3method(knit_print,nlmixr2FitCore)
S3method(knit_print,rxUi)
S3method(print,nlmixr2BoostrapSummary)
S3method(profile,nlmixr2FitCore)
S3method(rxUiDeparse,llpControl)
export(adaptivelassoCoefficients)
export(addCatCovariates)
export(addorremoveCovariate)
Expand All @@ -14,21 +26,27 @@ export(bootstrapFit)
export(buildcovInfo)
export(buildupatedUI)
export(covarSearchAuto)
export(fixedControl)
export(foldgen)
export(forwardSearch)
export(horseshoeSummardf)
export(ini)
export(knit_print)
export(lassoCoefficients)
export(lassoSummardf)
export(llpControl)
export(model)
export(nlmixr)
export(nlmixr2)
export(nlmixrWithTiming)
export(normalizedData)
export(optimUnisampling)
export(preconditionFit)
export(profileFixed)
export(profileFixedSingle)
export(profileLlp)
export(regularmodel)
export(rxUiDeparse)
import(lotri)
import(utils)
importFrom(Rcpp,evalCpp)
Expand All @@ -40,6 +58,7 @@ importFrom(nlmixr2est,nlmixrWithTiming)
importFrom(nlmixr2est,setCov)
importFrom(rxode2,ini)
importFrom(rxode2,model)
importFrom(rxode2,rxUiDeparse)
importFrom(stats,AIC)
importFrom(stats,approxfun)
importFrom(stats,cov)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# nlmixr2extra development version

* New `profile()` method for likelihood profiling (Issue #1)

# nlmixr2extra 2.0.10

* `bootstrapFit()` fixes `se` option (Issue #66)
Expand Down
6 changes: 1 addition & 5 deletions R/computingutil.R
Original file line number Diff line number Diff line change
Expand Up @@ -958,11 +958,7 @@ modelBootstrap <- function(fit,
}

# get control settings for the 'fit' object and save computation effort by not computing the tables
.ctl <- fit$control
.ctl$print <- 0L
.ctl$covMethod <- 0L
.ctl$calcTables <- FALSE
.ctl$compress <- FALSE
.ctl <- setQuietFastControl(fit$control)

modelsEnsemble <-
lapply(bootData[.env$mod_idx:nboot], function(boot_data) {
Expand Down
10 changes: 10 additions & 0 deletions R/knit_printEquation.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,27 @@ extractEqHelperLhsRhs <- function(x, ..., inModel, prefix = "", middle, suffix =
paste0(prefix, lhs, middle, rhs, suffix)
}

#' @export
extractEqHelper.nlmixr2FitCore <- function(x, ..., inModel) {
extractEqHelper(as.function(x), ..., inModel=FALSE)
}

#' @export
extractEqHelper.rxUi <- function(x, ..., inModel, name) {
extractEqHelper(as.function(x), ..., inModel=FALSE)
}

#' @export
extractEqHelper.function <- function(x, ..., inModel, name) {
extractEqHelper(methods::functionBody(x), ..., inModel=FALSE)
}

#' @export
"extractEqHelper.{" <- function(x, ..., inModel, name) {
extractEqHelperSeqDrop(x, ..., inModel = inModel)
}

#' @export
"extractEqHelper.(" <- function(x, ..., inModel, dropParen = FALSE, name) {
stopifnot(length(x) == 2)
if (dropParen) {
Expand Down Expand Up @@ -178,6 +183,7 @@ latexOpMap <-
"!"="{\\lnot}"
)

#' @export
extractEqHelper.call <- function(x, ..., inModel, name) {
if (inModel) {
if (is.name(x[[1]])) {
Expand Down Expand Up @@ -270,6 +276,7 @@ extractEqHelper.call <- function(x, ..., inModel, name) {
ret
}

#' @export
extractEqHelper.name <- function(x, ..., inModel, underscoreToSubscript = FALSE, name) {
if (inModel) {
ret <- as.character(x)
Expand All @@ -292,6 +299,7 @@ extractEqHelper.name <- function(x, ..., inModel, underscoreToSubscript = FALSE,
ret
}

#' @export
extractEqHelper.numeric <- function(x, ..., inModel, name = NULL) {
if (inModel) {
ret <- format(x)
Expand Down Expand Up @@ -329,6 +337,7 @@ escapeLatex <- function (x, newlines = FALSE, spaces = FALSE) {
x
}

#' @export
extractEqHelper.character <- function(x, ..., inModel, name = NULL) {
if (inModel) {
ret <- sprintf('\\text{"%s"}', escapeLatex(x))
Expand Down Expand Up @@ -394,6 +403,7 @@ extractEqHelper.if <- function(x, ..., inModel, alignment, indent = 0L, firstIf
ret
}

#' @export
extractEqHelper.default <- function(x, ..., inModel) {
if (inherits(x, "<-") | inherits(x, "=")) {
# The assignment classes go via extractEqHelper.default to fix an R CMD
Expand Down
Loading
Loading