nlmixrdevelopment / nlmixr

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

How to manually define exponential RUV and proportional RUV by norm() function? #564

Closed namtien0312 closed 2 years ago

namtien0312 commented 2 years ago

Dear nlmixr team,

I found that additive RUV cp ~ add(add.sd) is equivalent to cp ~ norm(add.sd) in userguide book!

How can I define in this way for proportional RUV, I tried cp ~ norm(cp*prop.sd) but it doesn't work, with error like that: Error in nlmixrUIModel(.model, ini, fun) : residual distribution parameter(s) estimates were not found in ini block. Code is:

one.compartment <- function() {
  ini({
    tka <- 0.45 # Log Ka
    tcl <- 1 # Log Cl
    tv <- 3.45    # Log V
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    prop.sd <- 0.7
  })
  model({
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center
    cp = center / v
    cp ~ norm(cp*prop.sd)
  })
}

fit2 <- nlmixr(one.compartment, theo_sd, list(print=0), est="focei")

And, with exponential RUV, how can I define it in the model. Is that log(cp) ~ norm(expo.sd)?

Thank you for the explanation! Tien Nguyen.

mattfidler commented 2 years ago

Hi @namtien0312

You cannot use norm(cp*prop.sd) instead use prop(prop.sd)

For the lognormal case you can use

cp ~ lnorm(expo.sd)

In this case, you can compare the objective function from the add and prop error models since they are on the same scale.

namtien0312 commented 2 years ago

Ohh, Thank Dr. Fidler for taking the time to help!

Tien Nguyen.