Facilitate Pharmacokinetic (PK) and Pharmacodynamic (PD) modeling
and simulation with powerful tools for Nonlinear Mixed-Effects (NLME)
modeling. The package provides access to the same advanced Maximum Likelihood
algorithms used by the NLME-Engine in the Phoenix platform. These tools support
a range of analyses, from parametric methods to individual and pooled data, and
support integrated use within the Pirana pharmacometric workbench

R Speaks Non Linear Mixed Effects Modeling, RsNLME, is a suite of R packages and supplementary Shiny apps developed by Certara that supports pharmacometric modeling inside R.
When used together, these packages can add a level of speed and flexibility to your pharmacometrics workflow that cannot be achieved with point-and-click type tools.
Whether you're still learning R or a seasoned expert, efficiently build, execute, and analyze your models from the Shiny GUI, then generate the corresponding R code to reproduce and expand your workflow from the R command line.
Certara.RsNLME uses tidyverse syntax to generate and update pharmacometric models in R. All functions can easily be chained together using the %>% operator from magrittr. See RsNLME Examples.
library(Certara.RsNLME)
library(magrittr)
# Create two-compartment pharmacokinetic model
model <- pkmodel(numCompartments = 2, data = pkData,
ID = "Subject", Time = "Act_Time", A1 = "Amount", CObs = "Conc",
modelName = "TwCpt_IVBolus_FOCE_ELS")
# Update initial estimates
model <- model %>%
fixedEffect(effect = c("tvV", "tvCl", "tvV2", "tvCl2"), value = c(15, 5, 40, 15))
If you are still learning the command line syntax, use the Certara.RsNLME.ModelBuilder Shiny application from either RStudio or Pirana to build your NLME model from the GUI and generate the corresponding R and PML code to reproduce your model across multiple environments.
library(Certara.RsNLME)
library(Certara.RsNLME.ModelBuilder)
model <- modelBuilderUI(data = pkData)
Learn more about Certara.RsNLME.ModelBuilder here
Next, we can execute the above model we created from the Shiny GUI inside R using the command fitmodel():
job <- fitmodel(model)
print(job$Overall)
Scenario RetCode LogLik -2LL AIC BIC nParm nObs nSub EpsShrinkage Condition
1: WorkFlow 1 -632.7953 1265.591 1283.591 1308.057 9 112 16 0.17297 3.34287
Or alternatively, use the Certara.RsNLME.ModelExecutor Shiny application to specify additional engine arguments, change the estimation algorithm, add output tables, and more - all from the Shiny GUI!
library(Certara.RsNLME.ModelExecutor)
modelExecutorUI(model)
Learn more about Certara.RsNLME.ModelExecutor here
After executing the model, we use the Certara.Xpose.NLME, xpose, ggplot2, and flextable packages to generate our model diagnostic plots.
library(Certara.Xpose.NLME)
library(xpose)
library(ggplot2)
xpdb <- xposeNlmeModel(model, job)
res_vs_idv(xpdb) +
theme_classic()
Learn more about Certara.Xpose.NLME here
Or alternatively, use the Certara.ModelResults Shiny application to easily preview, customize, and report model diagnostics plots and tables from the Shiny GUI. Furthermore, the application will generate the corresponding .R and .Rmd code to reproduce your model diagnostics.
library(Certara.ModelResults)
resultsUI(model)
Learn more about Certara.ModelResults here
Lastly, users can execute a vpcmodel() to generate a Visual Predictive Check (VPC) plot and assess model fit.
Using the Certara.RsNLME package, we will execute the function vpcmodel() to return our observed and simulated data used to generate our VPC. Pass the fitted model (the model carries its final estimates after fitmodel()) so the simulation uses the estimated parameters.
library(Certara.RsNLME)
vpcJob <- vpcmodel(model)
Next we'll extract our observed and simulated data from the return value of vpcmodel().
obs_data <- vpcJob$predcheck0
sim_data <- vpcJob$predout
Then we can use the tidyvpc package to parameterize our VPC. The tidyvpc arguments are yobs/ysim (the observed and simulated response), not y, and the VPC object is rendered with plot() (there is no vpc_plot()).
library(tidyvpc)
library(magrittr)
vpc <- observed(obs_data, x = IVAR, yobs = DV) %>%
simulated(sim_data, ysim = DV) %>%
binless() %>%
vpcstats()
plot(vpc)
Learn more about tidyvpc here
Or alternatively, use the Certara.VPCResults Shiny application to easily parameterize, customize, and report VPC plots from the Shiny GUI. Furthermore, the application will generate the corresponding .R and .Rmd code to reproduce your VPC's in R.
vpcResultsUI(obs_data, sim_data)
Learn more about Certara.VPCResults here