Using NONMEM to fit IV and oral data simultaneously

After learning how to use the nonlinear mixed effects modeling software NONMEM, one of the first things I tried to do was estimate the absolute bioavailability of a drug that I was working with. I had PK data following IV administration and following subcutaneous injection in monkeys. Using non-compartmental methods I calculated the bioavailability by calculating the ratio of the mean AUC for both routes of administration. While this method was perfectly acceptable, I was attracted the the possibility that I could use all of the data together to derive not only the pharmacokinetic parameters (CL, V, F, and ka) but also the variability in each parameter using NONMEM. Unfortunately the only way to figure out how to do this in NONMEM was ask a NONMEM expert to help me, or spend time working through the NONMEM manuals.

So when a recent email from PharmPK arrived with the folowing question:

Can anybody provide me nonmem script for simultaneous fit of IV and Oral data (population pharmacokinetic modeling) to derive parameters ka and F ?

I decided that I would post not only an answer (the NONMEM control stream and a sample data file), but I would add an explanation of how I was able to arrive at the answer. I hope that the combination of the explanation along with the files will help others understand what to do … and why.

Before we start, let’s make some assumptions:

  1. The IV data follows a 1 compartment model with constant clearance.
  2. The oral data follows a first-order elimination and first-order absorption model.

Given these assumptions, let’s draw the compartmental models that we are considering for the 2 routes of administration:

IV model Oral model
IV model Oral model
Click to enlarge Click to enlarge

Both models exhibit elimination from a central compartment with PK parameters for the dose, volume of distribution (V) and the clearance (CL) from the central compartment. The oral model has the additional PK parameters for the absorption rate (ka) and the bioavailability (F).

The IV model corresponds to ADVAN1 in NONMEM. The ADVAN1 help reads:

Compt. No. Function Initial Status On/Off Allowed Dose Allowed Default for Dose Default for Obs.
1 Central On No Yes Yes Yes
2 Output Off Yes No No No

The headers mean the following:

  • Comp. No. = Compartment number
  • Function = Type of compartment (e.g. central peripheral, or output [urine])
  • Initial Status = Ability to set the initial status of a compartment to a value (On = Yes, Off = No)
  • On/Off Allowed = Ability to turn on or off the compartment. On means NONMEM will calculate values in that compartment, and Off means that NONMEM will ignore that compartment.
  • Dose Allowed = Ability to add a dose to the compartment
  • Default for Dose = If no other information is provided, the compartment with Yes will be assumed to be the dosing compartment.
  • Default for Obs. = If no other information is provided, the compartment with Yes will be assumed to have the drug measurements.

For ADVAN1, the dose is given to compartment 1, and drug measurements are made in compartment 1.

Now the oral model corresponds to ADVAN2 in NONMEM, and that help reads:

Compt. No. Function Initial Status On/Off Allowed Dose Allowed Default for Dose Default for Obs.
1 Depot Of Yes Yes Yes No
2 Central On No Yes No Yes
3 Output Off Yes No No No

For ADVAN2, the dose is given in compartment 1, and drug measurements are made in compartment 2. In addition, it is possible to dose in compartment 2, but that is not the default dosing compartment.

So when initially looking at these, it appears that we need to use 2 different ADVANs to run our model in NONMEM … and, unfortunately, that is impossible in NONMEM. So what is the solution? Well, the solution is the little detail in ADVAN2 about the ability to dose to compartment 2. Pretend for a minute that compartment 1 of ADVAN2 is missing. The rows for compartments 2 and 3 look almost identical to those in ADVAN1. What we need to do is trick NONMEM by using an oral model (ADVAN2), but giving an IV dose. This is accomplished by building your dataset appropriately using the compartment (CMT) variable to tell NONMEM where you want to dose the drug. For IV you will want to dose in compartment 2 (CMT = 2), but for Oral, you will want to dose in compartment 1 (CMT = 1). All concentration measurements should be assigned to compartment 2 (CMT = 2). All other aspects of your datafile should follow NONMEM standards. For ease of analysis, you may want to include a variable that identifies which individuals (or treatments if a crossover study) are on IV and which are on Oral (e.g. RTE = 1 or 2; 1 = IV, 2 = Oral). A sample dataset is here.

Now that your dataset is ready, you need to construct a control stream that will calculate the desired parameters. A sample file is here. The PK block should look like this:

$PK
KA=THETA(1)*EXP(ETA(1))
CL=THETA(2)*EXP(ETA(2))
V=THETA(3)*EXP(ETA(3))
F1=THETA(4)*EXP(ETA(4))
S2=V/1000

For subjects receiving an oral dose, all 4 parameters will be estimated. For subjects receiving an IV dose, only CL and V will be estimated. One advantage of this method of simultaneously fitting IV and oral data is the ability to leverage both datasets (IV and oral) to estimate the clearance and volume of distribution. In turn, this leads to more accurate estimates for the absorption rate constant and the bioavailability.

Please note that I did not fit the sample datset/control stream in NONMEM. The dataset was small (only 2 subjects) and thus some characteristics of the model (e.g. etas) are not reasonable. The samples files are intended to provide the reader a working file with the proper structure.

Good luck, and I hope this helps!

What are compartmental models?

Almost everyone familiar with pharmaceuticals has heard a conversation like this before:

Scientist 1: “What are the pharmacokinetics of Drug X?”

Scientist 2: “Drug X follows a 1-compartment model in rats, but in monkeys it tends to have a distribution phase and seems to follow 2-compartment kinetics.”

Scientist 1: Thinks to himself/herself …’What does a compartment have to do with this! A compartment is something you find in a train!’

Compartments are an important concept in pharmacokinetics (and pharmacodynamics), but they are rarely explained to other scientists. Hopefully this post will demystify the idea of compartments and show you that the concept of compartments is simple.

Human heart

Human Heart

To understand compartments, think about your heart for a minute. A human heart has 4 distinct chambers, each with a specific function (above image from stacyycats.com). Blood, which has been depleted of oxygen returns through the veins to the right atrium. It is then transferred to the right ventricle. The right ventricle pumps the blood into the lungs and then the blood moves into the left atrium. Finally the blood moves into the left ventricle which pushes the blood through the arteries of the body to distribute the oxygenated blood to all of the organs and tissues of the body. Each chamber of the heart has a specific function, and there is a specific flow of blood involved. The following schematic depicts the 4 chambers of the heart along with the direction of blood flow.

Heart Chambers

Heart Chambers Model

As you can see, the blood has unidirectional flow from one chamber to the next. In other words, the blood does not move from the right ventricle back into the right atrium (at least it doesn’t happen with a normal, healthy heart!). If this makes sense to you, then you now understand the idea of compartments. In a very real way, the chambers of the heart are separate “compartments” that the blood passes through.

In pharmacokinetics we don’t use tangible “compartments” like the chambers of the heart. Instead we use theoretical, or imaginary “compartments”. If you were to draw a picture of all the organs and tissues of the body, each as a separate compartment, it would look something like this (image from dougneubauer.com):

Physiologic-based PK model

Physiologic-based PK model

Even this model is a bit simplistic for the body, are all muscles the same? What is the “Rest” of the body? Clearly, if we tried to identify every single different tissue in the body, we would have infinite “compartments” in our model. Pharmacokineticists like to simplify things significantly. Thus, instead of defining tangible compartments, we design theoretical compartments with *unique* names like 1, 2, 3, central, peripheral, etc. (I hope you noticed the sarcasm!). Then we draw arrows between these compartments to show how the drug travels from one compartment to the other. Here are 2 examples:

1 Compartment Model

1-Compartment Model

2 Compartment Model

2-Compartment Model

1-Compartment Model

  • Drug enters the central compartment (or compartment 1) from somewhere outside of the body.
  • Drug then leaves the central compartment. This is analogous to the drug leaving the body.
  • Drug recirculation does not occur (output line does not reconnect with input line).
  • The 1-compartment model considers the entire body, and all of the organs and tissues to be one giant bucket.

2-Compartment Model

  • Drug enters the central compartment (or compartment 1) from somewhere outside of the body.
  • Drug then leaves the central compartment by one of two paths:
    • the peripheral compartment (also called compartment 2) or
    • drug leaves the body
  • Drug that is in the peripheral compartment can return to the central compartment.
  • Drug recirculation occurs between the central and peripheral compartment, but once drug leaves the body, it does not re-enter the body.
  • The 2-compartment model considers the entire body, and all of the organs and tissues to be two buckets, but all drug must leave the body through a single bucket.

In many ways the compartmental models are very similar to the heart chamber model. These models show movement from one “chamber” to another. The 2 key differences are that the pharmacokinetic models are not closed systems (drug is not recirculated from output to input); and pharmacokinetic models permit bi-directional movement (the heart chamber model only allows unidirectional movement).

Hopefully you now understand what is meant by compartmental models in pharmacokinetics. In essence, the number (1, 2, 3) refers to the number of circles drawn on the paper. Many may be asking why we use compartment models in pharmacokinetics. The brief answer is that the mathematical functions associated with compartment models seem to describe the observed data very well. It is for practical reasons, not physiologic reasons that we use compartmental models. I will leave the detailed explanation for another blog post.