nlmixr2 / nlmixr2est

nlmixr2 estimation routines
https://nlmixr2.github.io/nlmixr2est/
GNU General Public License v2.0
7 stars 3 forks source link

`saem` model setup incorrectly; missing `V(eta.cl)`, `V(eta.v1)`, `V(eta.v2)` #222

Closed mattfidler closed 2 years ago

mattfidler commented 2 years ago
> library(nlmixr2est)
library(testthat)

tmdd<-function() {
  ini({
    tcl<-fix(log(0.0106))
    tv1<-fix(log(3.09))
    tq<-fix(log(0.0126))
    tv2<-fix(log(1.65))
    tkon<-log(0.114)
    tkoff<-log(56.7)
    tr0<-log(18)
    tkout<-log(0.034)
    tkint<-log(0.0051)
    tv4<-log(10)

    eta.cl+eta.v1~fix(c(
      0.034,
      0.0197,0.024
    ))
    eta.v2~fix(0.025)
    eta.r0~2
    eta.v4~0.3
    eta.koff~0.3
    prop.eps.mab <- 0.05
    prop.eps.comp<-0.1
    add.eps.mab<-5
    add.eps.comp<-100
  })
  model({
    CL<-exp(tcl+eta.cl)
    V1<-exp(tv1+eta.v1)
    V2<-exp(tv2+eta.v2)
    V4<-exp(tv4+eta.v4)
    Q<-exp(tq)
    KON<-exp(tkon)
    KOFF<-exp(tkoff+eta.koff)
    R0<-exp(tr0+eta.r0)
    KOUT<-exp(tkout)
    KIN<-R0*KOUT
    KINT<-exp(tkint)
    c<-A1/V1
    complex=A4/V4;
    A3(0)<-18.83*3.085
    A4(0)<-0
    rel=A3/18.83/V1
    d/dt(A1)<- -CL/V1*A1-Q/V1*A1+Q/V2*A2-KON/V1*A1*A3+KOFF*A4+KINT*A4
    d/dt(A2)<- Q/V1*A1-Q/V2*A2
    d/dt(A3)<- KIN*V1-KOUT*A3-KON*A1/V1*A3+KOFF*A4
    d/dt(A4)<-KON*A1/V1*A3-KOFF*A4-KINT*A4
    c~prop(prop.eps.mab)+add(add.eps.mab)|A1
    complex~prop(prop.eps.comp)+add(add.eps.comp)|A4
  })
}

f <- nlmixr(tmdd)

expect_equal(f$saemParHistNames,
             c("tkon", "tkoff", "tr0", "tkout",
               "tkint", "tv4", "V(eta.cl)", "V(eta.v1)", 
               "V(eta.v2)", "V(eta.koff)", "V(eta.r0)", "V(eta.v4)", 
               "add.eps.mab", "prop.eps.mab", "add.eps.comp", "prop.eps.comp"))

> > > . + > > > > + . + > Error: f$saemParHistNames (`actual`) not equal to c(...) (`expected`).

    actual        | expected          
[4] "tkout"       | "tkout"       [4] 
[5] "tkint"       | "tkint"       [5] 
[6] "tv4"         | "tv4"         [6] 
                  - "V(eta.cl)"   [7] 
                  - "V(eta.v1)"   [8] 
                  - "V(eta.v2)"   [9] 
[7] "V(eta.koff)" | "V(eta.koff)" [10]
[8] "V(eta.r0)"   | "V(eta.r0)"   [11]
[9] "V(eta.v4)"   | "V(eta.v4)"   [12]
> 
mattfidler commented 2 years ago

This is correct.