[R] How to solve differential equations with a delay (time lag)?
Setzer.Woodrow at epamail.epa.gov
Setzer.Woodrow at epamail.epa.gov
Wed Nov 29 23:26:12 CET 2006
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-0128 Fax: (919) 541-1194
Ravi Varadhan
<rvaradhan at jhmi.
edu> To
Sent by: r-help at stat.math.ethz.ch
r-help-bounces at s 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: 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