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

Feature Request: linCmt() on the right hand side with less automation #540

Open
billdenney opened this issue Jul 2, 2021 · 4 comments
Open

Comments

@billdenney
Copy link
Contributor

I have a model where I want to simultaneously use two linCmt() PK models while fitting the PD model. But, I think that linCmt() is only valid on the left hand side of an error model assignment (i.e. linCmt() ~ prop(prop.err)).

The feature request here has a few different parts to attempt to have the goal of using it for different drugs in the same model.

  1. Can linCmt() go on the right hand side of an assignment statement (e.g. cp = linCmt())? Maybe it already can, but I have not seen documentation of an example of that.
  2. Can a new version of linCmt be made where it can accept named arguments rather than auto-detecting the parameters? The goal of this part is that you could work with more than one drug at a time. (This is a bit different than using DVID or some other method like that because of the idea that I may want to work with more than one linCmt() drug at the same time. If I need to do a calculation like cp_drug1 = linCmt([parameters for drug 1]), cp_drug2 = linCmt([parameters for drug 2]), and then some calculation with cp_drug1 and cp_drug2 such as a competitive Emax model, I can't immediately think of a way to do that.)

An example of what I'd like to be able to do is below.

library(nlmixr)
double_onecmt <- function() {
  ini({
    lCl1 <- 1.6      ; label("Cl drug 1 (L/hr)")
    lVc1 <- log(18)  ; label("Vc drug 1 (L)")
    eta_Cl1 ~ 0.1 ; label("BSV Cl drug 1 ")
    prop_err1 <- c(0, 0.2, 1)
    lCl2 <- 1.6      ; label("Cl drug 2 (L/hr)")
    lVc2 <- log(18)  ; label("Vc drug 2 (L)")
    eta_Cl2 ~ 0.1 ; label("BSV Cl drug 2")
    prop_err2 <- c(0, 0.2, 1)
  })
  model({
    Cl1 <- exp(lCl1 + eta_Cl1)
    Vc1 <- exp(lVc1)
    Cl2 <- exp(lCl2 + eta_Cl2)
    Vc2 <- exp(lVc2)
    cp1 <- linCmt(CL=Cl1, Vc=Vc1)
    cp2 <- linCmt(CL=Cl2, Vc=Vc2)
    cp1 ~ prop(prop_err1)
    cp2 ~ prop(prop_err2)
  })
}
nlmixr(double_onecmt)
@mattfidler
Copy link
Contributor

mattfidler commented Jul 2, 2021

Can linCmt() go on the right hand side of an assignment statement (e.g. cp = linCmt())? Maybe it already can, but I have not seen documentation of an example of that.

Yes it can.

Can a new version of linCmt be made where it can accept named arguments rather than auto-detecting the parameters?

This would require a large rewrite of RxODE's parsing. It does currently accept arguments, though nothing that is named.

[Can linCmt() be used] for different drugs in the same model.

The linCmt() is not really a function. It is called in the ODE step or the LHS step depending on context. The memory is also allocated and equations/memory change if it is focei or saem. This would take an equal amount or larger time to rewrite these functions.

In short this seemingly simple request takes alot of work, so for right now I am not going to do it.

@mattfidler
Copy link
Contributor

In the UI that I am rewriting you will be able to mix ODE and linCmt but currently that isn't supported for nlmixr

@billdenney
Copy link
Contributor Author

I had a guess that it wasn't simple. Good to know that I can use linCmt() on the right hand side. It would be interesting to have some more documentation of that and how the arguments can be given to linCmt().

@mattfidler
Copy link
Contributor

The arguments are simply to trigger the autodetection. I haven't tested if the mangling done by nlmixr currently would break it, so I haven't really documented it.

It works in RxODE right now, you can see it in one of the many linear compartment model tests:

https://github.com/nlmixrdevelopment/RxODE/blob/b69e32a1a486e0c2416dfa183e2905cddcca1aa7/tests/testthat/test-lincmt-solve.R#L37

It still isn't really a function.

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

No branches or pull requests

2 participants