ocouriot/TuktuTools

Question : Why the first value of dt is NA and not the last one?

VVanlan opened this issue · 2 comments

Hi,

I have a question about how dt (in GetSpeed) is calculated. In other package dealing with animal movement such as adehabtiatLT and amt, dt is calculated as the time between the relocation i and the relocation i+1.

Example for one individual
dt = c(difftime( time[-1], time[-nrow(time)], NA)

Loc dt
1 t2-t1
2 t3-t2
3 t4-t3
4 NA-t4

The last value is NA, because no observed step is 'started' at the last point.

Your code :
dt = c(NA, difftime(Time[-1], Time[-length(Time)], units = "hours"))

Loc dt
1 NA
2 t2-t1
3 t3-t2
4 t4-t3

Is there a reason for that?

Thanks!

Thanks for pointing that out ... I (for one) don't usually use movement data structure from those other packages.

The choice is mainly arbitrary - and is just how I have always done it since I was making tables like this (now many years ago) - but my choice has always been somewhat philosophically motivated by the fact that you can say where someone came from but should avoid predicting where someone is going to. Thus, at $t_2$ we can talk about the interval of time that preceded it, and the step length that brought us there, etc. Also, for example, with turning angles - you can't know the turning angle for the 1st location OR the 2nd location, only the 3rd step - since you need the first two locations to know what angle you are turning relative to. It's, essentially, a difference of a difference. Which argues for the NA's to lead the vector.

The counter-argument is that maybe your goal is to predict something about a movement based on attributes of a given location, for example. In that case, it makes more sense the other way.

Again - this is mainly my (our) preference and what we're used to. The important thing is to be mindful of what you're looking at (and looking for!)

Thanks for the anwers!
I really appreciate it. I never thought about it like that because i am used to predict movement. It makes sense now.