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

Error for `mean` of ctmm and UD with periodicity #53

Closed cwilhite4151 closed 3 months ago

cwilhite4151 commented 8 months ago

Aloha, there appears to be an issue with mean for both ctmm and UD objects with periodicity.

library(ctmm)

data(wolf)
wolf <- wolf[c(1, 3)]

# proto ctmm
PROTO <- ctmm(mean="periodic",period=c(24 %#% "hours",1 %#% "month"),circle=TRUE)

# variogram
SVF <- lapply(wolf, variogram, res = 3)

# ctmm parameter guestimate
GUESS <- lapply(
  seq_along(wolf),
  function(i) {
    ctmm.guess(wolf[[i]], PROTO, variogram = SVF[[i]], interactive = FALSE)
  }
)

# model fits (...change n cores...)
FITS <- lapply(
  seq_along(wolf), 
  function(i) {
    ctmm.select(wolf[[i]], GUESS[[i]], cores = 8)
  }
)

# mean ctmm: error (pretending these are two tracks for the same individual)
mean_FITS <- mean(FITS)

# akde
UD <- akde(wolf,FITS,debias=TRUE,weights=TRUE)

# mean UD: error
mean_UD <- mean(UD)
chfleming commented 7 months ago

Sorry for the delay. I believe the errors are fixed now. Occasionally, I find that the optimizer gets hung up on one of the models, but I will have to look more into that later (with n=2, it could just be very multi-modal or something).