Skip to menu

Min-Soo Kim's blog

Installing NLMIXR2 on RStudio

I am learning popPK through books. So, I wanted to get tangible examples for the practice.

I found NLMIXR2 library ( ), and I got a problem executing the reference example code on the manual.

I was using R 4.2.3 on RStudio, Windows 11.

An example code is below:

library(nlmixr2data) #### MIN-SOO KIM: I think I need to define theo_sd on the line 27
## The basic model consiss of an ini block that has initial estimates
one.compartment <- function() {
    tka <- 0.45 # Log Ka
    tcl <- 1 # Log Cl
    tv <- 3.45    # Log V
    eta.ka ~ 0.6 ~ 0.3
    eta.v ~ 0.1 <- 0.7
  # and a model block with the error sppecification and model specification
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl +
    v <- exp(tv + eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center
    cp = center / v
    cp ~ add(
## The fit is performed by the function nlmixr/nlmix2 specifying the model, data and estimate
fit <- nlmixr2(one.compartment, theo_sd,  est="saem", saemControl(print=0))

And I goe an error message as below:

> fit <- nlmixr2(one.compartment, theo_sd,  est="saem", saemControl(print=0))
 parameter labels from comments will be replaced by 'label()'
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 1, 0
Error: arguments imply differing number of rows: 1, 0

Since I had no idea what I needed to do next, I checked if there were some mistakes in the installation. I ran 'nlmixr2CheckInstall' method (below).

image001 (002).png


I could not resolve the error, and I sent an email to Matthew Fidler who was the maintainer of the project ( ).

Matthew replied that some of the packages on CRAN were out of sync, and gave me a code. According to the reply from Matthew, I reinstall them using the code below:

install.packages(c("dparser", "nlmixr2data", "lotri", "rxode2ll",

                   "rxode2parse", "rxode2random", "rxode2et",

                   "rxode2", "nlmixr2est", "nlmixr2extra", "nlmixr2plot",


                 repos = c('',


And, solved!!

Comment 0개