Date: Fri, 21 Jul 2000 18:00:56 +0200
From: "Looby, Michael {PDC5~Basel}" <MICHAEL.LOOBY@roche.com>
Subject: Response is sum of amounts

Dear nmusers

I would be grateful for advice on how to code a problem with differential equations where my response is the sum of instantaneous amounts across several compartments? Maybe it is just Friday evening, but I don't see a straight forward solution...................

Regards
Mick


*****


From: "Bachman, William" <bachmanw@globomax.com>
Subject: RE: Response is sum of amounts
Date: Fri, 21 Jul 2000 13:07:14 -0400

Mick

A couple of years ago I was interested in doing something similar to what you want to do (sum the amounts in more than one compartment in a differential equation model). Attached is the response I got from Alison that helped me solve my ultimate problem (not the example used below).

Hope this helps.

William J. Bachman, Ph.D.
GloboMax LLC
Senior Scientist
7250 Parkway Drive, Suite 430
Hanover, MD 21076
Voice (410) 782-2212
FAX (410) 712-0737
bachmanw@globomax.com

============================================================================

Bill,

> I am trying to define a model (via differential equations) in which the
> observations (DV) correspond to the sum of the amounts in two compartments.
> I have been able to do this by defining another compartment that is the sum
> of the two compartments.

Seems to me the best way is to do this in $ERROR. You can use any ADVAN routine. You can do more than just a simple sum in $ERROR, e.g., see tolerance examples SIMTOL.5 and SIMTOL.6 in the ftp site pkpd.icon.palo-alto.med.va.gov.

I'll show the sum in $ERROR as a change to what you sent, although you would do much better with ADVAN4 because analytic ADVAN's tend to be faster and more stable than the general ones.

I'm dropping cmt 4 altogether.

$PROBLEM TEST3
$INPUT ID DOSE=AMT TIME DV
$DATA TEST1.PRN IGNORE=C
$SUBROUTINE ADVAN8 TRANS1 TOL=5
$MODEL NPAR=4 NCOMP=3 COMP=(DEPOT) COMP=(CENTRAL) COMP=(PERIPH)

;; by default, cmt 2 is default for observations
;; because it is named "CENTRAL"
;; or, to make this clear (CENTRAL DEFOBS)
$PK
KA= THETA(1) ;KA
K23=THETA(2) ;K23
K32=THETA(3) ;K32
K20=THETA(4) ;K20

;S2=1 ;SCALING FACTOR FOR CENTRAL COMP
;S3=1
$DES
DADT(1)=-KA*A(1)
DADT(2)=KA*A(1)-K23*A(2)+K32*A(3)-K20*A(2)
DADT(3)=K23*A(2)-K32*A(3)

$ERROR
Y=F+A(3)+ERR(1) ;; F = A(2)/S2 = A(2)/1 = A(2)

$THETA (0,10) ;1 KA
$THETA (0,1) ;2 K23
$THETA (0,0.4) ;3 K32
$THETA (0,0.5) ;4 K20

> However, this seems to me a case which could be
> defined in terms of differential and algebraic equations (ADVAN9).

True, but ADVAN9 is slow and very sensitive to numerical difficulties.

> The
> following model is a simplification of what I want to ultimately do, so you
> need not be concerned with the logic of the model or the identifiability of
> the parameters, I am more concerned with learning the process of using
> ADVAN9. I found the manual(s) fairly cryptic on it's use and couldn't find
> an example similar to what I'm trying to do. I would be grateful for any
> light you can shed on the problem. Does one define A(4) = A(2)+A(3)
> somewhere within $AESINIT ? INIT=? Also, I don't know what E(n) represent in
> $AES.

It would look something like this:

$PROBLEM TEST3
$INPUT ID DOSE=AMT TIME DV
$DATA TEST1.PRN IGNORE=C
$SUBROUTINE ADVAN9 TRANS1 TOL=5
$MODEL NPAR=4 NCOMP=4 COMP=(DEPOT) COMP=(CENTRAL) COMP=(PERIPH)
COMP=(CP,DEFOBS,EQU) ;; note the EQUILIBRIUM attribute
$PK
KA= THETA(1) ;KA
K23=THETA(2) ;K23
K32=THETA(3) ;K32
K20=THETA(4) ;K20

;S2=1 ;SCALING FACTOR FOR CENTRAL COMP
;S3=1
S4=1 ;; not needed. This is the default
$DES
DADT(1)=-KA*A(1)
DADT(2)=KA*A(1)-K23*A(2)+K32*A(3)-K20*A(2)
DADT(3)=K23*A(2)-K32*A(3)
A1=A(1)
A2=A(2)
A3=A(3)
A4=A(4)
$AESINIT
INIT=1 ;; this is the default. It says that A(4) is exact.
A(4)=A(2)+A(3)
$AES
E(4)=A(4)-A(2)-A(3)
$ERROR
Y=F+ERR(1)

E(4) (which can also be coded simply "E") is an algebraic condition that must be 0. For a given value of A(2) and A(3), ADVAN9 attempts to find a value of A(4) such that E=0. It is very easy in this case.

But not every algebraic condition is so easily solved, and there may be more than one E when there is more than one EQU compartment. Also, the DADT's for A(1) and A(2) and A(3) might themselves depend on A(4), so that all A(i) must be solved for simultaneously. It is for such difficult systems that ADVAN9 is designed, not for a simple sum.

I did not look at the data. Let me know if you have other questions.


*****


Date: Fri, 21 Jul 2000 11:27:04 -0700
From: LSheiner <lewis@c255.ucsf.edu>
Subject: Re: Response is sum of amounts

Why not:

$ERROR
F1 = A(1) + A(2) + A(3)
Y= F1 + EPS(1)

?

LBS.
--
_/ _/ _/_/ _/_/_/ _/_/_/ Lewis B Sheiner, MD (lewis@c255.ucsf.edu)
_/ _/ _/ _/_ _/_/ Professor: Lab. Med., Bioph. Sci., Med.
_/ _/ _/ _/ _/ Box 0626, UCSF, SF, CA, 94143-0626
_/_/ _/_/ _/_/_/ _/ 415-476-1965 (v), 415-476-2796 (fax)


*****


Date: Mon, 24 Jul 2000 11:29:53 +0200
From: "Looby, Michael {PDC5~Basel}" <MICHAEL.LOOBY@roche.com>
Subject: RE: Response is sum of amounts

Dear All

I had tried Mark's solution (below) but got the error message:

VARIABLE DEFINED IN $DES MUST BE REDEFINED WITH NEW NAME IN $ERROR

This threw me and made me think I might need something complicated along the lines of Bill's reply.

However, the simple "quip" from Lewis did the job................

Many thanks for your replies.
Regards
Mick

> -----Original Message-----
> From: Sale, Mark [SMTP:ms93267@glaxowellcome.com]
> Sent: Freitag, 21. Juli 2000 18:24
> To: 'Looby, Michael {PDC5~Basel}'
> Subject: RE: Response is sum of amounts
>
> Mick
> The amount in the compartment(s) is available as A(1), A(2) etc. If you
> want the concentrations, you can divide it by the volume (A(1)/S1), then add
> them
> $DES
> RES=A(1) + A(2)
> Then the quantity RES can be used in $ERROR
> Y = RES + EPS(1)
> Mark