[R-sig-dyn-mod] Event Timing question

Thomas Petzoldt Thomas.Petzoldt at TU-Dresden.de
Tue Jun 14 12:44:43 CEST 2011


Dear Melissa,

cleanEventTinmes and nearestEvent are called automatically by default, 
but sometimes a warning may occur to remind you that something was fixed 
automatically behind the scenes. We had a long discussion about how to 
implement this as a compromise between user-friendliness and 
reproducibility and decided to fix inconsistent time steps 
"automagically" but issue a warning.

So this is not an error, but only a hint to carefully check consistency 
of integration and event times.


A few remarks to your example:

1) Your example is not fully reproducible. I was able to assume values 
for a, r and init.x  (from my previous post):

http://tolstoy.newcastle.edu.au/R/e7/help/09/06/1230.html

but I don't see exactly what is in "env.fmort".


2) I wonder also why you implement "env.fmort" as events and not as 
forcing functions, e.g. of controlling resource(s). Note also that 
mortality is already part of your model in the interaction matrix "a" 
and the population growth rate vector "r" (= negative values of r).

If we assume that using events would be a correct approach, then:


3) Still the handling of the different times is not completely clear.
Note that you need to time vectors, one for the integration time steps 
and one for the events.

4) Given that all these inconsistencies are solved, the following would do:


## times of the events
evtimes <- seq(0,200,1)

## output time steps of the integration
t.out <-seq(0, 200, length=2000)

## unique times that are in t.out but not in evtimes
t.unique <-  cleanEventTimes(t.out, evtimes)

## corrected t.out with all values of t.out and all events
t.out2 <- sort(c(t.unique, evtimes))

## checks
evtimes %in% t.out    # not all events in t.out
evtimes %in% t.out2   # corrected: all events are now contained

################################################################

For your example it would also work like this:

## times of the events
evtimes <- seq(0, 200, 1)

## output time steps of the integration
t.out <- seq(0, 200, length=2001)    # note 2001 and not 2000 !!

## check if all evtimes are contained in t.out
evtimes %in% t.out


Note that if this last check fails, some rounding may be necessary.



Thomas Petzoldt



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