Dear NONMEM Users,
I have some questions about how to accomplish the following tasks in NONMEM,
would you kindly share your experience with me or provide some suggestions? I'm
trying to make a simulation that involves dynamic dosing. Here is the algorithm
of simulation: at time 0, a dose is given, then the time to the first event
will be simulated based on a certain survival function which depends on the
drug exposure. Next, conditioning on that simulated first event time, a second
dose will be introduced, and again time to the second event will be simulated.
This will be repeated until a certain cut off time point.
My specific questions are:
1. since the dosing history will be depending on the simulated event time, I
cannot construct the dosing history in NONMEM data set a prior, how can this be
done?
2. The survival function is a function of the time-varying drug exposure,
therefore I need to inverse an integral which does not have a closed form (i.e.
only expressed in differential equation), how can I do that?
Your help will be much appreciated!
Yaming Hang
seeking help on NONMEM code for simulation of Repeated Time to Event Data
7 messages
5 people
Latest: Apr 04, 2013
Hi Yaming,
In a general sense, the two things that you're wanting to do are likely
straight-forward with NONMEM.
For the dosing, as long as you're dosing at the same time and its the dose
amount that is changing, you can make F1 dependent on your event (e.g. to stop
dosing after the event, set F1 to 0; to double or halve dosing set it to 2 or
0.5). You can keep track of if the event happened by using an indicator
variable that is initialized on the first initialization of the subject. That
would be something like:
IF (NEWIND.EQ.1) EVNT=0
Then set EVNT=1 when your event happens (or more complex values, but using EVNT
values as your indicator).
To have the continual accumulation, you can use DES with a compartment that has
accumulation from a model parameter like the following:
$PRED
...
ACC=THETA(1)
...
$DES
DADT(4)=ACC
If you need to reset the accumulator compartment and the event happens at
arbitrary times, that is a bit more complex, and the best solution that I can
think of is to save the current accumulator amount into a variable when the
event happens and make your event dependent on the amount in the accumulator
compartment minus the amount at the previous event.
Thanks,
Bill
Quoted reply history
On Apr 3, 2013, at 5:17 PM, "Yaming Hang"
<[email protected]<mailto:[email protected]>> wrote:
Dear NONMEM Users,
I have some questions about how to accomplish the following tasks in NONMEM,
would you kindly share your experience with me or provide some suggestions? I’m
trying to make a simulation that involves dynamic dosing. Here is the algorithm
of simulation: at time 0, a dose is given, then the time to the first event
will be simulated based on a certain survival function which depends on the
drug exposure. Next, conditioning on that simulated first event time, a second
dose will be introduced, and again time to the second event will be simulated.
This will be repeated until a certain cut off time point.
My specific questions are:
1. since the dosing history will be depending on the simulated event time, I
cannot construct the dosing history in NONMEM data set a prior, how can this be
done?
2. The survival function is a function of the time-varying drug exposure,
therefore I need to inverse an integral which does not have a closed form (i.e.
only expressed in differential equation), how can I do that?
Your help will be much appreciated!
Yaming Hang
Yaming
Could you, please, add some more details about the procedure to determine the time of the event/dose. Is it some numerical integral of hazard, and when it reaches some value (integral from 0 to T0) then the dose is given at T0 ? Or you can determine it earlier, say by time T1 < T0 (where T1 is known in advance)?
Leonid
--------------------------------------
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web: www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel: (301) 767 5566
Quoted reply history
On 4/3/2013 4:35 PM, Yaming Hang wrote:
> Dear NONMEM Users,
>
> I have some questions about how to accomplish the following tasks in
> NONMEM, would you kindly share your experience with me or provide some
> suggestions? I’m trying to make a simulation that involves dynamic
> dosing. Here is the algorithm of simulation: at time 0, a dose is given,
> then the time to the first event will be simulated based on a certain
> survival function which depends on the drug exposure. Next, conditioning
> on that simulated first event time, a second dose will be introduced,
> and again time to the second event will be simulated. This will be
> repeated until a certain cut off time point.
>
> My specific questions are:
>
> 1. since the dosing history will be depending on the simulated event
> time, I cannot construct the dosing history in NONMEM data set a prior,
> how can this be done?
>
> 2. The survival function is a function of the time-varying drug
> exposure, therefore I need to inverse an integral which does not have a
> closed form (i.e. only expressed in differential equation), how can I do
> that?
>
> Your help will be much appreciated!
>
> Yaming Hang
Yaming,
You may wish to consult this document for details of coding time to event models using NM-TRAN.
http://holford.fmhs.auckland.ac.nz/docs/time-to-event-webinar.pdf
It is really very simple to integrate the hazard numerically using $DES. If you are dealing with only one event per subject then there are no random effects to be estimated in the model and it will run quite quickly with the FO estimation method.
Best wishes,
Nick
Quoted reply history
On 4/04/2013 9:35 a.m., Yaming Hang wrote:
> Dear NONMEM Users,
>
> I have some questions about how to accomplish the following tasks in NONMEM, would you kindly share your experience with me or provide some suggestions? I’m trying to make a simulation that involves dynamic dosing. Here is the algorithm of simulation: at time 0, a dose is given, then the time to the first event will be simulated based on a certain survival function which depends on the drug exposure. Next, conditioning on that simulated first event time, a second dose will be introduced, and again time to the second event will be simulated. This will be repeated until a certain cut off time point.
>
> My specific questions are:
>
> 1. since the dosing history will be depending on the simulated event time, I cannot construct the dosing history in NONMEM data set a prior, how can this be done?
>
> 2. The survival function is a function of the time-varying drug exposure, therefore I need to inverse an integral which does not have a closed form (i.e. only expressed in differential equation), how can I do that?
>
> Your help will be much appreciated!
>
> Yaming Hang
--
Nick Holford, Professor Clinical Pharmacology
Dept Pharmacology & Clinical Pharmacology, Bldg 503 Room 302A
University of Auckland,85 Park Rd,Private Bag 92019,Auckland,New Zealand
tel:+64(9)923-6730 fax:+64(9)373-7090 mobile:+64(21)46 23 53
email: [email protected]
http://www.fmhs.auckland.ac.nz/sms/pharmacology/holford
Dear Leonid, Nick and Bill,
Thank you very much for responding to my question! Sorry my original question
was not detailed enough, let me try it again:
I have a hazard function h(t) which is concentration dependent:
h(t)=h0(t)*(1-CP(t)/(EC50+CP(t))), where CP(t) is the drug exposure at time t,
h0(t) is the baseline hazard function without drug (may be a constant).
Definition of EC50 is as usual.
The cumulative hazard H(t) is integral of h(x) from time 0 to t, and the
survival function S(t)=exp(-H(t)).
Let's make it simple, assume the concentration follows a one-compartment model
and it's a bolus IV dose, CL and V are known. Also assume h0(t) is a constant
lambda, along with EC50 are known. Every time a dose is introduced, the amount
is the same. Here is how I intend to simulate the event (repeated) history for
one subject:
At time 0, a unit dose is introduced, CP(t) can be determined, therefore S(t)
can be determined (maybe through the $DES, not necessarily a closed form). The
time of first event will be simulated by first generating a random number u1
from Uniform[0,1], and then solve the equation S(t1)=u1. That's why I need to
inverse the survival function. Right at time t1 following the first event, I'll
introduce another unit dose. Because most likely the concentration coming from
the first dose has not reached zero by time t1, the survival function starting
from t1 could be different than the survival function starting from the first
dose (time 0). I'll follow the same procedure to simulate a t2, which is the
time from first event to second event, and another unit dose will be introduced
at time t1+t2. This process will continue until a certain cut-off time point
has been met. That's why I said the dosing is dynamic.
Hope this time I've stated it clear enough. It's just one thought on how to do
the simulation, I'd like to get some advice on how this can be accomplished in
NONMEM.
Kind Regards,
Yaming
Quoted reply history
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Leonid Gibiansky
Sent: Wednesday, April 03, 2013 5:39 PM
To: Yaming Hang
Subject: Re: [NMusers] seeking help on NONMEM code for simulation of Repeated
Time to Event Data
Yaming
Could you, please, add some more details about the procedure to determine the
time of the event/dose. Is it some numerical integral of hazard, and when it
reaches some value (integral from 0 to T0) then the dose is given at T0 ? Or
you can determine it earlier, say by time T1 <
T0 (where T1 is known in advance)?
Leonid
--------------------------------------
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web: www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel: (301) 767 5566
On 4/3/2013 4:35 PM, Yaming Hang wrote:
> Dear NONMEM Users,
>
> I have some questions about how to accomplish the following tasks in
> NONMEM, would you kindly share your experience with me or provide some
> suggestions? I'm trying to make a simulation that involves dynamic
> dosing. Here is the algorithm of simulation: at time 0, a dose is
> given, then the time to the first event will be simulated based on a
> certain survival function which depends on the drug exposure. Next,
> conditioning on that simulated first event time, a second dose will be
> introduced, and again time to the second event will be simulated. This
> will be repeated until a certain cut off time point.
>
> My specific questions are:
>
> 1. since the dosing history will be depending on the simulated event
> time, I cannot construct the dosing history in NONMEM data set a
> prior, how can this be done?
>
> 2. The survival function is a function of the time-varying drug
> exposure, therefore I need to inverse an integral which does not have
> a closed form (i.e. only expressed in differential equation), how can
> I do that?
>
> Your help will be much appreciated!
>
> Yaming Hang
>
Hi Yaming,
I have not done it so I do not have the code, but here is the possible way
1. There is an ADVAN9 routine that allows for equilibrium compartments. Equilibrium compartment is essentially a solution of something like S(t)=u1, or it possibly can be tricked to solving this equation. Another possibility is to add the external fortran code to solve algebraic equation.
2. For dose, I cannot think of the way to have dose event at the dynamically determined time. But this can be implemented by something like a delta function (short impulse with high rate) to the right-hand side of the differential equation. It will not be bolus but it can be short infusion with high rate. The time of infusion start can be controlled on the fly, in $DES block
CODE = 0
IF(T > T1 and T < T1+duration) CODE = 1
DADT()= P*CODE
where duration is a parameter (1 hour, 1 min, whatever is short in your scale but preferably large relative to the integration steps) and P=DOSE/duration.
Not straightforward but doable
Leonid
--------------------------------------
Leonid Gibiansky, Ph.D.
President, QuantPharm LLC
web: www.quantpharm.com
e-mail: LGibiansky at quantpharm.com
tel: (301) 767 5566
Quoted reply history
On 4/4/2013 11:16 AM, Yaming Hang wrote:
> Dear Leonid, Nick and Bill,
>
> Thank you very much for responding to my question! Sorry my original question
> was not detailed enough, let me try it again:
>
> I have a hazard function h(t) which is concentration dependent:
> h(t)=h0(t)*(1-CP(t)/(EC50+CP(t))), where CP(t) is the drug exposure at time t,
> h0(t) is the baseline hazard function without drug (may be a constant).
> Definition of EC50 is as usual.
>
> The cumulative hazard H(t) is integral of h(x) from time 0 to t, and the
> survival function S(t)=exp(-H(t)).
>
> Let's make it simple, assume the concentration follows a one-compartment model
> and it's a bolus IV dose, CL and V are known. Also assume h0(t) is a constant
> lambda, along with EC50 are known. Every time a dose is introduced, the amount
> is the same. Here is how I intend to simulate the event (repeated) history for
> one subject:
>
> At time 0, a unit dose is introduced, CP(t) can be determined, therefore S(t)
> can be determined (maybe through the $DES, not necessarily a closed form). The
> time of first event will be simulated by first generating a random number u1
> from Uniform[0,1], and then solve the equation S(t1)=u1. That's why I need to
> inverse the survival function. Right at time t1 following the first event, I'll
> introduce another unit dose. Because most likely the concentration coming from
> the first dose has not reached zero by time t1, the survival function starting
> from t1 could be different than the survival function starting from the first
> dose (time 0). I'll follow the same procedure to simulate a t2, which is the
> time from first event to second event, and another unit dose will be introduced
> at time t1+t2. This process will continue until a certain cut-off time point
> has been met. That's why I said the dosing is dynamic.
>
> Hope this time I've stated it clear enough. It's just one thought on how to do
> the simulation, I'd like to get some advice on how this can be accomplished in
> NONMEM.
>
> Kind Regards,
> Yaming
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Leonid Gibiansky
> Sent: Wednesday, April 03, 2013 5:39 PM
> To: Yaming Hang
> Subject: Re: [NMusers] seeking help on NONMEM code for simulation of Repeated
> Time to Event Data
>
> Yaming
> Could you, please, add some more details about the procedure to determine the time
> of the event/dose. Is it some numerical integral of hazard, and when it reaches
> some value (integral from 0 to T0) then the dose is given at T0 ? Or you can
> determine it earlier, say by time T1 <
> T0 (where T1 is known in advance)?
> Leonid
>
> --------------------------------------
> Leonid Gibiansky, Ph.D.
> President, QuantPharm LLC
> web: www.quantpharm.com
> e-mail: LGibiansky at quantpharm.com
> tel: (301) 767 5566
>
> On 4/3/2013 4:35 PM, Yaming Hang wrote:
>
> > Dear NONMEM Users,
> >
> > I have some questions about how to accomplish the following tasks in
> > NONMEM, would you kindly share your experience with me or provide some
> > suggestions? I'm trying to make a simulation that involves dynamic
> > dosing. Here is the algorithm of simulation: at time 0, a dose is
> > given, then the time to the first event will be simulated based on a
> > certain survival function which depends on the drug exposure. Next,
> > conditioning on that simulated first event time, a second dose will be
> > introduced, and again time to the second event will be simulated. This
> > will be repeated until a certain cut off time point.
> >
> > My specific questions are:
> >
> > 1. since the dosing history will be depending on the simulated event
> > time, I cannot construct the dosing history in NONMEM data set a
> > prior, how can this be done?
> >
> > 2. The survival function is a function of the time-varying drug
> > exposure, therefore I need to inverse an integral which does not have
> > a closed form (i.e. only expressed in differential equation), how can
> > I do that?
> >
> > Your help will be much appreciated!
> >
> > Yaming Hang
Hi Yaming,
Another approach is to fill your dataset with dummy doses and then only set F to a non-zero value in your code whenever you actually need a dose. It's a little clumsy but it can work quite well, especially if you know a dose can only occur at a finite number of visits to the clinic.
Best regards, James
Quoted reply history
On 04/04/2013 16:36, Leonid Gibiansky wrote:
> Hi Yaming,
>
> I have not done it so I do not have the code, but here is the possible way
>
> 1. There is an ADVAN9 routine that allows for equilibrium compartments. Equilibrium compartment is essentially a solution of something like S(t)=u1, or it possibly can be tricked to solving this equation. Another possibility is to add the external fortran code to solve algebraic equation.
>
> 2. For dose, I cannot think of the way to have dose event at the dynamically determined time. But this can be implemented by something like a delta function (short impulse with high rate) to the right-hand side of the differential equation. It will not be bolus but it can be short infusion with high rate. The time of infusion start can be controlled on the fly, in $DES block
>
> CODE = 0
> IF(T > T1 and T < T1+duration) CODE = 1
>
> DADT()= P*CODE
>
> where duration is a parameter (1 hour, 1 min, whatever is short in your scale but preferably large relative to the integration steps) and P=DOSE/duration.
>
> Not straightforward but doable
>
> Leonid
>
> --------------------------------------
> Leonid Gibiansky, Ph.D.
> President, QuantPharm LLC
> web: www.quantpharm.com
> e-mail: LGibiansky at quantpharm.com
> tel: (301) 767 5566
>
> On 4/4/2013 11:16 AM, Yaming Hang wrote:
>
> > Dear Leonid, Nick and Bill,
> >
> > Thank you very much for responding to my question! Sorry my original question was not detailed enough, let me try it again:
> >
> > I have a hazard function h(t) which is concentration dependent: h(t)=h0(t)*(1-CP(t)/(EC50+CP(t))), where CP(t) is the drug exposure at time t, h0(t) is the baseline hazard function without drug (may be a constant). Definition of EC50 is as usual.
> >
> > The cumulative hazard H(t) is integral of h(x) from time 0 to t, and the survival function S(t)=exp(-H(t)).
> >
> > Let's make it simple, assume the concentration follows a one-compartment model and it's a bolus IV dose, CL and V are known. Also assume h0(t) is a constant lambda, along with EC50 are known. Every time a dose is introduced, the amount is the same. Here is how I intend to simulate the event (repeated) history for one subject:
> >
> > At time 0, a unit dose is introduced, CP(t) can be determined, therefore S(t) can be determined (maybe through the $DES, not necessarily a closed form). The time of first event will be simulated by first generating a random number u1 from Uniform[0,1], and then solve the equation S(t1)=u1. That's why I need to inverse the survival function. Right at time t1 following the first event, I'll introduce another unit dose. Because most likely the concentration coming from the first dose has not reached zero by time t1, the survival function starting from t1 could be different than the survival function starting from the first dose (time 0). I'll follow the same procedure to simulate a t2, which is the time from first event to second event, and another unit dose will be introduced at time t1+t2. This process will continue until a certain cut-off time point has been met. That's why I said the dosing is dynamic.
> >
> > Hope this time I've stated it clear enough. It's just one thought on how to do the simulation, I'd like to get some advice on how this can be accomplished in NONMEM.
> >
> > Kind Regards,
> > Yaming
> >
> > -----Original Message-----
> >
> > From: [email protected] [ mailto: [email protected] ] On Behalf Of Leonid Gibiansky
> >
> > Sent: Wednesday, April 03, 2013 5:39 PM
> > To: Yaming Hang
> >
> > Subject: Re: [NMusers] seeking help on NONMEM code for simulation of Repeated Time to Event Data
> >
> > Yaming
> >
> > Could you, please, add some more details about the procedure to determine the time of the event/dose. Is it some numerical integral of hazard, and when it reaches some value (integral from 0 to T0) then the dose is given at T0 ? Or you can determine it earlier, say by time T1 <
> >
> > T0 (where T1 is known in advance)?
> > Leonid
> >
> > --------------------------------------
> > Leonid Gibiansky, Ph.D.
> > President, QuantPharm LLC
> > web: www.quantpharm.com
> > e-mail: LGibiansky at quantpharm.com
> > tel: (301) 767 5566
> >
> > On 4/3/2013 4:35 PM, Yaming Hang wrote:
> >
> > > Dear NONMEM Users,
> > >
> > > I have some questions about how to accomplish the following tasks in
> > > NONMEM, would you kindly share your experience with me or provide some
> > > suggestions? I'm trying to make a simulation that involves dynamic
> > > dosing. Here is the algorithm of simulation: at time 0, a dose is
> > > given, then the time to the first event will be simulated based on a
> > > certain survival function which depends on the drug exposure. Next,
> > > conditioning on that simulated first event time, a second dose will be
> > > introduced, and again time to the second event will be simulated. This
> > > will be repeated until a certain cut off time point.
> > >
> > > My specific questions are:
> > >
> > > 1. since the dosing history will be depending on the simulated event
> > > time, I cannot construct the dosing history in NONMEM data set a
> > > prior, how can this be done?
> > >
> > > 2. The survival function is a function of the time-varying drug
> > > exposure, therefore I need to inverse an integral which does not have
> > > a closed form (i.e. only expressed in differential equation), how can
> > > I do that?
> > >
> > > Your help will be much appreciated!
> > >
> > > Yaming Hang
--
James G Wright PhD,
Scientist, Wright Dose Ltd
Tel: UK (0)772 5636914