Reprojecting ctmm movement models

163 views
Skip to first unread message

Marcus Michelangeli

unread,
Aug 22, 2024, 10:06:15 PM8/22/24
to ctmm R user group
Hi Chris. 

I have run into a problem when trying to calculate pairwise proximity and distance metrics between two individuals of a different species.

In short, the problem I have is that their ctmm's have different projections because I analysed them seperately. I know that you can change the projection of a telemetry object, but is it possible to change the projection of a ctmm object?

This is what I tried to do to rectify the issue (as what would work with a telemetry object)

test_ctmm <- list(pike_muddyfoot_ctmm_fits$F59880, roach_muddyfoot_ctmm_fits$F59707)

ctmm::projection( test_ctmm   ) <-ctmm::median( test_ctmm )

Error in getMethod("median", CLASS) : Cannot find method median for class ctmm

I am assuming that I am unable to change the projection once the movement has been modelled.

Some context about the data I am working with. My data is from a multi-experimental lake study where we tracked 3 different species of fish (2 prey: roach (30 individuals) and perch (30 individuals), 1 predator: northern pike (6 individuals)) in each lake. Median sampling interval for each species ~4secs, tracked over ~36 days. I'm interested in estimating the interaction rates, and possible predation events,  between predator and prey.

As you can imagine, I have a lot of location data, and running the ctmm's took a very long time, so if I can avoid re-running these, that would be ideal. 

Thanks for your time
Marcus

Christen Fleming

unread,
Sep 1, 2024, 9:39:34 PM9/1/24
to ctmm R user group
Hi Marcus,

I just pushed a projection()<- assignment method for ctmm class objects to GitHub. Please try that.

Best,
Chris

Marcus Michelangeli

unread,
Sep 3, 2024, 12:40:30 AM9/3/24
to Christen Fleming, ctmm R user group
Amazing, thanks Chris, it works.


--
You received this message because you are subscribed to the Google Groups "ctmm R user group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ctmm-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ctmm-user/8253f4af-760c-4938-b890-4a995143eecfn%40googlegroups.com.

Marcus Michelangeli

unread,
Sep 3, 2024, 12:55:42 AM9/3/24
to ctmm R user group
Hi Chris,

Sorry, while I was able to reproject my ctmm models, I am still getting the same error message when trying to calculate pairwise proximity and distance metrics with the function distances().

Error in check.projections(data) : Inconsistent projections.

I am still getting this error message even though all ctmm and telemetry objects in distances() have the same projections. 

test_telem <- list(pike_muddyfoot_tel$F59880, roach_muddyfoot_tel$F59707)
names(test_telem) <- c('F59880', 'F59707')

test_ctmm <- list(pike_muddyfoot_ctmm_fits$F59880, roach_muddyfoot_ctmm_fits$F59707)
names(test_ctmm) <- c('F59880', 'F59707')

#Center the projection on the geometric median of the data
ctmm::projection(test_telem) <- ctmm::median(test_telem)
projection(test_telem)

[1] "+proj=aeqd +lat_0=63.7710945900604 +lon_0=20.0482803129897 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"

#give ctmm object the same projection
ctmm::projection(test_ctmm) <- ctmm::projection(test_telem)
projection(test_ctmm)

[1] "+proj=aeqd +lat_0=63.7710945900604 +lon_0=20.0482803129897 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"

Marcus Michelangeli

unread,
Sep 3, 2024, 1:10:55 AM9/3/24
to ctmm R user group
Sorry again. I solved my issue

This code doesn't work as I get the inconsistent projection warning. 
DISTS <- distances(c(test_telem$F59880, test_telem$F59707),
                   c(test_ctmm$F59880, test_ctmm$F59707))

This code works without specifying each element within each object
 DISTS <- distances(test_telem, test_ctmm)

Perhaps there is a reason why one works and the other doesn't?

Christen Fleming

unread,
Sep 3, 2024, 10:22:59 AM9/3/24
to ctmm R user group
Hi Marcus,

In the first code block,  c(test_telem$F59880,test_telem$F59707) is not a list of telemetry objects (similar with the ctmm objects).

You would want something like
test_telem[c('F59880','F59707')]
or
list( F59880 =test_telem$F59880, F59707 =test_telem$F59707)

Best,
Chris

Marcus Michelangeli

unread,
Sep 3, 2024, 10:33:12 PM9/3/24
to ctmm R user group
Ah okay. That makes sense

Thanks Chris
Reply all
Reply to author
Forward
0 new messages