nlmixr2 / rxode2

rxode2
https://nlmixr2.github.io/rxode2/
GNU General Public License v3.0
28 stars 8 forks source link

Promoting parameters from dataset values to estimated parameters works with an initial estimate but not bounds #692

Closed billdenney closed 3 months ago

billdenney commented 3 months ago
library(nlmixr2)
#> Loading required package: nlmixr2data

one.compartment <- function() {
  ini({
    tka <- log(1.57); label("Ka")
    tcl <- log(2.72); label("Cl")
    tv <- log(31.5); label("V")
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.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 ~ add(add.sd)
  })
}

mod_up <-
  one.compartment |>
  model(
    extraValue <- exp(lextraValue),
    append = NA
  )

mod_up1 <-
  mod_up |>
  ini(
    lextraValue <- 2
  )
#> ℹ promote `lextraValue` to population parameter with initial estimate 2
#> ℹ change initial estimate of `lextraValue` to `2`

mod_up2 <-
  mod_up |>
  ini(
    lextraValue <- c(1, 2)
  )
#> Error in .addVariableToIniDf(.lhs, rxui, toEta = .tilde, value = .rhs, : Assertion on 'value' failed: Must have length 1, but has length 2.

mod_up3 <-
  mod_up |>
  ini(
    lextraValue <- c(1, 2, 3)
  )
#> Error in .addVariableToIniDf(.lhs, rxui, toEta = .tilde, value = .rhs, : Assertion on 'value' failed: Must have length 1, but has length 3.

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