Estimation: nlmixr

While the PKPDsim R package does not include functionality to perform population estimation within the package, it does offer a convenient translator to be able to use the nlmixr R package for parameter estimation. nlmixr allows fitting of population PK-PD models using common algorithms applied in pharmacometrics, such as FOCE and SAEM. For installation and usage of nlmixr, please refer to the documentation in the nlmixr package and on the respective website.

Translation

Under the hood, nlmixr uses the RxODE R package to perform PKPD model simulations, and which is very similar to PKPDsim. The model syntax for both RxODE and nlmixr compared to PKPDsim are also very similar, making translation fairly straightforward. A model translator has therefore been included in PKPDsim that allows translation of a PKPDsim model to nlmixr syntax, e.g.

mod <- new_ode_model("pk_1cmt_iv")
f <- pkpdsim_to_nlmixr(
  model = mod,
  parameters = list(CL = 5, V = 50),
  omega = c(0.1, 0.05, 0.1),
  res_var = list(prop = 0.1, add = 0.1),
  log_transform = T)

The return object f generated by pkpdsim_to_nlmixr is an object that defines the required model and parameter definitions in nlmixr syntax:

> f
function() {
  ini({
    logCL <- log(5) # log CL
    logV <- log(50) # log V
    err_prop <- c(0, 0.1, 1)
    err_add <- c(0, 1, 10)
    eta_CL + eta_V ~ c(
      0.1, 0.05, 0.1)
  })
  model({
    CL <- exp(logCL + eta_CL)
    V <- exp(logV + eta_V)
        d/dt(A1) = -(CL/V)*A1;
    y = A1/V
    y ~  prop(err_prop) + add(err_add)
  })
}

A full code example is included below.

Note: both nlmixr and the nlmixr-translator in PKPDsim are still under active development. Syntax and results may change.

Example

library(tidyverse)
library(PKPDsim)
library(nlmixr)

## Create PKPDsim model
mod   <- new_ode_model("pk_1cmt_iv")
par   <- list(CL = 5, V = 50)
ruv   <- list(prop = 0.1, add = 1)
omega <- c(0.1,
           0.05, 0.1)

## Simulate data
t_obs <- c(8, 23.5, 25, 71.5)
n <- 50
regimen <- new_regimen(amt = 1500, n = 4, interval = 24, type = "bolus")
conc <- sim_ode(
  ode = mod, regimen = regimen, parameters = par,
  omega = omega, only_obs = T, t_obs = t_obs, n = n,
  res_var = ruv) %>%
  dplyr::mutate(EVID = 0, AMT = 0, MDV = 0, CMT = 1) %>%
  dplyr::select(ID = id, TIME = t, CMT, DV = y, AMT, EVID, MDV)
doses <- regimen_to_nm(regimen, n_ind = n)
simdat <- dplyr::bind_rows(doses, conc) %>% dplyr::arrange(ID, TIME)
d <- nmDataConvert(simdat)

## Create nlmixr model object
f <- pkpdsim_to_nlmixr(
  model = mod,
  parameters = par,
  omega = c(0.1, 0.05, 0.1),
  res_var = list(prop = 0.1, add = 0.1),
  log_transform = T)

## Perform fit using nlmixr
fit <- nlmixr(object = f,
       data = d,
       est = "saem",
       saemControl(n.burn = 100, n.em = 200))

results matching ""

    No results matching ""