nlmixr2 / nlmixr2extra

Extra utilities for nlmixr objects
https://nlmixr2.github.io/nlmixr2extra/
GNU General Public License v3.0
3 stars 1 forks source link

Feature request: profile function for log-likelihood profiling #1

Closed billdenney closed 1 month ago

billdenney commented 2 years ago

I think that it'd be helpful to implement a profile() method for fit objects to perform log-likelihood profiling. (This is not a high priority request, and if not yet implemented, it's something that I could help with.)

mattfidler commented 2 years ago

The focei methods are working in this revision more or less, saem is ongoing. If that is sufficient for you to work on, that is fine with me.

You can install with:

remotes::install_github("nlmixr2/lotri")
remotes::install_github("nlmixr2/rxode2")
remotes::install_github("nlmixr2/nlmixr2")
mattfidler commented 2 years ago

The tests need to be updated too, since they use low level functions etc, so this isn't "working" yet.

mattfidler commented 2 years ago

Maybe we should move this to projects?

billdenney commented 2 years ago

@mattfidler , Can you please move this to nlmixr2extra? (I don't think that I can move the issue.)

mattfidler commented 2 years ago

Done. Not sure what is required to move issues.

billdenney commented 3 months ago

@mattfidler, While working on the profile.nlmixr2FitCore method in the PR this morning, I realized that I was reinventing numerical optimization for about the 50th time in my career.

What I'd like to do is to use a one-dimensional minimizer trying to minimize fit$objective + targetOfv by varying each requested parameter in turn where:

  1. I can give bounded optimization either between the initial model-estimated OFV and the upper bound (which may be infinite), and separately its lower bound (which also may be infinite).
  2. I can inspect at each optimization step to see if any of the following conditions have been met and variously give warnings, errors, or stop the profiling process
    1. A new lower OFV has been found during the minimization
    2. The model did not converge
    3. The OFV profile is non-monotonic
  3. I can obtain the trace of the estimation

Rather than reinventing all of this, I'd prefer to use parts of nlmixr2 that are likely already available in some form. Is there something that could do this for me in nlmixr2?

mattfidler commented 3 months ago

Not yet. You are in luck :smile: I would suggest something like Brent's method in optim

billdenney commented 2 months ago

Unfortunately, Brent's method in optim() starts at the middle of the allowed interval, so if the limits for lka are c(-10, 10), and the estimate is 3, it will start the search at 0 rather than near 3. But generally, I'm looking around there for a solution.