implement an interidividual variability in the residual variance

40 views
Skip to first unread message

yami...@gmail.com

unread,
Jul 18, 2016, 11:38:53 AM7/18/16
to mrgsolve
Hi group,

In case that NONMEM model implements an interidividual variability in the residual variance like below:

$ERROR
 Y  = F + EXP(ETA(1)) * EPS(1)

Is below the correct way to translate it into mrgsolve model code (suppose I have declared C2 corresponding to F before $TABLE)?

$TABLE
double DV = C2 + EXP(ETA(1)) * EPS(1)

Thanks!
Yaming

Vijay Ivaturi

unread,
Jul 18, 2016, 11:42:09 AM7/18/16
to yami...@gmail.com, mrgsolve
Looks correct to me, given that C2 is your predicted concentration. Note that you have to use lower case exp instead of EXP in R. 


--
MetrumRG Website: http://www.metrumrg.com/opensourcetools.html
---
You received this message because you are subscribed to the Google Groups "mrgsolve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mrgsolve+u...@metrumrg.com.
To post to this group, send email to mrgs...@metrumrg.com.
Visit this group at https://groups.google.com/a/metrumrg.com/group/mrgsolve/.
--
~Vijay

Kyle Baron

unread,
Jul 18, 2016, 11:51:25 AM7/18/16
to Vijay Ivaturi, yami...@gmail.com, mrgsolve
Agree with Vijay.


I'd also add a caution to make cure that C2 gets calculated in $TABLE (I'm assuming that it came from $ODE).  


Two ways to do this:


Just re-calculate (again, this assumes C2 was initialized and calculated elsewhere)
$TABLE
C2 = CENT/V2;


Or use a pre-processor directive

$GLOBAL 
#define C2 (CENT/V2)

$TABLE
double DV = C2 + exp(ETA(1)) * EPS(1)


If you take the #define route, don't declare double C2 anywhere ... just use C2.  Wherever you use C2, it will calculate (CENT/V2).






Kyle Baron

Yaming Su

unread,
Jul 18, 2016, 12:03:13 PM7/18/16
to mrgsolve, ivija...@gmail.com, yami...@gmail.com
Vijay and Kyle, appreciate your response.

I declared C2 in $ODE block as below (just showing portion where C2 is declared)

$ODE
double C2 = CENT/VC;


Is there a difference as compared to declaring it in $TABLE block? Under what circumstance should I be cautious about where to declare C2 (in $ODE versus $TABLE)

Thanks!
Yaming

Kyle Baron

unread,
Jul 18, 2016, 12:12:18 PM7/18/16
to Yaming Su, mrgsolve, Vijay Ivaturi
Yaming - 

It is fine to declare C2 in $ODE.  But if you don't re-calculate it in $TABLE, the value you get is the last value that was seen in calls to $ODE by the solver.  Most of the time (observation records), this will be fine ... but for dosing records, it will probably not be what you want (you won't see the doses).  

So, declare in $ODE is fine, just re-calculated when you get to $TABLE

$ODE
double C2 = CENT/VC;
....

$TABLE
C2 = CENT/VC; /// re-calculate C2
double DV = C2 + exp(ETA(1)) * EPS(1)


One more thing to check: make sure you need C2 in $ODE (presumably it's driving some PD model?).  If you don't need C2 in $ODE, just declare and calculate it in $TABLE and skip it in $ODE.  

Does this make sense?  Please keep going with the questions if not ... I want to make sure this is clear.


Thanks,
Kyle

Yaming Su

unread,
Jul 18, 2016, 1:48:30 PM7/18/16
to mrgsolve, yami...@gmail.com, ivija...@gmail.com
Hi Kyle,

I tried an example to check if I understand your statement. In the attached mrgsolve R code file, I declared C1 = CENT/V in $ODE block and re-calculate it in $TABLE in the first model;  I declared C1 = CENT/V in only in $ODE block.  The study template is that dose was given on time 0 and 24.  The simulation results showed that both methods showed simulation outcomes on dosing records time (e.g., time=24).  I may misunderstand your comments in the previous email.

> out1
  ID time          GUT      CENT       C1       DV
1  1    0 0.000000e+00   0.00000 0.000000 0.000000
2  1    0 1.000000e+02   0.00000 0.000000 0.000000
3  1   10 6.144211e-04  76.97997 2.199428 2.959954
4  1   20 3.594157e-09  57.84917 1.652834 2.564771
5  1   24 1.000000e+02  51.60164 1.474333 1.252804
6  1   30 7.465859e-02 129.69669 3.705620 1.063563
> out2
  ID time          GUT      CENT       C1        DV
1  1    0 0.000000e+00   0.00000 0.000000 0.0000000
2  1    0 1.000000e+02   0.00000 0.000000 0.0000000
3  1   10 6.144211e-04  76.97997 2.199428 0.2223536
4  1   20 3.594157e-09  57.84917 1.652834 0.7501229
5  1   24 1.000000e+02  51.60164 1.474333 0.2798951
6  1   30 7.465859e-02 129.69669 3.705620 0.8705180

Thanks!
Yaming
mrgsolve_self_learning_C1_in_TABLE_or_ODE.R

Kyle Baron

unread,
Jul 18, 2016, 1:53:14 PM7/18/16
to Yaming Su, mrgsolve, Vijay Ivaturi
Can you try putting the dose into CENT, not GUT?

Yaming Su

unread,
Jul 18, 2016, 2:29:38 PM7/18/16
to mrgsolve, yami...@gmail.com, ivija...@gmail.com
Kyle,

According to your suggestion, in the originally attached mrgsolve R code, I changed dosing in dataset in study template (i.e., a bolus dose to central cmt now),
ids <- expand.grid(ID = 1, time = c(0, 24), cmt = 2, evid = 1, amt = 100)

The simulation output is shown below,  it is true that prediction at dosing records are different between two different ways of declaring C1; It appears that declaring C1 in $ODE and re-calculate it in $TABLE gives correct simulation (object out1) at times corresponding to dosing records.  A quick check for simulation of C1 at dosing record when time=0 show it is equivalent to Dose/V (100/35 = 2.857143), which theoretically makes sense. The simulation of C1 at dosing record when time=24 also makes more sense in out1 too.

> out1
  ID time GUT      CENT       C1       DV
1  1    0   0   0.00000 0.000000 0.000000
2  1    0   0 100.00000 2.857143 4.158951
3  1   10   0  75.14773 2.147078 2.889503
4  1   20   0  56.47181 1.613480 2.503705
5  1   24   0 150.37303 4.296372 3.650814
6  1   30   0 126.68333 3.619524 1.038852
> out2
  ID time GUT      CENT       C1        DV
1  1    0   0   0.00000 0.000000 0.0000000
2  1    0   0 100.00000 0.000000 0.0000000
3  1   10   0  75.14773 2.147078 0.2170612
4  1   20   0  56.47181 1.613480 0.7322628
5  1   24   0 150.37303 1.439229 0.2732310
6  1   30   0 126.68333 3.619524 0.8502925

Thanks for making this question clear.
Yaming

Kyle Baron

unread,
Jul 18, 2016, 2:34:39 PM7/18/16
to Yaming Su, mrgsolve, Vijay Ivaturi
Thanks for trying it.  I think that NONMEM prevents you from calculating C2 in $DES and then accessing that same variable in $ERROR.  mrgsolve doesn't have that check right now, so it's up to the user.  I got into the habit of using #define statements as I illustrated earlier to make sure it's never an issue.
Reply all
Reply to author
Forward
0 new messages