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

Converting model from lincmt to an ODE model fails due to missing parameter in the ini block #505

Closed
billdenney opened this issue Apr 19, 2023 · 1 comment
Assignees

Comments

@billdenney
Copy link
Contributor

The example below indicates that peripheral1 should be in the ini block, but it shouldn't. This is likely a sequencing issue with append. I can try to look at it in a few days.

library(nlmixr2lib)
library(nlmixr2)
#> Warning: package 'nlmixr2' was built under R version 4.2.3
#> Loading required package: nlmixr2data
#> Warning: package 'nlmixr2data' was built under R version 4.2.3

readModelDb("Soehoel_2022_tralokinumab") %>%
  model(-f(depot), -cp) %>%
  model(
    {
      kel <- cl/vc
      k12 <- q/vc
      k21 <- q/vp
      
      d/dt(depot) <- -ka*depot
      d/dt(central) <-  ka*depot - kel*central - k12*central + k21*peripheral1
      d/dt(peripheral1) <- k12*central - k21*peripheral1
      cp <- central / vc
      
      f(depot) <- fdepot
      cp ~ add(cpaddSd) + prop(cppropSd)
    },
    append = TRUE
  )
#> ! remove population parameter `cpaddSd`
#> ! remove population parameter `cppropSd`
#> ℹ promote `peripheral1` to population parameter with initial estimate 1
#> ℹ add residual parameter `cpaddSd` and set estimate to 1
#> ℹ add residual parameter `cppropSd` and set estimate to 1
#> Error: syntax/parsing errors:
#> the following parameter(s) were in the ini block but not in the model block: peripheral1

Created on 2023-04-19 with reprex v2.0.2

@billdenney billdenney self-assigned this Apr 19, 2023
@mattfidler
Copy link
Member

This seems to work for me now.

library(rxode2)
#> rxode2 2.0.14.9000 using 8 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
library(nlmixr2lib)
readModelDb("Soehoel_2022_tralokinumab") %>%
model(-f(depot), -cp) %>%
model(
      {
      kel <- cl/vc
      k12 <- q/vc
      k21 <- q/vp
      
      d/dt(depot) <- -ka*depot
      d/dt(central) <-  ka*depot - kel*central - k12*central + k21*peripheral1
      d/dt(peripheral1) <- k12*central - k21*peripheral1
      cp <- central / vc
      
      f(depot) <- fdepot
      cp ~ add(cpaddSd) + prop(cppropSd)
      },
      append = TRUE
      )
#> ! remove population parameter `cpaddSd`
#> ! remove population parameter `cppropSd`
#> ℹ add residual parameter `cpaddSd` and set estimate to 1
#> ℹ add residual parameter `cppropSd` and set estimate to 1
#>  ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#>            lka            lvc            lcl            lvp             lq 
#>     -1.6928195      0.9969486     -1.9038090      0.3646431     -1.8388511 
#>        lfdepot      e_wt_vcvp       e_wt_clq e_nonECZTRA_cl e_nonECZTRA_vc 
#>     -0.2731219      0.7930000      0.8730000      0.3440000      0.2580000 
#>   e_f_dilution  e_ka_dilution        cpaddSd       cppropSd 
#>      0.3540000     -0.5190000      1.0000000      1.0000000 
#> 
#> Omega ($omega): 
#>           etavc     etacl
#> etavc 0.3861480 0.2683494
#> etacl 0.2683494 0.3057157
#> 
#> States ($state or $stateDf): 
#>   Compartment Number Compartment Name
#> 1                  1            depot
#> 2                  2          central
#> 3                  3      peripheral1
#>  ── μ-referencing ($muRefTable): ──  
#>   theta   eta level
#> 1   lcl etacl    id
#> 2   lvc etavc    id
#> 
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     covariateData <- list(nonECZTRA = "1 = any study other than ECZTRA; 0 = ECZTRA study", 
#>         WT = "Body weight in kg", dilution = "Was the drug diluted as it was in study D2213C00001? 1 = yes, 0 = no (0 is typical)")
#>     reference <- "Soehoel A, Larsen MS, Timmermann S. Population Pharmacokinetics of Tralokinumab in Adult Subjects With Moderate to Severe Atopic Dermatitis. Clinical Pharmacology in Drug Development. 2022;11(8):910-921. doi:10.1002/cpdd.1113"
#>     ini({
#>         lka <- -1.69281952137315
#>         label("Absorption rate (1/day)")
#>         lvc <- 0.99694863489161
#>         label("Central volume of distribution (L)")
#>         lcl <- -1.90380897303668
#>         label("Clearance (L/day)")
#>         lvp <- 0.364643113587909
#>         label("Peripheral volume of distribution (L)")
#>         lq <- -1.83885107676191
#>         label("Intercompartmental clearance (L/day)")
#>         lfdepot <- -0.273121921120451
#>         label("Subcutaneous bioavailability (fraction)")
#>         e_wt_vcvp <- 0.793
#>         label("Effect of body weight on central and peripheral volumes (unitless)")
#>         e_wt_clq <- 0.873
#>         label("Effect of body weight on clearance and intercompartmental clearance (unitless)")
#>         e_nonECZTRA_cl <- 0.344
#>         label("Effect of non-ECZTRA trials on clearance (unitless)")
#>         e_nonECZTRA_vc <- 0.258
#>         label("Effect of non-ECZTRA trials on central volume (unitless)")
#>         e_f_dilution <- 0.354
#>         label("Effect of dilution on bioavailability (unitless)")
#>         e_ka_dilution <- -0.519
#>         label("Effect of dilution trials on absorption rate (unitless)")
#>         cpaddSd <- c(0, 1)
#>         cppropSd <- c(0, 1)
#>         etavc + etacl ~ c(0.386148, 0.2683494, 0.3057157)
#>     })
#>     model({
#>         fdepot <- exp(lfdepot) * (1 + e_f_dilution * dilution)
#>         ka <- exp(lka) * (1 + e_ka_dilution * dilution)
#>         cl <- exp(lcl + etacl) * (WT/75)^e_wt_clq * (1 + e_nonECZTRA_cl * 
#>             nonECZTRA)
#>         vc <- exp(lvc + etavc) * (WT/75)^e_wt_vcvp * (1 + e_nonECZTRA_vc * 
#>             nonECZTRA)
#>         q <- exp(lq) * (WT/75)^e_wt_clq
#>         vp <- exp(lvp) * (WT/75)^e_wt_vcvp
#>         kel <- cl/vc
#>         k12 <- q/vc
#>         k21 <- q/vp
#>         d/dt(depot) <- -ka * depot
#>         d/dt(central) <- ka * depot - kel * central - k12 * central + 
#>             k21 * peripheral1
#>         d/dt(peripheral1) <- k12 * central - k21 * peripheral1
#>         cp <- central/vc
#>         f(depot) <- fdepot
#>         cp ~ add(cpaddSd) + prop(cppropSd)
#>     })
#> }

Created on 2023-11-30 with reprex v2.0.2

At least with #610 applied

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