메뉴 건너뛰기

김민수의 블로그

Installing NLMIXR2 on RStudio

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

I found NLMIXR2 library ( https://cran.r-project.org/web/packages/nlmixr2/index.html ), 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(nlmixr2)
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() {
  ini({
    tka <- 0.45 # Log Ka
    tcl <- 1 # Log Cl
    tv <- 3.45    # Log V
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.sd <- 0.7
  })
  # and a model block with the error sppecification and model specification
  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)
  })
}
 
## 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))
print(fit)

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 ( https://github.com/nlmixr2/nlmixr2/ ).

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",

                   "nlmixr2"),

                 repos = c('https://nlmixr2.r-universe.dev',

                           'https://cloud.r-project.org'))

And, solved!!

댓글 0개