Simulating BLQ values in NONMEM

When simulation concentration-time data using NONMEM, there are times when you wish to include the censoring effect of BLQ measurements from your bioanalytical laboratory. It is very easy to implement this in your NONMEM control stream. Here is how I do it.

In the $ERROR block , you will be adding your residual error to the prediction. The prediction is denoted F in NONMEM code. The individual prediction that is output as DV is denoted Y in NONMEM code. Let’s assume that the limit of quantitation is 0.1 ng/mL. The code to add at the end of your error code is the following:

Y=F + ERR(1)
IF(Y.LT.0.1) THEN
Y=0
ENDIF

The first line can vary depending on your specific residual error structure. The heavy lifting is done by the second line where the value Y is compared to the target value of 0.1 using the Fortran term for “less than” (LT). If the predicted value is less than the BLQ it will be replaced by the number zero. If the predicted value is greater than or equal to the BLQ, then the prediction does not change. You cannot assign text (eg BLQ) to the value of Y. Only numerical values are accepted. In my example I set it to zero; however, I could have assigned a value of -99999 also. Ether way I would extract these “BLQ” values from the simulated dataset before plotting the data.

Is a Monte Carlo simulation an exotic drink?

The term “Monte Carlo simulation” is often used in the modeling and simulation literature with PK/PD analysis. When I was first exposed to this term, I was thoroughly confused and thought that it was some exotic statistical method that required 3 PhDs and a few days to comprehend. Well, I was very wrong.

A Monte Carlo simulation is a simulation that utilizes the “Monte Carlo Method“. It was named after the famous Monte Carlo Casino in Monaco.

Monte Carlo Casino Monaco

Monte Carlo Casino Monaco

At the Monte Carlo Casino, people take their money and gamble on games of chance. Games of chance are based on probabilities of random events ocurring. For example, roullette is a game where a ball bounces around a spinning platform and eventually comes to rest on one of 36 spots. Players can make various bets on the chance that the ball will stop on a specific spot or spots.

You may ask, “what in the world does that have to do with simulations?!” Well, let me tell you. Prior to the Monte Carlo method, simulations were performed with specific parameter values to generate a single simulation. For example, let’s assume we have the following PK model:

 C(t)=\frac{Dose}{V}*e^{(-\frac{CL}{V}*t)}

We can predict a concentration-time curve by providing a value for CL and V. We can then do that for various combinations of CL and V. It would look something like this:

Simulation - Discrete

Discrete Simulation

This gives us 2 concentration-time curves. While this is useful, we don’t always know the exact values of CL and V for a given individual before they take the drug. What we usually know is that the CL and V have some average value along with a variance. In other words, we have a distribution of values for CL and V, with some being more likely than others. Thus instead of just choosing a few sets of values for CL and V, what if we chose many values. And what if we used the known distribution to select more likely values more often and less likely values less often? Well, we would then have a simulation that looks like this:

Monte Carlo Simulation

Monte Carlo Simulation

As output, we would get a large distribution of plasma concentration-time curves that would represent the range of possibilities, and the more likely possibilities would occur more frequently. This is extremely useful in PK/PD simulations because we can quantify both the mean response and the range of responses.

To do a Monte Carlo simulation, you simply have to have a program (like NONMEM or WinNonlin) that randomly selects a parameter value from a known distribution. Then runs the PK model and saves the output. That process is repeated many times (usually between 1,000 and 10,000 times) to generate the expected outcomes.

Hopefully you understand Monte Carlo simulations better now … and if not, you should go get an exotic drink and try reading this post again tomorrow!

What is Modeling and Simulation?

I am currently attending a short conference on modeling and simulation in pediatric clinical pharmacology, and I noticed that many people in the conference don’t have a good grasp on what “Modeling and Simulation” means. I think most of them think that it is an extremely complicated mathematical concoction that is intended to keep everyone confused and in awe of the speaker that is presenting. They couldn’t be further from the truth. But, first, let’s talk about saving money.

Imagine you are given $1,000 from a relative. You would like to use that money to “make some money”, so you put it into an investment that is guaranteed to make 8% growth annually. If you left that money there for 20 years, how much money would you have?

To solve this problem, you need to know what the future value of the principle given the 8% annual growth, compounded monthly for 20 years. There is an equation for that:

 FV=PV*(1+i)^t      Equation 1

 PV=\char36 1,000\;\;\;i=\frac {0.08}{12} = 0.00667\;\;\;t=20*12=240

 FV=\char36 1,000*(1+0.00667)^{240} = \char36 4,930.72      Equation 2

So after 20 years, you have almost 5 times as much money as you were given. The method we just worked through to determine how much we would have in the future can be thought of as modeling and simulation. Equation 1 is the model, and Equation 2 is the simulation.

I think I just heard you say, “What! It can’t be that simple! No way!” Well, it is true, the estimation of future savings is nothing more than a simulation of a known financial model for compounding interest.

Now we can convert this into the pharmaceutical world. A model is a set of mathematical equations that describe observations. In some cases the observations are plasma concentrations, in other cases it is intraocular pressure, or enzyme inhibition. The “parameters” of the model are derived from the observations. (In Equation 1, the parameters are PV, i and t.)

A simulation is when you use a model to predict something. Instead of estimating parameters from observed data, you take the model, and a set of parameters to simulate some data. As we did in Equation 2, we set PV, i and t to specific values for the desired situation, then we calculated FV. Or, in other words, we simulated FV given a set of parameters.

So, when you hear about modeling and simulation, just think about your bank savings account and remember that you and your bank do modeling and simulation every month.