Hi Chris et al.,
I am working to calculate RSFs for a group of marine turtles (n = 20) tracked for between 4-13 months.
I aim is to understanding how changing coverage of key habitats effects suitability/distribution across a region (plus a few other variables). I have a mix of categorical (e.g. depth) and continuous (e.g. seagrass cover) predictor layers that I am planning to include in the final analysis.
I have managed to run RSFs on a test dataset, but I have a few queries.
(1) Averaging ranges - Some individuals (~50%) in my population undergo range shifts so I segmented the data and calculated multiple AKDEs. There was an answer somewhere (maybe this one) that suggested that to return the full range of the individual range I need to run mean with weighting. So to calculate the mean AKDE for my sample population prior to running RSF I assume I have to:
a. First run mean() for each individual that uses multiple ranges and weight this mean by the time spent in in each range
b. Then run mean() across all individuals and weight by the tracking duration fo each individual.
(2) Rsf vs rsf.select - As I am using a mean AKDE I also think I need to use rsf.select() instead of rsf.fit (mentioned here)
(3) Viewing points used in rsf calculations – is it possible to plot the points that have been used in the rsf calculations? For my understanding of the rsf calculation (and so that I can explain ot my supervisors/collaborators) It would be great to visualise the chosen presences, available locations, and available area.
(4) Plotting responses – based on this response it seems that diagnostic and residual plots are on the cards at some point. In the meantime is there a simple way to extract the required parts of the rsf.fit to plot model outputs from the summary? I haven't done much manual plotting of models and would love to be able to create plots similar to those attached.
Cheers,
Mike
Hi Chris,
I am back at this after some time on a different project. I am trying to get my code for RSFs to run and am coming up against some problems.
• The main issue is with memory, similar to this thread, which as well as causing errors takes a long time. I have 42 sites to iterate over and running an rsf for the first site alone takes >1 hour and then runs into memory issues. The resolution of the predictors is quite high (10m) so aggregating to ~100m might be one option, but it would be nice to get it running at this resolution if possible.
• I have cropped the predictor layers to the extent of each UD to try and help speed things up (but could I just project the layers to the ctmm projection to limit the function reprojecting everything?)
• Integrator = Reimann is a little bit quicker ( I think), but still pretty slow.
• I think define formulas would minimise additional calculations/dredging. But, I am unsure how these should be formatted? Also, when defining formulas can I test multiple within the same function or would I have to repeat the rsf calculation for each additional formulae I want to test?
For example with the below, poorly formatted, formulas could I run rsf.select(…,formula = FORM) or would it have to be rsf.select(…,formula = FORM[[i]]) in a loop?
FORM <- c("~ H.EXTRA", “H.EXTRA + Bathy", “H.EXTRA + H.EXTRA:Bathy")
• I am also interested in using an offset to prevent predictions from being on land (land should be NA in my predictor layers anyway. I have an layer called landoffset where land is 1 and water is 0, but I am unsure where or how I should add this.
I am predominately using terra and then changing to raster at the end so that may contribute towards my issues. I will try and get my code into a reproducible format soon if that helps, but in the meantime any advice on how to speed up processing would be appreciated.
Thanks again,
Mike
Hi Chris,
I might see if loading the files and not manipulating them works to keep them in RAM. Otherwise I could try to crop them to a smaller area covering all ranges or stick with cropping them to the extent of each UD as I calculate my loop. Would cropping to the extent of the UD cause issues if some categorical values are not in that area and I want to average across sites?
It seems like the i value is Null or <1, but I am not sure where in the source code this issue is occurring or how to fix it. I am running R 4.3.1, and tested this with ctmm_1.1.1 and the most recent github version.
I have what should be a reproducible script and data in this drive folder to see if you can recreate the error. Apologies for the size of the files, when I have a moment I will recreate it with smaller pred rasters.
Cheers,
Mike