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

PD model error: Error in if (.retl > 5) #651

Open
fbroccatelli opened this issue Jun 26, 2024 · 2 comments
Open

PD model error: Error in if (.retl > 5) #651

fbroccatelli opened this issue Jun 26, 2024 · 2 comments

Comments

@fbroccatelli
Copy link

fbroccatelli commented Jun 26, 2024

Thanks for the awesome package and support.
I am trying a simple PD model based on internal data, and I finding an error, which I am able to reproduce with the warfarin dataset.

Model below, as well as error:

######

pk_iv_2_PD <- function() {
  ini({
    tke <- log((20))
    tk12 <- log((1))
    tk21 <- log((2))
    tvc <- log((0.1))
    tkdeg <- log(0.1)
    tkinact <- log(1)
    prop.err <- (0.1)
    add.err <- 1
    proppd.err <- (0.1)
    addpd.err <- 1
    
  })
  model({
    ke <- exp(tke)
    k12 <- exp(tk12)
    k21 <- exp(tk21)
    vc <- exp(tvc)
    kdeg <- exp(tkdeg)
    kinact <- exp(tkinact)
    
    periphereal(0)<-0
    pd(0)<-100
    
    d/dt(central)  = -central*ke - central * k12 + periphereal * k21
    d/dt(periphereal)  =  central * k12 - periphereal * k21
    d/dt(pca)  =  100*kdeg - kdeg * pca - kinact * central * pca
    
    cp =  central / vc   
    cp ~ prop(prop.err) + add(add.err)
    pca ~ prop(proppd.err) + add(addpd.err) 
  })
}

fit <- nlmixr2(pk_iv_2_PD, warfarin,  "focei",control=foceiControl(print=100000, outerOpt="bobyqa"))

########error:

→ loading into symengine environment...
→ pruning branches (if/else) of full model...
✔ done
Error in if (.retl > 5) { : the condition has length > 1
Error: the condition has length > 1

@mattfidler
Copy link
Contributor

Hi @fbroccatelli

I cannot reproduce your error. For me, the model runs successfully:

library(nlmixr2est)
#> Warning: package 'nlmixr2est' was built under R version 4.3.3
#> Loading required package: nlmixr2data
#> Warning: package 'nlmixr2data' was built under R version 4.3.3
pk_iv_2_PD <- function() {
  ini({
    tke <- log((20))
    tk12 <- log((1))
    tk21 <- log((2))
    tvc <- log((0.1))
    tkdeg <- log(0.1)
    tkinact <- log(1)
    prop.err <- (0.1)
    add.err <- 1
    proppd.err <- (0.1)
    addpd.err <- 1
    
  })
  model({
    ke <- exp(tke)
    k12 <- exp(tk12)
    k21 <- exp(tk21)
    vc <- exp(tvc)
    kdeg <- exp(tkdeg)
    kinact <- exp(tkinact)
    
    periphereal(0)<-0
    pd(0)<-100
    
    d/dt(central)  = -central*ke - central * k12 + periphereal * k21
    d/dt(periphereal)  =  central * k12 - periphereal * k21
    d/dt(pca)  =  100*kdeg - kdeg * pca - kinact * central * pca
    
    cp =  central / vc   
    cp ~ prop(prop.err) + add(add.err)
    pca ~ prop(proppd.err) + add(addpd.err) 
  })
}

fit <- nlmixr2(pk_iv_2_PD, nlmixr2data::warfarin,  "focei",control=foceiControl(print=0, outerOpt="bobyqa"))
#> → loading into symengine environment...
#> → pruning branches (`if`/`else`) of full model...
#> ✔ done
#> → finding duplicate expressions in EBE model...
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00
#> → optimizing duplicate expressions in EBE model...
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00
#> → compiling EBE model...
#> using C compiler: 'gcc.exe (GCC) 12.3.0'
#> ✔ done
#> rxode2 2.1.3 using 4 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
#> calculating covariance matrix
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> done
#> → Calculating residuals/tables
#> ✔ done
#> → compress origData in nlmixr2 object, save 27560
#> → compress parHistData in nlmixr2 object, save 84704

Created on 2024-06-29 with reprex v2.1.0

Can you provide a backtrace with traceback(). You can also see if your nlmixr2 is outdated by running the nlmixr2CheckInstall() function.

@fbroccatelli
Copy link
Author

Thanks for the help, this works now!

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