rsf.fit - running weighted RSFs with time-sensitive data

180 views
Skip to first unread message

Fang Chen

unread,
Jul 17, 2023, 10:39:30 PM7/17/23
to ctmm R user group
Hello Chris,

I am currently working on running the weighted RSFs mentioned in Alston et al. (2022) to deal with my GPS data set with two different intervals (5 and 8.5 hours). I tried to modify the code provided by Alston et al. for my data, but I am facing challenges incorporating time-sensitive data, such as NDVI or temperature, into the rsf.fit (or rsf.select) function. 

Here is the code I tried, where I used the mean value of NDVI:
ctmm:::rsf.fit(dat_tel[1]$bb01,UD=AKDE[1]$bb01,R=list(ndvi=ndvi_ll_c,elevation=elev_ll),debias=TRUE,error=0.01, integrator="Riemann",interpolate = FALSE)

While this approach worked, I would like to know if it is possible to incorporate time-sensitive data into the model and how. I am sorry if this question has been asked previously. Any advice would be highly appreciated.

Thank you so much for your time.

Best regards,

Fang

Christen Fleming

unread,
Jul 18, 2023, 4:17:26 AM7/18/23
to ctmm R user group
Hi Fang,

There is support for time-dependent modifiers like time of day. Support for time-dependent rasters is being added this year. I will announce to the group when it is working.

Best,
Chris

Jesse Alston

unread,
Jul 18, 2023, 7:16:12 PM7/18/23
to Christen Fleming, ctmm R user group
Hi Fang,

To follow up on what Chris said, if you have a time-dependent modifier like temperature in your data, you can use the formula argument in rsf.fit() to add an interaction term. For your example, it would look something like this:

ctmm:::rsf.fit(dat_tel[1]$bb01,UD=AKDE[1]$bb01,R=list(ndvi=ndvi_ll_c,elevation=elev_ll),formula=ndvi+elevation+ndvi:temperature+elevation:temperature,debias=TRUE,error=0.01, integrator="Riemann",interpolate = FALSE)

If you do this, be sure that your data is standardized--ctmm does this automagically under the hood unless you use the formula argument.

Jesse



--
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/6c5bff10-9376-425e-8dc8-d89536b153afn%40googlegroups.com.


--

Fang Chen

unread,
Jul 18, 2023, 8:52:36 PM7/18/23
to ctmm R user group
Hi Chris and Jesse,

Thank you so much for your help. I will wait for the announcement and try the formula that Jesse mentioned to add interaction between covariates.

Thanks again,

Fang

Fang Chen

unread,
Sep 4, 2023, 9:13:52 PM9/4/23
to ctmm R user group
Hello Chris,

I came back to this issue after a couple of months. I want to incorporate the change in NDVI over time, so I wrote a code called find_ndvi(coordinate, time) to return the NDVI value of a location at a certain time. I was wondering if either of the methods below could work for my data set: 

1. Extracting the coordinate, timestamp, and weight of each available point and conduct a weighed logistic regression (simple GLM)
- You mentioned that it is possible to plot the points generated by the Gaussian availability model in the previous discussion. Therefore, I was wondering if we can plot the available points, can we extract the coordinates, timestamp, weights, and effective sample size (N) for each point using ctmm package and how (I am thinking about using Riemann integration)?

2. Modifying the code of rsf.select to incorporate find_ndvi function for NDVI value extraction
- I tried to figure out how formula works, but I am not sure if "formula" can be used as a place to put a function command (in my understanding, formula is an object to specify the relationship of elements in R=list() that I want to test? not sure if this is correct). I was wondering if there is any way that I can modify the code to extract time-dependent values for my data points.

I am sorry for bothering you multiple times with the same issue. Any thoughts and information would be greatly appreciated.


Thank you so much for your time.

Best regards,

Fang

Christen Fleming

unread,
Sep 5, 2023, 10:57:48 AM9/5/23
to ctmm R user group
Hi Fang,

You would need to sample a set of available points for each time, like you do in SSFs, because the normalization is different for every time.
Riemann integration would be slow in the time dependent case, because of having on integral per time.
Until I finish the time-dependent code in rsf.fit(), finding some time-dependent SSF code is probably the easiest way forward.
I will probably get to this in the next couple of months.

Best,
Chris
Reply all
Reply to author
Forward
0 new messages