# Delayed differential equations

**URL:** <https://forum.certara.com/t/delayed-differential-equations/2945>\
**Category:** Modelling and Simulation\
**Created:** [March 24, 2016, 7:05pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945 "2016-03-24T19:05:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![douglasferguson](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@douglasferguson](https://forum.certara.com/u/douglasferguson)\
**Post date:** [March 24, 2016, 7:05pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945/1 "2016-03-24T19:05:37Z")

</div>

Is there any way to code delayed differential equations in Phoenix?

I would like to explore cell lifespan based indirect response models - where the ‘rate out’ at time t equals the ‘rate in’ at the earlier time t-X (where X would be the lifespan)

This would mean that the differential equation would be something like this

d(A1)/dt = Kin(at t) - Kin(at t-X)

Is this possible with Phoenix?

---

<div class="post-metadata">

**Author:** ![minhaj](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@minhaj](https://forum.certara.com/u/minhaj)\
**Post date:** [March 24, 2016, 7:57pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945/2 "2016-03-24T19:57:43Z")

</div>

> [@douglasferguson](#):
>
> Is there any way to code delayed differential equations in Phoenix?
> 
> I would like to explore cell lifespan based indirect response models - where the ‘rate out’ at time t equals the ‘rate in’ at the earlier time t-X (where X would be the lifespan)
> 
> This would mean that the differential equation would be something like this
> 
> d(A1)/dt = Kin(at t) - Kin(at t-X)
> 
> Is this possible with Phoenix?

Dear colleague

Usually the delay is due to the rate in and out depending on the concentration of the drug at time t and time t-tlag.

In that situation the code attached should make it.

The idea is that the mass balance for PD is defined as kin_f(C(t)) -kin_f(C(t-tlag))

where f(C(t)) is a function of the drug level at time t while f(C(t-tlag)) is a function of the drug level at time t-tlag.

Before giving the drug we have E0=kin\*tlag

You do a copy of your dose column one that is used at time 0 and one that is used at time tlag.

Look at the code and let me know if it is clear.

best Regards

Serge

Best

Serge

[delay\_PD\_EXAMPLE.phxproj](https://forum.certara.com/uploads/short-url/8ke2MoqibTf5pZucWyJiCkrYulr.phxproj) (145 KB)

---

<div class="post-metadata">

**Author:** ![wrubas](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@wrubas](https://forum.certara.com/u/wrubas)\
**Post date:** [May 6, 2016, 8:26pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945/3 "2016-05-06T20:26:13Z")

</div>

> [@minhaj](#):
>
> Dear colleague
> 
> Usually the delay is due to the rate in and out depending on the concentration of the drug at time t and time t-tlag.
> 
> In that situation the code attached should make it.
> 
> The idea is that the mass balance for PD is defined as kin_f(C(t)) -kin_f(C(t-tlag))
> 
> where f(C(t)) is a function of the drug level at time t while f(C(t-tlag)) is a function of the drug level at time t-tlag.
> 
> Before giving the drug we have E0=kin\*tlag
> 
> You do a copy of your dose column one that is used at time 0 and one that is used at time tlag.
> 
> Look at the code and let me know if it is clear.
> 
> best Regards
> 
> Serge
> 
> Best
> 
> Serge

I have a similar problem. Looking your structure, it appears to me that the delay is in PK but not PD. But what if the response is delayed (Transduction model)? From a mechanistic point I have receptor binding, signaling followed by a measurable response, thus there is a delay in PD. Not sure how to integrate this concept in Phoenix.

Thanks

---

<div class="post-metadata">

**Author:** ![minhaj](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@minhaj](https://forum.certara.com/u/minhaj)\
**Post date:** [May 7, 2016, 4:30pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945/4 "2016-05-07T16:30:55Z")

</div>

[quote=“wrubas, username:wrubas”]

I have a similar problem. Looking your structure, it appears to me that the delay is in PK but not PD. But what if the response is delayed (Transduction model)? From a mechanistic point I have receptor binding, signaling followed by a measurable response, thus there is a delay in PD. Not sure how to integrate this concept in Phoenix.

Thanks

[/quote]Here is an example that explains how to put a delay in PD. the idea is to use transit compartments where the upstream compt is the one that gets the production of PD affected by PK exposure.  
We can also use the transit compt statement (new) if the number of transit compartment is variable and/or not integer.  
If you need help, let me know with that new feature.  
I could not attach a project but will try again.  
best  
Serge

test(){  
deriv(A1 = - (Cl \* C)- (Cl2 \* (C - C2)) + (Aa \* Ka))  
urinecpt(A0 = (Cl \* C))  
deriv(A2 = (Cl2 \* (C - C2)))  
deriv(Aa = - (Aa \* Ka))  
deriv(pd0 = KIN\*(1-EFFC)\*(1+EFFE)- (pd0 \* ktr))  
deriv(pd1 = (pd0 \* ktr)- (pd1 \* ktr))  
deriv(pd2 = (pd1 \* ktr)- (pd2 \* ktr))

sequence{pd0=KIN/ktr  
pd1=KIN/ktr  
pd2=KIN/ktr  
platelet=KIN/kdeg}  
deriv(carboplatin = - (carboplatin \* KC))  
urinecpt(carboeli = (carboplatin \* KC))  
deriv(platelet = - (platelet \* kdeg) + (pd2 \* ktr))  
urinecpt(plateletoutput = (platelet \* kdeg))  
C = A1 / V  
C2 = A2 / V2  
error(CEps = 0.1)  
observe(CObs = C \* (1 + CEps))  
dosepoint(Aa)

pd0graph=pd0  
pd1graph=pd1  
pd2graph=pd2  
plateletgraph=platelet

dosepoint(carboplatin)  
EFFC = SLPC_carboplatin  
carboplatingraph=carboplatin  
EFFCGRAPH=EFFC  
EFFE = SLPE_C  
error(CEpsplatelet = 0.1)  
observe(plateletObs = platelet \* (1 + CEpsplatelet))  
stparm(V = tvV \* exp(nV))  
stparm(Cl = tvCl \* exp(nCl))  
stparm(V2 = tvV2 \* exp(nV2))  
stparm(Cl2 = tvCl2 \* exp(nCl2))  
stparm(Ka = tvKa \* exp(nKa))  
stparm(kdeg = tvkdeg \* exp(nkdeg))  
stparm(ktr = tvktr )  
stparm(KIN = tvKIN )  
stparm(SLPC = tvSLPC \* exp(nSLPC))  
stparm(SLPE = tvSLPE \* exp(nSLPE))  
stparm(KC = tvKC \* exp(nKC))  
fixef(tvV = c(, 11.7, ))  
fixef(tvCl = c(, 0.839, ))  
fixef(tvV2 = c(, 9.81, ))  
fixef(tvCl2 = c(, 1, ))  
fixef(tvKa = c(, 4, ))  
fixef(tvkdeg = c(, 1, ))  
fixef(tvktr(freeze) = c(, 0.0253, ))  
fixef(tvKIN(freeze) = c(, 1.43, ))  
fixef(tvSLPC = c(, 3.01, ))  
fixef(tvSLPE = c(, 0.190, ))  
fixef(tvKC = c(, 0.0176, ))  
ranef(diag(nV, nCl, nV2, nCl2, nKa, nkdeg, nKC, nSLPC, nSLPE) = c( 0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1))  
}

 ![egg_chicken.jpg](https://us1.discourse-cdn.com/certara/original/1X/de5a14ab107bc1ae6f0c055c2ef97bed35946187.jpeg)

---

<div class="post-metadata">

**Author:** ![wrubas](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@wrubas](https://forum.certara.com/u/wrubas)\
**Post date:** [May 9, 2016, 7:52pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945/5 "2016-05-09T19:52:25Z")

</div>

> [@minhaj](#):
>
> Here is an example that explains how to put a delay in PD. the idea is to use transit compartments where the upstream compt is the one that gets the production of PD affected by PK exposure.  
> We can also use the transit compt statement (new) if the number of transit compartment is variable and/or not integer.  
> If you need help, let me know with that new feature.  
> I could not attach a project but will try again.  
> best  
> Serge
> 
> test(){  
> deriv(A1 = - (Cl \* C)- (Cl2 \* (C - C2)) + (Aa \* Ka))  
> urinecpt(A0 = (Cl \* C))  
> deriv(A2 = (Cl2 \* (C - C2)))  
> deriv(Aa = - (Aa \* Ka))  
> deriv(pd0 = KIN\*(1-EFFC)\*(1+EFFE)- (pd0 \* ktr))  
> deriv(pd1 = (pd0 \* ktr)- (pd1 \* ktr))  
> deriv(pd2 = (pd1 \* ktr)- (pd2 \* ktr))
> 
> sequence{pd0=KIN/ktr  
> pd1=KIN/ktr  
> pd2=KIN/ktr  
> platelet=KIN/kdeg}  
> deriv(carboplatin = - (carboplatin \* KC))  
> urinecpt(carboeli = (carboplatin \* KC))  
> deriv(platelet = - (platelet \* kdeg) + (pd2 \* ktr))  
> urinecpt(plateletoutput = (platelet \* kdeg))  
> C = A1 / V  
> C2 = A2 / V2  
> error(CEps = 0.1)  
> observe(CObs = C \* (1 + CEps))  
> dosepoint(Aa)
> 
> pd0graph=pd0  
> pd1graph=pd1  
> pd2graph=pd2  
> plateletgraph=platelet
> 
> dosepoint(carboplatin)  
> EFFC = SLPC_carboplatin  
> carboplatingraph=carboplatin  
> EFFCGRAPH=EFFC  
> EFFE = SLPE_C  
> error(CEpsplatelet = 0.1)  
> observe(plateletObs = platelet \* (1 + CEpsplatelet))  
> stparm(V = tvV \* exp(nV))  
> stparm(Cl = tvCl \* exp(nCl))  
> stparm(V2 = tvV2 \* exp(nV2))  
> stparm(Cl2 = tvCl2 \* exp(nCl2))  
> stparm(Ka = tvKa \* exp(nKa))  
> stparm(kdeg = tvkdeg \* exp(nkdeg))  
> stparm(ktr = tvktr )  
> stparm(KIN = tvKIN )  
> stparm(SLPC = tvSLPC \* exp(nSLPC))  
> stparm(SLPE = tvSLPE \* exp(nSLPE))  
> stparm(KC = tvKC \* exp(nKC))  
> fixef(tvV = c(, 11.7, ))  
> fixef(tvCl = c(, 0.839, ))  
> fixef(tvV2 = c(, 9.81, ))  
> fixef(tvCl2 = c(, 1, ))  
> fixef(tvKa = c(, 4, ))  
> fixef(tvkdeg = c(, 1, ))  
> fixef(tvktr(freeze) = c(, 0.0253, ))  
> fixef(tvKIN(freeze) = c(, 1.43, ))  
> fixef(tvSLPC = c(, 3.01, ))  
> fixef(tvSLPE = c(, 0.190, ))  
> fixef(tvKC = c(, 0.0176, ))  
> ranef(diag(nV, nCl, nV2, nCl2, nKa, nkdeg, nKC, nSLPC, nSLPE) = c( 0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1))  
> }

Thank you. This is helpful. In this example the trans time through the compartments appears to be the same, correct? Does this example also require that I need PD data for PD0 - PD2 or can this be used if I have only data for one of them, lets say PD1 and/or PD2? Any chance this can be set up in graphical mode too?

Werner

---

<div class="post-metadata">

**Author:** ![minhaj](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@minhaj](https://forum.certara.com/u/minhaj)\
**Post date:** [May 11, 2016, 10:15pm UTC](https://forum.certara.com/t/delayed-differential-equations/2945/6 "2016-05-11T22:15:40Z")

</div>

> [@wrubas](#):
>
> Thank you. This is helpful. In this example the trans time through the compartments appears to be the same, correct? Does this example also require that I need PD data for PD0 - PD2 or can this be used if I have only data for one of them, lets say PD1 and/or PD2? Any chance this can be set up in graphical mode too?
> 
> Werner

Dear Werner

The last compartment is the one from which you have data. I added upstream compartment to emulate the delay. You do not need or have data elsewhere. You cannot set up graphically because the infusion is not a constant over time. You do not have a PD dose but only the production of PD being put in the upstream compartment. If the delay was ion the PK , then you could use the graphical mode.

Best Regards

Serge

---

<div class="post-metadata">

**Author:** ![wrubas](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@wrubas](https://forum.certara.com/u/wrubas)\
**Post date:** [May 13, 2016, 12:32am UTC](https://forum.certara.com/t/delayed-differential-equations/2945/7 "2016-05-13T00:32:02Z")

</div>

Dear Serge,

Thank you.

How do you upload a file. Can’t do it with attachments it gets me back to front page.

I practized with PKPD from GAbrielsson and wanted feed back but since I don’t know how to upload it has to wait until someone tells me what to do.

Thank you,

Werner

[CSINONMEMfinal.pdf](https://forum.certara.com/uploads/short-url/nwLItd3ySGYHSkSwOaCktGLHHl3.pdf) (1.3 MB)[ACCP Case Study 1.phxproj](https://forum.certara.com/uploads/short-url/gEQMb1EkFycHzDsjYywmnwkno8K.phxproj) (5.4 MB)
