[R-sig-ME] solve some differential equations with the deSolve
Carl Von Ende
cvonende @end|ng |rom n|u@edu
Fri Nov 8 17:56:40 CET 2019
Hi Torsten,
You are in luck. There is a R mailing list for deSolve. I believe it is moderated by Thomas Petzoldt. Here is the link to subscribe to it, if you wish.
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
This is the address of the mailing list.
r-sig-dynamic-models using r-project.org
Best Regards,
Carl von Ende
Dept. Biol. Sciences
Northern Ill. Univ.
DeKalb, IL 60115
On 11/8/19, 5:02 AM, "R-sig-mixed-models on behalf of r-sig-mixed-models-request using r-project.org" <r-sig-mixed-models-bounces using r-project.org on behalf of r-sig-mixed-models-request using r-project.org> wrote:
Send R-sig-mixed-models mailing list submissions to
r-sig-mixed-models using r-project.org
To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
or, via email, send a message with subject or body 'help' to
r-sig-mixed-models-request using r-project.org
You can reach the person managing the list at
r-sig-mixed-models-owner using r-project.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-mixed-models digest..."
Today's Topics:
1. Subjecting data to differential equations deSolve (Torsten Hauffe)
2. Re: [FORGED] Subjecting data to differential equations
deSolve (Rolf Turner)
----------------------------------------------------------------------
Message: 1
Date: Thu, 7 Nov 2019 14:12:33 +0100
From: Torsten Hauffe <torsten.hauffe using gmail.com>
To: R-mixed models mailing list <r-sig-mixed-models using r-project.org>
Subject: [R-sig-ME] Subjecting data to differential equations deSolve
Message-ID:
<CAGCrCxav2ZMC0Pq+migjo+19n6jFP6e8rYiupZDMak9oWffvhQ using mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Dear list,
My apologies if this question doesn't fit the scope of the mailing list.
I try to solve some differential equations with the deSolve::ode and need
to feed some values at certain time-points into the equations.
Anyone has a guess why the results are off by factor 10?
Thanks for any input and cheers,
Torsten
Here is a simplified reproducible example:
# Time of observations
ObsTime <- c(1.9, 2.0, 2.1, 3.9, 4.0, 4.1, 9.9, 10.0, 10.1, 23.9, 24.0,
24.1)
# Value of the observations
Obs <- c(0, 6, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0)
# following the second example of ode(), it needs a function from where
values could be obtained as function of time
obs3Func <- approxfun(ObsTime, Obs, method = "constant", rule = 2)
# Subjecting the time to the approx-function works
obs3Func(ObsTime)
# A simple function that I expect to return the cumulative sum of Obs (i.e.
15)
Test_rhs <- function(t, x, parms, obsFunc)
{
with(as.list(c(parms, x)), {
Sa <- obsFunc(t)
list(Sa * s)
})
}
Test <- ode(y = 0,
times = seq(0, 65, by = 0.1),
func = Test_rhs,
parms = list(s = 1),
obsFunc = obs3Func)
# Using s = 1, the results are off (my expectation) by factor 10
plot(Test)
# With s = 10 the result is as expected but I don't know why
Test2 <- ode(y = 0,
times = seq(0, 65, by = 0.1),
func = Test_rhs,
parms = list(s = 1),
obsFunc = obs3Func)
plot(Test2)
# Changepoints & values
Time <- c(2, 4, 10, 24)
abline(v = Time, lty = 2, col = "grey")
points(ObsTime, cumsum(Obs), pch = 19)
[[alternative HTML version deleted]]
------------------------------
Message: 2
Date: Fri, 8 Nov 2019 11:01:50 +1300
From: Rolf Turner <r.turner using auckland.ac.nz>
To: Torsten Hauffe <torsten.hauffe using gmail.com>, R-mixed models mailing
list <r-sig-mixed-models using r-project.org>
Subject: Re: [R-sig-ME] [FORGED] Subjecting data to differential
equations deSolve
Message-ID: <71688763-b4a5-f25b-de8e-5bc9a2aa0d37 using auckland.ac.nz>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Maybe I'm obtuse (some would say that there's no "maybe" about it! :-) )
but I cannot for the life of me see what this question has to do with
mixed models.
Why not ask it on plain vanilla r-help???
cheers,
Rolf Turner
On 8/11/19 2:12 AM, Torsten Hauffe wrote:
> Dear list,
>
> My apologies if this question doesn't fit the scope of the mailing list.
>
> I try to solve some differential equations with the deSolve::ode and need
> to feed some values at certain time-points into the equations.
>
> Anyone has a guess why the results are off by factor 10?
>
> Thanks for any input and cheers,
> Torsten
>
> Here is a simplified reproducible example:
>
> # Time of observations
> ObsTime <- c(1.9, 2.0, 2.1, 3.9, 4.0, 4.1, 9.9, 10.0, 10.1, 23.9, 24.0,
> 24.1)
>
> # Value of the observations
> Obs <- c(0, 6, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0)
>
> # following the second example of ode(), it needs a function from where
> values could be obtained as function of time
> obs3Func <- approxfun(ObsTime, Obs, method = "constant", rule = 2)
>
> # Subjecting the time to the approx-function works
> obs3Func(ObsTime)
>
> # A simple function that I expect to return the cumulative sum of Obs (i.e.
> 15)
> Test_rhs <- function(t, x, parms, obsFunc)
> {
> with(as.list(c(parms, x)), {
> Sa <- obsFunc(t)
> list(Sa * s)
> })
> }
>
> Test <- ode(y = 0,
> times = seq(0, 65, by = 0.1),
> func = Test_rhs,
> parms = list(s = 1),
> obsFunc = obs3Func)
>
> # Using s = 1, the results are off (my expectation) by factor 10
> plot(Test)
>
> # With s = 10 the result is as expected but I don't know why
> Test2 <- ode(y = 0,
> times = seq(0, 65, by = 0.1),
> func = Test_rhs,
> parms = list(s = 1),
> obsFunc = obs3Func)
> plot(Test2)
> # Changepoints & values
> Time <- c(2, 4, 10, 24)
> abline(v = Time, lty = 2, col = "grey")
> points(ObsTime, cumsum(Obs), pch = 19)
------------------------------
Subject: Digest Footer
_______________________________________________
R-sig-mixed-models mailing list
R-sig-mixed-models using r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
------------------------------
End of R-sig-mixed-models Digest, Vol 155, Issue 5
**************************************************
More information about the R-sig-mixed-models
mailing list