ctmm-initiative / ctmm

Continuous-Time Movement Modeling. Functions for identifying, fitting, and applying continuous-space, continuous-time stochastic movement models to animal tracking data.
http://biology.umd.edu/movement.html
43 stars 10 forks source link

newer version model selection is slower? #30

Closed xhdong-umd closed 5 years ago

xhdong-umd commented 5 years ago

Recently I noticed the model selection on the 100 points sample of buffalo data is slower than before. Long time ago it's always 7 secs, recently it's often slower. I did a test and found recent version do start to take more time. Maybe it's normal and needed by the new feature, just want to raise this to your attention to be sure there is nothing wrong.

# install various versions of ctmm

remove.packages("ctmm")
devtools::install_github("ctmm-initiative/ctmm")

library(ctmm)
library(ctmmweb)
data("buffalo")
tele_list <- pick(buffalo, 100)
model_try_res <- par_try_models(tele_list)

# it took 20 secs with current version for 100 points sample

# older versions
# 2018.08.07 version 0.5.1, 7 secs for 30 pints, 10 secs for 100 points.
devtools::install_github("ctmm-initiative/ctmm", ref = "0fcb40a17903f37f6dc961be71fbeec99b9b3a36")

# 2018.12.19 version, 11 secs for 100 points
devtools::install_github("ctmm-initiative/ctmm", ref = "93d6670ad28c088b4b68e11be7b2a016bf3da18f")

# 2019.02.11 version, 16 secs for 100 points
devtools::install_github("ctmm-initiative/ctmm", ref = "236254702786933288eca6648e9510520992786d")

# 2019.02.17 version, 16 secs for 100 points
devtools::install_github("ctmm-initiative/ctmm", ref = "3a6fed61960d2bdd93efcfd87b426bbab96d162f")
chfleming commented 5 years ago

I've made 3 updates that could have potentially caused some slowdown, due to failing corner cases:

  1. I included some alternate formulas in the matrix construction behind the Kalman filter, so that the OU/OUF -> BM/IOU limits retain full machine precision.
  2. I put some NaN checks in the Kalman filter where I knew what the 0/0 limit was supposed to resolve to, also for the OU/OUF -> BM/IOU limits.
  3. ctmm.select is now considering a larger number of models by default, because I was finding some non-intuitive behavior in the stepwise regression.

I suspect the cause is (3), given the dates you have listed, and because I don't think (1-2) should have caused too much slowdown. I still have some fine-tuning to do in (3), but it probably will not help with the buffalo, which are typically fit without an error model. Do you see more models output in the slower versions?

xhdong-umd commented 5 years ago

Yes I do see more models output. With the smaller sample of 30 points there are quite some columns about tao.