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

Calibration with uere.fit #47

Closed marbotte closed 1 year ago

marbotte commented 1 year ago

I get a surprising result when I compare VAR.xy and HDOP in my telemetry objects, which have been calibrated with independent dataset:

the slope of a linear model between the square root of VAR.xy and HDOP is always equal to 7.071, while the calibration datasets are quite different

I put my code in this document: https://github.com/PEM-Humboldt/urban-wildlife-tracking/blob/main/data_management/local/SpatialErrorCalibration.md#calculating-uere

I am no expert in telemetry. I read the paper "A comprehensive framework for handling location error in animal tracking data" (Fleming et al, 2021, preprint), but I should confess I do not understanf everything.

So my question is whether:

Please know that one of the 2 first options are likely, I am quite a beginner in movement ecology.

What I find surprising is that the UERE objects are different:

UERE_list$Zorro02
An object of class "UERE"
[[1]]
         horizontal vertical
gps NA 3   21.98817 16.99704

[[2]]
         horizontal vertical
gps NA 3         17       17

[[3]]
horizontal   vertical 
  341.3062   188.7123 

[[4]]
horizontal   vertical 
  1.107132   2.394613 

[[5]]
horizontal   vertical 
  1.002452  27.578882 

[[6]]
horizontal   vertical 
        18         18 

Slot "info":
list()
UERE_list$Zarigueya2
An object of class "UERE"
[[1]]
         horizontal vertical
gps NA 3   79.45091  74.8428

[[2]]
         horizontal vertical
gps NA 3         20       20

[[3]]
horizontal   vertical 
  470.6473   267.6472 

[[4]]
horizontal   vertical 
 0.9290836  1.0754054 

[[5]]
horizontal   vertical 
  2.870670   8.674563 

[[6]]
horizontal   vertical 
        21         21 

Slot "info":
list()

But:

 (LM_errorZorro02<-lm(sqrt(zorro02_ctmm$VAR.xy)~zorro02_ctmm$HDOP))

Call:
lm(formula = sqrt(zorro02_ctmm$VAR.xy) ~ zorro02_ctmm$HDOP)

Coefficients:
      (Intercept)  zorro02_ctmm$HDOP  
        1.017e-14          7.071e+00  

> (LM_errorzarigueya2<-lm(sqrt(zarigueya2_ctmm$VAR.xy)~zarigueya2_ctmm$HDOP))

Call:
lm(formula = sqrt(zarigueya2_ctmm$VAR.xy) ~ zarigueya2_ctmm$HDOP)

Coefficients:
         (Intercept)  zarigueya2_ctmm$HDOP  
          -2.122e-14             7.071e+00 

I used R version 4.2.1 (2022-06-23) and ctmm "1.1.1"

Thank you very much for your work on ctmm!

chfleming commented 1 year ago

Hi @marbotte , 7.071 is 10/sqrt(2), which is the default 10-meter RMS UERE. Looking at your link, I think the issue is that your tracking data have a location class of "2514698630 NA 3", while the calibration data have a different location class of "gps NA 3". Calibrations are applied on a per-class basis, because you can have different location classes (or even different tracking technologies) in the same datasets. Are the tracking and calibration data formatted the same way (especially with respect to the location-class columns)? If there's really only one location class in the data, then it might be easiest to remove those columns before importing.

marbotte commented 1 year ago

Ah, okay, thanks! I saw these "location class" in the tables but I thought it did not matter in my case... my bad! Could you explain what information exactly the location classes should have. (I mean: how do ctmm define what are these classes based on movebank data? From which columns of the movebank table does it take the information). That way I'll define how to manage those location classes in my case.

It is indeed one problem in our study: animal tracking data comes directly from movebank with the movebankGetData function, but the calibration datasets have been built from Excel "in a movebank format", so no, they are not formatted exactly in the same way!

May I suggest something? Could uere(x)<- throw an error, or at least a warning when the location class in the calibration dataset does not correspond to the location class in the movement dataset?

marbotte commented 1 year ago

I have another question: one of my colleagues first made the calibration process in ctmmweb, I am currently adapting what she did in a code way with ctmm. She actually used the same files as I used but in ctmmweb. Is it possible that in ctmmweb, the datasets are flaged as "calibrated" but it actually applied the default 10-meter RMS UERE? If this is the case it might be a problem because people believe they did the job, but because the location classes are different the RMS UERE does not make more sense than applying a 10meter UERE... Would it be possible to flag it with some warnings?

chfleming commented 1 year ago

Hi @marbotte , there are valid situations where the location classes might differ, but I could throw a warning message.

It would have worked the same way in ctmmweb.

marbotte commented 1 year ago

Thanks a lot @chfleming ! A last question: Is it safe to force-assign a location class in the telemetry object? like

telem$class <- "GPS"

Or does it potentially break some links between slots of a telemetry object and the validity of the object?

chfleming commented 1 year ago

Hi @marbotte , I think the following would work before calibration:

telem$class <- factor("GPS") # or just telem$class <- NULL
uere(telem) <- NULL
marbotte commented 1 year ago

That worked! Thanks a lot!