Jump to content


Photo

difficulty with model containing sine function


  • Please log in to reply
13 replies to this topic

#1 mario sampson

mario sampson

    Member

  • Members
  • PipPip
  • 20 posts

Posted 05 June 2012 - 03:50 PM

Hi,

I am attempting to evaluate the following model. It iterates fairly quickly in the status window, however, even after overnight running, it gets stuck at an iteration and does not proceed from there. Do you see any problems with the code below?

Thanks,

Mario

--

 

test(){

#recycling from cmt2 to cmt1

FT = sin((2*3.14159*(t+u)/p))

#where u is the time delay of the period (p) from the first dosing time

Fpos=FT

if (FT < 0) {Fpos=0}

#differential equations

    deriv(Aa = - (Aa * Ka))

deriv(A1 = - (Cl * C1) + (Aa * Ka)- (Cl12 * C1) + (Cl21 * C2)- (Cl13 * C1) + (Cl31 * C3))

    deriv(A2 = (Cl12 * C1) - (Cl21 * Fpos * C2))

    deriv(A3 = (Cl13 * C1) - (C3 * Cl31))



#2 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 06 June 2012 - 01:54 AM

I can't see any problem with the code, but I can't say for sure if that's the correct model for your data. If it's iterating at all, that's a good sign. You can try with different engines (LB, ELS, QRPEM in the latest and greatest version, Laplacian, etc.), with and without MPI, with different intial estimates, etc.



#3 Teodora Dumitrescu

Teodora Dumitrescu

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 06 June 2012 - 02:05 AM

Hi Emily,

 

In Mario's model equation: FT = sin((2*3.14159*(t+u)/p)) , is "t" recognized implicitly as the time?

 

Thanks,

Dora



#4 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 06 June 2012 - 01:13 PM

t is time, but I noticed there's an "if()" in his code, which may be partly why it's not working. If you want to use if/then, you should probably try sequence{} and sleep(). Look at the enterohepatic recirculation model as an example. That's the best I can do for now, as I'm not in the office this week. If you get stuck, write in to support and send them the whole model with the data, if you can, or the project file.



#5 mario sampson

mario sampson

    Member

  • Members
  • PipPip
  • 20 posts

Posted 12 June 2012 - 02:43 PM

Hi,

 

Using NLME, I am trying to use a sine function to model non-continuous flow of a drug between the second compartment to the first compartment. To do this, I am using a model obtained from the literature (see page 1 of attached word document).

 

At first I used an 'if' statement to do this. The model text is on page 2 of the attached word document. This model iterated in the status window, but it would become stuck on a particular iteration and never complete.

 

Emily suggested use of a sequence/sleep function instead. The model text for this is on page 4 of the word document. Here, the same problem occurred, in that iteration was observed, but the run never completed.

 

My questions are:

1) Would you recommend either approach for this problem, or some other way to program this?

2) What exactly are the problems with the 'if' model and the 'sequence/sleep' models that are attached?

 

Thanks,

Mario

UNC Eshelman School of Pharmacy [file name=model_text_for_pharsight_question_1.docx size=91430]http://pharsight.com/extranet/media/kunena/attachments/legacy/files/model_text_for_pharsight_question_1.docx[/file]



#6 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 12 June 2012 - 03:27 PM

In your If/then model, try replacing this

 

Fpos=FT

if (FT < 0) {Fpos=0}

 

with this

 

Fpos = (FT < 0 ? 0 : FT)

 

If that doesn't work, the problem may be that you're using the differential equations with a t in your model. Sometimes you have to put it in closed form and put time as a covariate if you plan to access t like you do with the sine function. In that case, you would have a line: covariate(time), and your observe statement would have to say observe(CObs(time) = C + CEps) or whatever the form of the residual error model is, but you can try to see if the above fix works first.

 

Also, there is a problem with your ranef statment. You need to have initial estimates for your random effects. Try with a built in model and switch to text to see what the code should look like for ranef.



#7 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 12 June 2012 - 03:35 PM

Another option if you're not able to put the differential equations in closed form is to have a line covariate(time), map an additional column for time (as if it's just another variable in addition to the one you have that's reserved for time), and use that same name "time" in your sine function instead of the reserved name of t. I heard from the developer a while ago that there could be problems if you try to access this reserved t in some cases, and I think one of those cases is when you have differential equations (deriv()'s) with t in your model somewhere. So mapping a new column for time and calling it a covariate would allow you to keep the deriv()'s as is and still be able to use a time variable in your model.



#8 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 12 June 2012 - 03:38 PM

If you're not changing the differential equations to closed form, you do not need to put time in your observe statement. If you write the closed form solution for the concentration, you need to have

 

observe(CObs(time) = C + CEps)

 

but if you have the deriv()'s (differential equations), then it has to be like this:

 

observe(CObs = C + CEps)

 

but with deriv()'s I think you can still use time as a covariate for your sine function.



#9 Teodora Dumitrescu

Teodora Dumitrescu

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 12 June 2012 - 07:21 PM

Hi Emily,

 

If we are using the covariate(time) option, and map the additional column for time, will the FT be evaluated at only the time points from the dataset (ex: 0, 1, 2, 3 h etc), or will it be evaluated continuously from zero to the end of the sampling interval? I am not sure, but I think we need it to be calculated continuously, correct?

 

Thanks,

Dora



#10 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 12 June 2012 - 07:25 PM

If you put time as a covariate, it does not evaluate continuously, only at the points in the data set.



#11 mario sampson

mario sampson

    Member

  • Members
  • PipPip
  • 20 posts

Posted 13 June 2012 - 05:34 PM

Hi Emily,

 

When I used your suggestion of 'Fpos = (FT <= 0 ? 0 : FT)' and 'covariate(time)', the model now completes. In a previous post, you said that accessing 't' in the 'deriv' statement may be problematic. Is there another way to access 't' in a continuous manner? For example, is it problematic to add rows to the dataset where there are values for time, but no concentrations. We would prefer to evaluate the sine function continuously, as opposed to only at the sampling times.

 

Thanks,

Mario

UNC Eshelman School of Pharmacy



#12 serge guzy

serge guzy

    Advanced Member

  • Members
  • PipPipPip
  • 485 posts

Posted 15 June 2012 - 04:13 PM

Did you try

Fpos = (FT < 0 ? 0 : FT) instead of the if condition ?

Did you try QRPEM?

Is it possible to get the data set or a hidden version of it?

What is the error or problem?



#13 serge guzy

serge guzy

    Advanced Member

  • Members
  • PipPipPip
  • 485 posts

Posted 15 June 2012 - 04:19 PM

Did you try Fpos = (FT < 0 ? 0 : FT)

 instead of the if condition? What erro message do you get? What engine di you use? Did you try QRPEM? Is it possible to get the data set and if confidential then without the responses, just to have some sense of what do we deal with? Did you try to simulate data with the same desing and then fit the model? Are you sure the model is identifiable?

Best

Serge



#14 Emily Colby

Emily Colby

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 15 June 2012 - 06:39 PM

In answer to Dora's question, to have another time variable that evaluates continuously and not just at times in the dataset:

 

Don’t use time as a covariate. Add another equation deriv(time2=1)

 

That is what the developers told me.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users