nlmixr2 / rxode2

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

Feature Request: `model()`-only Models #213

Closed billdenney closed 2 years ago

billdenney commented 2 years ago

I had a model tonight where I wanted to do a post-hoc simulation where I had the parameter estimates in a data.frame. I tried writing a model that could have looked like the following, but the ini() was required.

Is there a reasonable way to make a no-ini() (model()-only) model?

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

pheno <- function() {
  model({
    ke <- cl / v            # elimination rate constant
    d/dt(A1) = - ke * A1    # model differential equation
    cp = A1 / v             # concentration in plasma
    cp ~ add(add.err)       # define error model
  })
}

simdata <-
  data.frame(
    AMT=c(1, rep(0, 23)),
    CMT="A1",
    cl=0.008,
    v=0.6,
    ke=0.008/0.6
  )

nlmixr(object=pheno, data=simdata, est="simulate")
#> Error: rxode2 model function requires one 'ini({})' block

Created on 2022-05-31 by the reprex package (v2.0.1)

billdenney commented 2 years ago

@mattfidler Thanks!