[R-sig-dyn-mod] possible error in events specification / implementation

Carl A B Pearson blank101 at gmail.com
Sat Dec 13 13:51:01 CET 2014


According to the documentation for using events in ode, when using the
data.frame approach (events = list(data=data.frame(...))) those events can
be specified in for different variables either by the names or positions in
the whole variable.

However, using positions does not appear to currently work.

Modifying the first example in ?events can demonstrate this:

derivs <- function(t, var, parms) {
  list(dvar = rep(0, 2))
}

yini <- c(1, 2) # change 1
times <- seq(0, 10, by = 0.1)
eventdat <- data.frame(var = c(1, 2, 2, 1), #change 2
time = c(1, 1, 5, 9),
value = c(1, 2, 3, 4),
method = c("add", "mult", "rep", "add"))

eventdat

out <- vode(func = derivs, y = yini, times = times, parms = NULL, events =
list(data = eventdat)) # now reports an error

plot(out)

Based on a cursory review of the rk.R code, it seems the check for events
assumes that y must be named (always calls the Ynames version).

	[[alternative HTML version deleted]]



More information about the R-sig-dynamic-models mailing list