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

Ravi Varadhan rvaradhan at jhmi.edu
Wed Nov 29 23:09:33 CET 2006


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: rvaradhan at jhmi.edu

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

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Ravi Varadhan
Sent: Wednesday, November 29, 2006 4:45 PM
To: r-help at 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: rvaradhan at jhmi.edu

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

 

----------------------------------------------------------------------------
--------

 


	[[alternative HTML version deleted]]

______________________________________________
R-help at 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.



More information about the R-help mailing list