[R-sig-dyn-mod] Initial value for additive events
Daniel Kaschek
daniel.kaschek at physik.uni-freiburg.de
Sun Apr 19 09:33:44 CEST 2015
Hi John,
you could plot log(x + offset) instead of log(x). In ggplot2 you can
even define your own transform, e.g. based on log(x + offset) and then
use it in analogy to the predifined scales scale_y_log10() or
scale_y_sqrt().
Cheers,
Daniel
---------------------------------
Daniel Kaschek
Institute of Physics
Freiburg University
Room: 210
Phone: +49 761 2038531
On Sa, Apr 18, 2015 at 1:24 , John Harrold <john.m.harrold at gmail.com>
wrote:
> Hello,
>
> When I have an additive event that occurs at the initial sample time
> the
> state receiving the value has a value of the specified initial
> condition.
> For example see the code below. I understand that the initial
> condition is
> set to zero, but I guess from my perspective adding a value at time
> zero
> should change that initial condition. This is important for me because
> bolus injections (impulse functions) into states with a value of zero
> is
> pretty common for my work. It makes plotting things on a log scale
> difficult when a zero value always exists. It also looks kind of
> silly to
> have the system start at zero when the injection was supposed to
> occur.
>
> So my question is more about how to deal with this if my goal is to
> remove
> this point? One option is to automatically sample at a really small
> value
> (SV = 250*.Machine$double.eps) then set the value of the state
> receiving
> the event at time zero to the value at time SV. It's messy but doable.
> Anyway I was wondering if there were any thoughts?
>
> Thanks
> John
>
> <CODE>
> rm(list=ls())
> library("deSolve")
> library("ggplot2")
> yini <- c(v1=0)
> times <-seq(0,10, by=.01)
> f1 <- function (t, y, parms) {
> ydot <- vector(len = 1)
> ydot[1] <- - 0.1*y[1]
> return(list(ydot))
> }
> eventdat <- data.frame(var = c("v1", "v1", "v1", "v1"),
> time = c(0, 1, 2, 3),
> value = c(1, 1, 1, 1),
> method = c("add", "add", "add", "add"))
> out <- ode(func=f1,
> y=yini,
> times = times,
> parms = NULL,
> events = list(data = eventdat))
> plot(out, type="l", lwd=2)
> </CODE>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
More information about the R-sig-dynamic-models
mailing list