Thanks Scott. Cleaning up the dosing records is a great suggestion. And so is removing the interaction term. I'm sad to say I don't even know what it does because unfortunately I'm still in the stages where I sometimes blindly copy people's code. ADVAN13 sounds like a great idea but for now I'm stuck using Nonmem 6.
For anyone interested, I'm stubborn and I tried to track down a technique for using an explicit solution. I mean, why the heck use Advan6 with it's 5th/6th order Runge-Kutte which is overkill in the extreme when I know I can compute the exact solution with way fewer computations. Well, the answer is sure, you can compute the exact solution in a piecewise, recursive fashion for one patient, but can you compute your partial derivatives in the ETAs that are necessary for the FO and FOCE method? The answer, it turns out, is no. At least as of 1996. I've copied a short snippet of the answer along with a link to the longer posting at the end of this email. However, if anyone knows of a change since 1996, please please let me know! The other thing I was thinking of trying is the finite difference approach proposed by [1] if I can figure out how to implement it properly. Thanks again for your help, Andy [1] Petersson, Friberg, Karlsson, J. Pharmacokin. Pharmacodyn. (2010) 37:493-506. http://gaps.cpb.ouhsc.edu/nm/58sep2496.html **** *From alison Fri Sep 27 10:30:50 1996 **Subject: recursive abbreviated code * Kyungsoo Park, Rik Schoemaker, Ken Kowalski, Reudi Port, Lew Sheiner, and others have been discussing various complicated topics in modelling. I do not want to comment on these topics, because I am not familiar enough with them. The only thing I am comfortable commenting on is this (most recent) code and question from Reudi Port: > I see that the above code won't work with population > data, at least when the FO method is used. I'm wondering whether it could be > applicable with the FOCE method. > of course, for FOCE, I was thinking of a code that includes eta's: > > IF (TIME.EQ.0) Celast = 0 ; or some other initial value > Cenew = ... Celast ... (function of Celast, > the mean population PK parameters, and some eta's) > effect = ... (function of Cenew, more parameters (more eta's)) > Y = ... effect ... EPS( ) > Celast = Cenew This cannot be implemented correctly in abbreviated code. Unfortunately, NM-TRAN (in NONMEM IV) does not recognize that there is something wrong. With population data and both FO and FOCE, the objective function will be computed incorrectly. With FOCE, I think it will be even worse, and that the conditional estimation will also be done incorrectly. With individual data and FO, the computations will be correct, because there will be no etas in the computation of Cenew and Celast. (FOCE is not possible with individual data). As to what this implies for the complicated models that have been discussed, I cannot say in general. Here are some details that *might* make this more clear. Skip them if they confuse anyone. At present, NM-TRAN makes a single pass thru a given block of abbreviated code. When it sees "Cenew = ... Celast", it does not know that Celast will become dependent on etas later in the block, and does not compute the partial derivatives correctly. This is true of $PRED, $DES, $PK, and $ERROR blocks. With the latter three, of course, we are using PREDPP, and PREDPP can handle a recursive solution internally; compartment amounts *and their derivatives* are carried forward and updated correctly from record to record. But the PK parameters (and the quantities used in differential equations and in the $ERROR block) must be coded in a non-recursive way. That is, any left hand quantity in abbreviated code that depends on random variables (ETA and/or EPS) must be computed EXACTLY ONCE AND UNCONDITIONALLY. If an either/or choice is involved, indicator variables (e.g., Q and 1-Q in many examples) can be used, because this rule is obeyed. But if the computation invoves random variables computed with a prior data or event record, it cannot be done correctly. **** On Fri, Mar 4, 2011 at 11:50 AM, Scott Vanwart <svanw...@icpd.com> wrote: > Hi Andy, > > > > I would suggest trying to optimize the performance of the current model > rather than try to use a stepwise function to get an explicit equation for > the IDR model. Perhaps switch from ADVAN6 to ADVAN13 (with NSIG=2 and > SIGL=6 on $EST if you are using TOL=6 for $SUBROUTINES), remove INTERACTION > from $EST if you are only using an additive RV model for your PD measures, > and shorten your dataset if you have dose records that extend beyond your > last PD observation within each subject. All of these simple things may > help reduce the run times. > > > > Scott > > > > *From:* owner-nmus...@globomaxnm.com [mailto:owner-nmus...@globomaxnm.com] > *On Behalf Of *Andy Stein > *Sent:* Friday, March 04, 2011 10:51 AM > *To:* nmusers@globomaxnm.com > *Subject:* [NMusers] Speeding up code with explicit, piecewise ODE > solutions > > > > Hi, > > I'm trying to solve an indirect response model in Nonmem where the drug > effect depends upon the dose, which can change every day. Currently, I'm > using the ADVAN6 routine, but because I have thousands of time points for > about a thousand patients, Nonmem is quite slow. I thought that in > principle, it should be possible to speed this up. Rather than use the > ADVAN6 routine, it would be nice if I could just somehow enter the > piecewise, analytical solution into the model. Instead of the DADT(1) > equation shown below, it would be nice to be able to use something like the > pseudo-code > > SSA = KIN*(1-EFF)/KOUT ; the steady state for A given the effect at a > certain dose). note that EFF can change with time due to dose changes > A(this time step) = (A(last time step) - SSA)*EXP(-KOUT*TSTEP) + SSA ; this > is the explicit solution to the indirect response equation from the model > below, TSTEP=size of time step > > > Does anyone know if this is possible? If so, if you have sample code for a > similar problem that would be extremely helpful. > > Thanks, > Andy > > $PROBLEM this is the essential part of the current indirect response code > I'm using > $SUBS ADVAN6 TOL=5 > $PK > ; PD model > KIN = THETA(1)*EXP(ETA(1)); > KOUT = THETA(2)*EXP(ETA(2)); > E10 = THETA(3)*EXP(ETA(3)); %effect of 10mg > > ; Initialize ODE > A_0(1) = Y0; baseline value (as covariate) > > $DES > IF (DOSE.EQ.10) EFF=E10 > IF (DOSE.EQ.0) EFF=0 > DADT(1) = KIN*(1-EFF)-KOUT*A(1) >