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

Initial implementation of likelihood profiling #37

merged 28 commits into from
Sep 18, 2024

Conversation

billdenney
Copy link
Contributor

fix #1

This is a draft implementation of likelihood profiling.

@lirui0321
Copy link

Hi Bill and Matt, has this log likelihood profiling feature been added to nlmixr? I feel it is a pretty helpful feature to quantify the uncertainty in estimated parameter values.

@mattfidler
Copy link
Member

This is Bill's function. He would better understand the timelines.

@lirui0321
Copy link

Thank you, Matt! Let's see what Bill says.

Other than variance matrix and bootstrap, is there any other approach currently included in nlmixr for uncertainty quantification? Is there any plan to incorporate an MCMC based approach like BAYES in NONMEM?

@billdenney
Copy link
Contributor Author

I will likely complete this in a few weeks. The implementation is mostly complete, but it will take significant time to implement the tests.

@lirui0321
Copy link

I will likely complete this in a few weeks. The implementation is mostly complete, but it will take significant time to implement the tests.

Thanks for the update, Bill! I am happy to try your beta version whenever that becomes available.

@mattfidler
Copy link
Member

mattfidler commented Apr 25, 2024

Other than variance matrix and bootstrap, is there any other approach currently included in nlmixr for uncertainty quantification?

Not clear what you mean, but vpc and the variances/standard errors of ETA values can also be used to test for uncertainty. Over-parameterized models can sometimes be checked for by converting the model to PopED (using the development versions as well as babelmixr2's poped "estimation" method).

Is there any plan to incorporate an MCMC based approach like BAYES in NONMEM?

Long term, perhaps adding a stan interface like stanette is on the road-map (though on the long-term road-map). Also prior values are something that is on the road-map.

@lirui0321
Copy link

Other than variance matrix and bootstrap, is there any other approach currently included in nlmixr for uncertainty quantification?

Not clear what you mean, but vpc and the variances/standard errors of ETA values can also be used to test for uncertainty. Over-parameterized models can sometimes be checked for by converting the model to PopED (using the development versions as well as babelmixr2's poped "estimation" method).

Is there any plan to incorporate an MCMC based approach like BAYES in NONMEM?

Long term, perhaps adding a stan interface like stanette is on the road-map (though on the long-term road-map). Also prior values are something that is on the road-map.

Thanks, Matt! I am a "more" preclinical guy usually facing sparse data (e.g., mean digitized from literature) but relatively complicated model structure with multiple fitted parameters. Sometimes variance/covariance step fails. Sometimes I don't trust SE from covariance matrix because it tends to underestimate uncertainty. I like your plan of adding stan interface. NONMEM has BAYES and NUT, but again both approaches are not very friendly with data of limited N.

@mattfidler
Copy link
Member

Nothing other than bootstrapping currently.

@mattfidler
Copy link
Member

There is the preconditionFit function, too, if you are trying to get more reliable covariance. It does require some information about your covariance though... and it may not work with all scenarios.

@lirui0321
Copy link

There is the preconditionFit function, too, if you are trying to get more reliable covariance. It does require some information about your covariance though... and it may not work with all scenarios.

Many thanks for your feedback! rxode2 and nlmixr are still very convenient tools for me even without these additional features.

Choose a reason for hiding this comment

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

Hi Bill (@billdenney),
Thanks for the initial implementation. Very interesting! I have a question to you: Your code only allows the profiling of fixed effect parameters. Why not profiling e.g. the variance-covariances?
Thanks in advance!
Simon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no specific reason for that right now. Generally, profiling fixed effects is easier than random effects because random effects can be correlated. So, I think that you would need to detect correlation and only allow profiling of the random effects without correlations (or remove the correlation). @mattfidler, can you fix a random effect or its correlation when it is correlated without fixing the other parts?

Copy link
Member

Choose a reason for hiding this comment

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

You have to fix the whole block

Choose a reason for hiding this comment

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

I was referring the omegas not the individual etas, since they are part of the marginal likelihood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simonbeyer1, yes, I understood that you were referring to omegas. The idea I was getting to is that if you specify an eta like etacl + etavc ~ c(0.2, 0.1, 0.2), we would have to fix or not fix the entirety of that, all or none of the c(0.2, 0.1, 0.2) part. I don't immediately have a good idea of how to profile correlated BSV, so that will remain out of scope for this initial version of profiling.

Choose a reason for hiding this comment

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

ahh okay! Now I got it! Thanks!

@lirui0321
Copy link

Hi Bill,

By reading the comments above, it sounds like you have implemented a (beta?) version of LLP. Is there a tutorial about how to use it with nlmixr2? I am very interested in trying it. Thanks!

@billdenney
Copy link
Contributor Author

Hi Bill,

By reading the comments above, it sounds like you have implemented a (beta?) version of LLP. Is there a tutorial about how to use it with nlmixr2? I am very interested in trying it. Thanks!

I love the excitement! It isn't quite ready for use as I'm still working on the interface. I'm actively working on it, so I hope that it will be ready for testing soon. And, when it's ready for testing, I'll be sure to comment here and/or in the original issue. Alternatively, this pull request being merged will be an indication that it's ready for testing.

@lirui0321
Copy link

Hi Bill,
By reading the comments above, it sounds like you have implemented a (beta?) version of LLP. Is there a tutorial about how to use it with nlmixr2? I am very interested in trying it. Thanks!

I love the excitement! It isn't quite ready for use as I'm still working on the interface. I'm actively working on it, so I hope that it will be ready for testing soon. And, when it's ready for testing, I'll be sure to comment here and/or in the original issue. Alternatively, this pull request being merged will be an indication that it's ready for testing.

Thank you, Bill! Looking forward to testing it when it is ready.

@billdenney
Copy link
Contributor Author

billdenney commented Aug 20, 2024

@lirui0321 and @simonbeyer1 , This is ready for testing. I tried to make the documentation in ?profile.nlmixr2FitCore clear for how to use it. So, can you please take a look there and let me know if you have any questions?

@mattfidler, Can you please take a look and let me know if you see any issues?

Issues that I'm currently aware of are:

  • It doesn't handle fixing random effects, only fixed effects are supported.
  • If a new minimum OFV is found during profiling, the results may not be reliable.
  • If the OFV is not monotonic (an example is here:
    profadd.sd <- profile(fit, which = "add.sd")
    ), the results may not be reliable.
  • It should interface with confidence interval methods in the rest of nlmixr2 so that its output could be used in the fit$parFixed estimates.

@billdenney billdenney marked this pull request as ready for review August 20, 2024 17:47
#' @family Profiling
#' @seealso [profileLlp()]
#' @export
llpControl <- function(ofvIncrease = qchisq(0.95, df = 1),
Copy link
Member

Choose a reason for hiding this comment

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

Because of shinyMixR this should now have a new method rxUiDeparse.llpControl()... I will write one quickly. I am trying to release this today and would like this included (I know I'm reviewing last minute...)

@mattfidler
Copy link
Member

It would be nice it it would only use one function

nlmixr2(fit, est="llp")

But, it seems ok to me.

@mattfidler
Copy link
Member

mattfidler commented Sep 17, 2024

We may add that as a future feature.

@mattfidler
Copy link
Member

Unless you have strong objections, I will submit this with the rest.

@billdenney
Copy link
Contributor Author

Looks good to me. Thanks!

@mattfidler mattfidler merged commit ea0cfc7 into main Sep 18, 2024
8 checks passed
@mattfidler mattfidler deleted the fix-1 branch September 18, 2024 02:16
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.

Feature request: profile function for log-likelihood profiling
4 participants