nlmixrdevelopment / nlmixr

nlmixr: an R package for population PKPD modeling
https://nlmixrdevelopment.github.io/nlmixr/
GNU General Public License v2.0
115 stars 45 forks source link

Cannot have IIV fixed to 0 for focei #392

Open billdenney opened 4 years ago

billdenney commented 4 years ago

It is possible to fix IIV to a nonzero value for a focei fit, but I cannot fix it to zero.

I think that the preferred behavior would be to handle this by removing the zero before estimation-- either totally remove it (probably much easier) or remove it and put it back into the estimation results later (harder from a programming perspective, but better for the user).

library(nlmixr)
one.cmt <- function() {
  ini({
    ## You may label each parameter with a comment
    tka <- 0.45 # Log Ka
    tcl <- 1 # Log Cl
    ## This works with interactive models
    ## You may also label the preceding line with label("label text")
    tv <- 3.45; label("log V")
    ## the label("Label name") works with all models
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ fixed(0)
    add.sd <- 0.7
  })
  model({
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    linCmt() ~ add(add.sd)
  })
}
fit <- nlmixr(one.cmt, theo_sd, est="focei", control=foceiControl(print=0))
#> i parameter labels from comments will be replaced by 'label()'
#> matrix seems singular; Using pseudo-inverse
#> Error in chol.default(mat2) : 
#>   the leading minor of order 3 is not positive definite
#> Error: initial 'omega' matrix inverse is non-positive definite

Created on 2020-09-07 by the reprex package (v0.3.0)

mattfidler commented 4 years ago

The problem is with the omega matrix; it isn't positive definite with a 0 on the diagonal (by definition); Therefore putting it back would be problematic.

However with model piping, you can put it in quite easily, so I'm unsure there is a huge advantage to having it in the output.

It is possible to remove the diagonal with a zero provided:

It seems alot for something the user can do themselves. For now I will not work on this, but I can see its value. I have some higher value things that need to be taken care of.

billdenney commented 4 years ago

Reasonable that this is very low priority.