Jump to content


Photo

lagtime model diff equations


  • Please log in to reply
30 replies to this topic

#1 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 17 February 2013 - 10:35 PM

When modeling plasma concentrations after oral administration there can be a lagtime for the drug appearing in the plasma. One has the option of using a 1 cpt model , V, first order absorption and elimination with a lag time. This can work very well, but if the lag is pronounced the model may not fit the early plasma concentrations well ( lag time zone) while fitting the rest of the profile.

I have written very simple models along the lines of published work that include a series of lag time compartments and they work well for fitting single doses of drug. The lagtime zone plus the rest ofthe profile is fitted well.

 

An example of code for single dose would be below. CON (1) = dose

 

The single dose plasma concentrations are fitted well.

 

I am now considering how I can include simulating for multiple doses in the code. That way I could predict plasma concentrations after say 5 doses.

 

So how would I approach including the option to simulate (predict) say 5 doses of drug once a day for example using the fitting of the single dose paranaters.

 

NCON=1

 NFUNCTIONS 1

 NDERIVATIVES 8

 NPARAMETERS 9

 NSEC 2

 PNAMES 'K01','KLAG','KLAG2','KLAG3','KLAG4', 'KLAG5','KLAG6', 'K10','V_F'

 SNAMES 'AUC','K10_hl',

 END

     1: TEMPORARY

     2: V1=P(9)

     3: END

     4: START

     5: Z(1) = CON(1)

     6: Z(2) = 0

     7: Z(3) = 0

     8: Z(4) = 0

     9: Z(5) = 0

    10: Z(6) = 0

    11: Z(7)= 0

    12: Z(8)= 0

    13: END

    14: DIFFERENTIAL

    15: DZ(1) = -K01*Z(1)

    16: DZ(2) = K01*Z(1)-KLAG*Z(2)

    17: DZ(3) = KLAG*Z(2)-KLAG2*Z(3)

    18: DZ(4) = KLAG2*Z(3)-KLAG3*Z(4)

    19: DZ(5) = KLAG3*Z(4)-KLAG4*Z(5)

    20: DZ(6)= KLAG4*Z(5)-KLAG5*Z(6)

    21: DZ(7)= KLAG5*Z(6)-KLAG6*Z(7)

    22: DZ(8)= KLAG6*Z(7)-K10*Z(8)

    23: END

    24: FUNCTION 1

    25: F =Z(8)/V_F

    26: END

    27: SECO

    28: D=CON(1)

    29: AUC=D/P(9)/K10

    30: K10_HL=-DLOG(0.5)/K10

    31: END

    32: EOM

 

 

Do you have any suggestions

 

 

 

angus


  • Anthonynep, Austingar and WilliamJainy like this

#2 Simon Davis

Simon Davis

    Advanced Member

  • Administrators
  • 1,318 posts

Posted 18 February 2013 - 11:12 AM

Angus, I know it takes a while to change from what you're confident & comfortable in but if you were write that model in the Phoenix model object, (i think you could probably use just the graphical editor), then you wouldn't have to alter the code to perform simulations, simply switch the run options.

 

 Have you had a go at this - I seem to recall a discussion with you about linking absorption compartments together before?

 

 Simon



#3 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 18 February 2013 - 01:58 PM

Simon: Thank you for your reply. Yes; you are correct. At an earlier date with your help I was able to write a graphical model. I just tried to find it under "angusmdmclean", but it did not come up. I did find it under "deconvolution". That model involved a series of absorption compartments at different times (different parts of the intestine) with a common central compartment with Ke and V. It is a very useful exercise.

 

Obviously Phoenix is a brilliant program and I should move in the directionof implementing the current model in a similar way. For the current model there is an initial absorption Z(1) followed by a series of lagtime compartments { Z(2)-Z(8)}that are interconnected. Right now of course I do not know how to do this in the graphical object language. So any suggestions are most welcomnee,

 

Angus



#4 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 18 February 2013 - 08:24 PM

Simon: I thought about it and made an attempt. I used the minimum of lagtime compartments just to explore the concept. [/size]

So I initiated an approach and it is is attached. I have put a dose in there plus PK paramaters. The first dose aA is know since that is what is dosed so that must be entered as a constant. For the diff version of the model it was con(1) = mgiven dose and a constant. So I do not know how to do that in this environment. Iset the first absorption Aa to the dose (30000000 ng) and the other two Aa's to zero at 0 time.

 

.I thought about the green observation icon and decided that two of the compartments need an observation. We are trying to fit the observed plasma concentrations and there are concentrations in both of the compartments. I now realize this is m not correct; there should only be oen observation compartment (the lsat one).

 

I could not find a way to insert the green observation icon. Now this I have done before and I do not know how I managed it. Perhaps is important to have other settings set up prior to inserting the green icon.

 

This ia first attempt and it is probably pathetic. Maybe you can look at this effort to see what you think.

 

The DIFF equation version of the model (below works Ok). it is difficult for me how to transpose over to the Phoenix graphical platform.

 

 

Angus [file name=lagtime_graphical_model.phxproj size=106408]http://pharsight.com/extranet/media/kunena/attachments/legacy/files/lagtime_graphical_model.phxproj[/file]



#5 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 19 February 2013 - 04:01 PM

Simon: the basic problem I have we have a series of lagtime compartments. The final one Z(8) in the diff equation example has an elimination associated with it. So how does one represent that in the graphical language. { We have plasma concentration observations and the model(simple) is intended to fit these}. Is it regarded as a central compartment? Do not see how it can be since absorption is associated with it. Neither is it a peripheral compartment. I am now wondering whether this can be done in the graphical language of Phoenix. I am thinking it probably can, but do not see how.

 

Angus



#6 Simon Davis

Simon Davis

    Advanced Member

  • Administrators
  • 1,318 posts

Posted 22 February 2013 - 12:09 PM

Sorry Angus was wrapped up in a few meetings but my beliefis you only want a dose point t to the first compartment, so I've updated the others to 0; Posted Image

To link an observation box, drag from the little square indicating the compartment amount e.g. Aa2 to your obs; Posted Image

So with a bit of fiddling we get to e.g. Posted Image

#7 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 22 February 2013 - 06:17 PM

Thanks Simon: I am still within the CONFUSION MATRIX.

I have tried about 10 times to get the program to run. What I am trying does not make sense to me. I do not really understand what I am doing. I do not follow what you are doing.

here are the questions I have:

 (A) I am able to create a link between the compartment and observation compartment (green) as you describe.

However I only see the need for one such link (between Aa2 and the green observation. yes?

(B) for the first absorption compartment (Aa) the dose point is set to 0: Aa1 is set to 1, Aa2 is set to 0. Yes? If I do this then Aa2 dose and Aa do not appear for in initializing in the dose table ( Aa1 and time). What I have in the dosing table is Aa1 and time. Is this what it should be? Surely Aa (initial dose) should be set to a given value and as such it should appear in the dosing table with a dose point 1. What should appear in the dose Table and how do you set it up as you want to.

The lagtime is set for compartment Aa1. Yes?

I think my efforts have improved. The program validates, but work flow does not complete.

I now do not see why it is not working?

The dose I am using is arbitrary.

 

I enclose the file I am working with. So you can see where I am.

 

May be you can boot me in the right direction. I feel it is now close to running.

 

Angus



#8 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 22 February 2013 - 06:19 PM

Simon: my file did not upload so i try again. [file name=lagtime__model_effort_2_22_2013.phxproj size=337881]http://www.pharsight.com/extranet/media/kunena/attachments/legacy/files/lagtime__model_effort_2_22_2013.phxproj[/file]



#9 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 22 February 2013 - 06:48 PM

Hi Angus,

 

I fixed your model for you. I did the following

 

1) Removed the dosepoint from the second absorption compartment because you said there was no dose adminstered to that one

2) Put the tlag on the first absorption compartment (where else would tlag go?). In the blank box beside the checkbox, I typed "Tlag".

3) Right click in blank modeling area, select Insert>Paramter

4) Type "Tlag" for the name of this parameter

5) Delete third absorption compartment and put a central compartment there instead. Re-link the compartments. I did this because you said you were observing plasma concentrations.

6) In the parameters section, I copied the values you had before. I pasted them into Notepad. Then, I click "Rebuild". This reconstructs the parameters worksheet based on the parameter names in the model with correct spelling. Next, I pasted back the values you had before for the initial estimates (though they were in different order now, so I did this line by line).

7) when I executed, it complained that one of the intial estimates exceeded the bound. When I checked, Ke was set to an intial value of 0.2 with bounds of (0.29, 0.5). I changed the 0.2 to 0.29 and vice versa. Then I decided to delete all the bounds because Phoneix usually runs better without bounds anyway.

8) Execute again and your model is working. Looks alright.

 

Emily



#10 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 22 February 2013 - 06:49 PM

file attached? [file name=lagtime__model_effort_2_22_2013-20130222.phxproj size=350961]http://www.pharsight.com/extranet/media/kunena/attachments/legacy/files/lagtime__model_effort_2_22_2013-20130222.phxproj[/file]



#11 Simon Davis

Simon Davis

    Advanced Member

  • Administrators
  • 1,318 posts

Posted 22 February 2013 - 08:23 PM

Couple of comments.

1) most likely the problem, Emily and you had was choosing the first box to attach, this is for inline images only. If you have a problem like this again just use the Edit post function and try again, being sure to use the second box.
Posted Image
2) When converting from a built in to a Graphical model, there is a bug in 1.3 (QC 12372) in that tlag is lost from the model, hence Emily showed how to add this back in, or we could have done this in textual model (which was what I had done whilst looking to confirm the bug reference.

QC_PHX_12372 If a Phoenix built-in model had the Tlag property selected and was then converted to graphical (Edit Graphical), the Tlag property was not included in the graphical model. This defect has been corrected in Phoenix 1.4. (due late 2013)

That's it for me - the wine is open for the w/e, cheers!
Simon

test(){
deriv(A1 = - (A1 * Ke) + (Aa2 * Ka2))
urinecpt(A0 = (A1 * Ke))
deriv(Aa2 = - (Aa2 * Ka2) + (Aa * Ka))
deriv(Aa = - (Aa * Ka))
C = A1 / V
error(CEps = 1)
observe(CObs = C + CEps, bql)
dosepoint(Aa, tlag = (Tlag), idosevar = AaDose, infdosevar = AaInfDose, infratevar = AaInfRate)
stparm(V = tvV)
stparm(Ke = tvKe)
stparm(Ka2 = tvKa2)
stparm(Ka = tvKa)
stparm(Tlag = tvTlag)
fixef(tvTlag = c(, 1, ))
fixef(tvV = c(, 119457, ))
fixef(tvKe = c(, 0.131561, ))
fixef(tvKa2 = c(, 0., ))
fixef(tvKa = c(, 0.0786547, ))
}

#12 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 22 February 2013 - 08:46 PM

the concept of the lagtime compartment is derived from the DIFF equations already written in WinNonlin shown above and reproduced in part below: I showed that above so I am wondering if what you are doing is equivalent

4: DIFFERENTIAL
15: DZ(1) = -K01*Z(1)
16: DZ(2) = K01*Z(1)-KLAG*Z(2)
17: DZ(3) = KLAG*Z(2)-KLAG2*Z(3)
18: DZ(4) = KLAG2*Z(3)-KLAG3*Z(4)
19: DZ(5) = KLAG3*Z(4)-KLAG4*Z(5)
20: DZ(6)= KLAG4*Z(5)-KLAG5*Z(6)
21: DZ(7)= KLAG5*Z(6)-KLAG6*Z(7)
22: DZ(8)= KLAG6*Z(7)-K10*Z(8)
23: END

I am wondering if what you are doing is equivalent

4: DIFFERENTIAL
15: DZ(1) = -K01*Z(1)
16: DZ(2) = K01*Z(1)-KLAG*Z(2)
17: DZ(3) = KLAG*Z(2)-KLAG2*Z(3)
18: DZ(4) = KLAG2*Z(3)-KLAG3*Z(4)
19: DZ(5) = KLAG3*Z(4)-KLAG4*Z(5)
20: DZ(6)= KLAG4*Z(5)-KLAG5*Z(6)
21: DZ(7)= KLAG5*Z(6)-KLAG6*Z(7)
22: DZ(8)= KLAG6*Z(7)-K10*Z(8)
23: END

Equation 15 shows the drug being absorbed into Z(1) compartment (Aa). The lag-time comes into play when the drug moves from Z(1) into Z(2). Z(2) is a lag time compartment (Aa1).

That is at Equation 16.

So Aa is the equivalent to the first absorption compartment and Aa1 is the next compartment (lagtime compartment). So the lagtime is applicable at Aa1? Do you agree?

Angus

#13 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 22 February 2013 - 09:04 PM

Simon: I looked at your suggested model. I am thinking it is different from including the lagtime compartment in the model. This envisages absorption and then lagtime compartments.

 

The reason the lag time compartment is invoked is to fit the early plasma concentrations as well as the rest of the profile.

 

Peter Bonate has published this in his book. I have a number of lagtime compartments (8) as you can see to provide a good fit at early time points as well as the rest of the model..

The other lagtime compartments are added as needed to get the bet fit.

 

The lagtime compartment is the second compartment just like the DIFF equation approach.

 

Do you agree?

 

Angus



#14 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 22 February 2013 - 11:00 PM

Simon: I am looking at the diff equations from WinNonlin. The key is to understand well that code and what it does. We have the plasma concentrations to fit the model to. There is a series of interconnected lagtime compartments to describe the model. There is a first absorption compartment and it is connected with a lagtime compartment second compartment.

 

  You can see from the Diff equations done in WinNonlin that drug is transferred from the first absorption compartment to the next compartment {lagtime compartment} so is there is a dose point at the first compartment {absorption} only {I think}.

I

The third compartment also has observations i.e. observed plasma concentrations and an elimination process. I am not sure if it is considered to be a central compartment? You can see from my WinNonlin code that I have up to 8 connected compartments { Z(8) is the last} and plasma concentrations are obtained from the 8TH compartment Z(8) and the volume of distribution.

 

Do you follow my explanation of the model we have?

 

Angus



#15 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 23 February 2013 - 12:27 AM

Simon: another thought I have is that I am using a misnomer when I say lagtime compartment.
: DIFFERENTIAL
15: DZ(1) = -K01*Z(1)
16: DZ(2) = K01*Z(1)-KLAG*Z(2)
17: DZ(3) = KLAG*Z(2)-KLAG2*Z(3)

It may be an absorption lag compartment is correct. If we look at the Diff code above KLAG is a rate constant for removal of drug from the second compartment and KLag*Z(2) is an amount of drug that leaves the second compartment and goes to the third.

it is not a lagtime per se. Lagtime is a discrete amount of time
a delay in a process kicking in and it is different from Klag. Klag allows the description of early plasma concentrations observed.


Therefore we do not use lagtime at all and I wonder if we should be using peripheral compartments?


Angus.

#16 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 23 February 2013 - 03:11 PM

Dear Angus,

 

I tried again, this time attempting to modify the lag time model, and also trying a 0/1st sequential model as well as a Savic transit model. The Savic transit model turns out to be the best.

 

Best regards,

Emily [file name=LagTime_01stSeq_SavicTransit.phxproj size=1004260]http://www.pharsight.com/extranet/media/kunena/attachments/legacy/files/LagTime_01stSeq_SavicTransit.phxproj[/file]



#17 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 23 February 2013 - 04:30 PM

Emily: Thank you for your evaluations. I think I am so confused that my description is confusing I have given some thought to this model overnight. { I do not have the population model module. I understand that there is one for Phoenix (along the same lines as NONMEM)}. I do not feel lagtime should be included as a parameter in the model. I do not have it in the DIFF equation model (see above) The idea is to fit the early plasma concentrations by use of absorption lag compartments or transit time compartments. At the same time the rest of the concentrations at the later times are fitted. The inclusion of a lagtime parameter prevents the model from fitting the early plasma concentrations.

15: DZ(1) = -K01*Z(1)

16: DZ(2) = K01*Z(1)-KLAG*Z(2)

17: DZ(3) = KLAG*Z(2)-KLAG2*Z(3)

I now think my ideas following Simon's prompting are much better. Conceptually I am trying to translate my DIFF equation model over into Phoenix. I have 3 DIFF equations as you can see from above. I am using just 3 DIFF equations {instead of 8} for convenience for this exercise. The extra compartments are necessary so that the early plasma concentrations as well as the rest of the profile are fitted quite well. Only using the 3 DIFF equations will not fit the early plasma concentrations well. I would need to add more lag compartments. I do not think tlag should be in included in the Savic model, since it is the absorption compartments that provide a description in the delay. The inclusion of tlag means that the early concentrations will not be fit to the model and I want them to be {with the extra compartments added}. Do you agree?

Immediately a transit model will work for this situation. I have seen a transit model (from Sweden) written in NONMEM code that does have transit compartments (see link below)

• Overview of absorption models and modelling issues

 

There is only 1 dose point and that is Aa. Absorption lag model or transit model are the correct description of what I am trying to do. Lag times, I feel, should not be used. In part I have left the confusion matrix.

 

I looked at the Savic model you introduced and I tried to find the graphic representation of the model. I do not see it in your work so I am thinking you wrote the code in. You have that from your population work. Would this be correct?

Do you follow my arguments and what I am trying to do?

Can we have the Savic model without lagtime parameter.? And can we add more compartments to cause the fitting to the early parts of the profile without changing the code?

 

 

Angus



#18 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 23 February 2013 - 04:55 PM

Simon: For reasons I have elaborated on in my reply to Emily Colby I feel lag time should not be included in the model. Lagtime was not included in my DIFF equation model. The idea is to use absorption lag time compartments or transit compartments to describe the entire profile.

 

 

The inclusion of a lag time by definition surely means that the early concentrations would not be fit.

 

That said I have clarified my thought and come up with a reasonable effort now (attached).

 

There is only one does point (first compartment) and I have a central compartment. I know that with only the one absorption lag time compartment that the fit will not be good (since it is not good a good fit in WinNonlin)

 

 

 I thought it was OK conceptually. It did run but it is giving ridiculous parameters (take a look at V).

 

The fit is difficult to achieve in WinNonlin, but it did fit and the parameters were not ridiculous.

 

I attach it to show you what I got. I was not expecting the early plasma concentrations to be fit by this model (we need more absorption lag time compartments)

 

Angus [file name=lag_with_central_comp_2_23_2013.phxproj size=354862]http://www.pharsight.com/extranet/media/kunena/attachments/legacy/files/lag_with_central_comp_2_23_2013.phxproj[/file]



#19 Angus McLean

Angus McLean

    Advanced Member

  • Members
  • PipPipPip
  • 223 posts

Posted 23 February 2013 - 05:14 PM

Simon: here are the fitted parameters from the model ( 1 absorption lag time compartment).

 

The same model I sent to you in Phoenix. The(CV%) were ridiculously high.

 

    K01 0.099312

KLAG 0.099311

K10 0.098866

V_F 190340.0303

 

So it is not a good model, but then we know that more lag time compartments are needed to get the fit needed.

 

 

Angus



#20 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 23 February 2013 - 06:55 PM

Dear Angus,

 

In the attached project (updated from earlier version), the lag time model is exactly the same model as the WinNonlin ASCII model you pasted in the original post, with 7 absorption compartments and no "tlag" parameter. Note that to remove the tlag parameter I selected the first absorption compartment, deselected the "Tlag" check box, and I deleted the "Tlag" parameter box in the model picture. After doing so, I added all the other compartments to make it match your original model.

 

Best regards,

Emily [file name=LagTime_01stSeq_SavicTransit-20130223.phxproj size=1021870]http://www.pharsight.com/extranet/media/kunena/attachments/legacy/files/LagTime_01stSeq_SavicTransit-20130223.phxproj[/file]






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users