Re: [R] How to solve differential equations with a delay (time lag)?

2006-11-29 Thread Ravi Varadhan
Hi,

I would like to add an additional piece of information to my previous
posting:

y[1](t) = 0, for all t in the interval (-delay, 0)

This completes the specification of the problem.

Thanks,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan
Sent: Wednesday, November 29, 2006 4:45 PM
To: r-help@stat.math.ethz.ch
Subject: [R] How to solve differential equations with a delay (time lag)?

Hi,

 

I would like to solve a system of coupled ordinary differential equations,
where there is a delay (time lag) term.  I would like to use the lsoda
function odesolve package.  However, I am not sure how to specify the
delay term using the syntax allowed by odesolve.  

Here is an example of the kind of problem that I am trying to solve:

 

 library(odesolve) 

 

yprime - function(t, y, p) {  # this function 

yd1 - p[k1] *(t = p[T]) - p[k2] * y[2]

yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2]  # this is not
syntactically valid, but it is what I would like to do

list(c(yd1,yd2))

}

 

times - seq(0,30,by=0.1)

y0 - c(0,0)

parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5)

 

Is there a way to incorporate delay in odesolve?

 

Any hints would be much appreciated. 

 

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




 


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to solve differential equations with a delay (time lag)?

2006-11-29 Thread Setzer . Woodrow
lsoda does not solve delay differential equations, which is what you
need to be able to do.  A quick search on netlib (netlib.org) turned up
one match for delay differential equations: ode/ddverk.f, which might
help (though not in R).

R. Woodrow Setzer, Ph. D.
National Center for Computational Toxicology
US Environmental Protection Agency
Mail Drop B205-01/US EPA/RTP, NC 27711
Ph: (919) 541-0128Fax: (919) 541-1194



 Ravi Varadhan  
 [EMAIL PROTECTED]   
 eduTo 
 Sent by: r-help@stat.math.ethz.ch  
 [EMAIL PROTECTED]cc 
 tat.math.ethz.ch   
Subject 
  [R] How to solve differential 
 11/29/2006 04:44 equations with a delay (time  
 PM   lag)? 










Hi,



I would like to solve a system of coupled ordinary differential
equations,
where there is a delay (time lag) term.  I would like to use the lsoda
function odesolve package.  However, I am not sure how to specify the
delay term using the syntax allowed by odesolve.

Here is an example of the kind of problem that I am trying to solve:



 library(odesolve)



yprime - function(t, y, p) {  # this function

yd1 - p[k1] *(t = p[T]) - p[k2] * y[2]

yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2]  # this is not
syntactically valid, but it is what I would like to do

list(c(yd1,yd2))

}



times - seq(0,30,by=0.1)

y0 - c(0,0)

parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5)



Is there a way to incorporate delay in odesolve?



Any hints would be much appreciated.



Ravi.



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html










 [[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to solve differential equations with a delay (time lag)?

2006-11-29 Thread Ravi Varadhan
Thanks, Woodrow.  I also found a DDE solver called dde23 in Matlab written
by L.F. Shampine.  I will see if I can use it in Scilab, since I don't have
Matlab.  

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Sent: Wednesday, November 29, 2006 5:26 PM
To: Ravi Varadhan
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] How to solve differential equations with a delay (time
lag)?

lsoda does not solve delay differential equations, which is what you
need to be able to do.  A quick search on netlib (netlib.org) turned up
one match for delay differential equations: ode/ddverk.f, which might
help (though not in R).

R. Woodrow Setzer, Ph. D.
National Center for Computational Toxicology
US Environmental Protection Agency
Mail Drop B205-01/US EPA/RTP, NC 27711
Ph: (919) 541-0128Fax: (919) 541-1194



 Ravi Varadhan  
 [EMAIL PROTECTED]   
 eduTo 
 Sent by: r-help@stat.math.ethz.ch  
 [EMAIL PROTECTED]cc 
 tat.math.ethz.ch   
Subject 
  [R] How to solve differential 
 11/29/2006 04:44 equations with a delay (time  
 PM   lag)? 










Hi,



I would like to solve a system of coupled ordinary differential
equations,
where there is a delay (time lag) term.  I would like to use the lsoda
function odesolve package.  However, I am not sure how to specify the
delay term using the syntax allowed by odesolve.

Here is an example of the kind of problem that I am trying to solve:



 library(odesolve)



yprime - function(t, y, p) {  # this function

yd1 - p[k1] *(t = p[T]) - p[k2] * y[2]

yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2]  # this is not
syntactically valid, but it is what I would like to do

list(c(yd1,yd2))

}



times - seq(0,30,by=0.1)

y0 - c(0,0)

parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5)



Is there a way to incorporate delay in odesolve?



Any hints would be much appreciated.



Ravi.



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html










 [[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.