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
47 stars 12 forks source link

Inconsistent output from ctmm.select() #38

Closed padpadpadpad closed 3 years ago

padpadpadpad commented 3 years ago

I have been helping a student with some models and came across something inconsistent in how models are assigned in the summary() output of a ctmm.select() object. The models are identical and the AICc scores are identical, but the order of the models is different...

The student wanted to use a loop to write several objects to the environment so we were using assign() and then get(data) inside the cttm.select() call. However the problem remains even in a simple reproducible example.

Having ran different variations of the code, it appears to be something wrong with running ctmm.select() inside assign(), but I cannot understand what the problem is.

# test code
library(ctmm)

data(buffalo)
Cilla <- buffalo$Cilla
vario.cilla<-variogram(Cilla)

GUESS <- ctmm.guess(Cilla, variogram = vario.cilla, interactive=FALSE)

# The four lines of code below should work the same 
FIT <- ctmm.select(Cilla,CTMM=GUESS, verbose=TRUE)
assign(paste("FIT", '1', sep = ""), ctmm.select(get('Cilla'),CTMM=GUESS, verbose=TRUE))
FIT2 <- ctmm.select(get('Cilla'),CTMM=GUESS, verbose=TRUE)
assign(paste("FIT", '3', sep = ""), ctmm.select(Cilla ,CTMM=GUESS, verbose=TRUE))

# check
summary(FIT)
summary(FIT1)
summary(FIT2)
summary(FIT3)

The summary output is: Screen Shot 2020-10-27 at 17 03 38

The two assign() outputs have a different order to the ones using <-. Any idea why this might be?

Many thanks Dan

chfleming commented 3 years ago

Thanks for raising the issue. It should be fixed in the master branch now.

The list names were not being updated because of an oversight. The actual objects were fine and in order. They were just mislabeled in the list.