NJKlappstein / hmmSSF

R package to fit state-switching step selection functions (HMM-SSFs) with covariate-dependent transition probabilities
3 stars 0 forks source link

hmmSSF simulation capacity? #2

Closed SnowpeaSoho closed 3 months ago

SnowpeaSoho commented 9 months ago

Very excited about this package, I’ve just worked through the vignette and looked through the additional files for your 2023 Movement Ecology paper, very helpful thank you :)

I was wondering if you please have code available for reproducing the figures 2-5 in your paper?

In particular, I am very interested in the simulation capacity described in the final paragraph of the methods (p8 of 13), the results of which are shown in Figure 5. This doesn’t appear yet to be implemented in the hmmSSF package, albeit there is another function (old name simHMMSSF.R) present but not yet documented/updated? While there are a few codes in the sim_example and sim_study folders, these don’t implement the workflow as described in the paper and I wonder if you are able to please provide that.

Also, one additional question: given the data frame input includes an ‘id’ column, can the hmmSSF be fit across multiple individual animals (complete pooling, per p6 of your 2023 Move Ecol paper)?

Very happy to see movement behaviour formally embedded in SSFs :D Thanks! (let me know if you want issues separated),

Sophie

NJKlappstein commented 9 months ago

Hi Sophie, glad to hear you're finding the package/paper useful!

I hope to add simulation capacity to the package in the future (hopefully in the spring/summer). In the meantime, the full code to reproduce the analyses/plots can be found at Zenodo (https://doi.org/10.5281/zenodo.7872602). You can find code to simulate a utilisation distribution and create the plots in the illustration folder. Note that the simulation function is not infinitely flexible and hasn't been written to be widely used. For example, it can only simulate from a model with transition probability covariates that can be derived prior to simulation (e.g., time of day) which rules out spatial covariates, and the SSF can only have simple linear terms. Let me know if you run into any issues with this.

Yes, the HMM-SSF can be fitted across multiple individuals. You will need a column named 'ID' that should identify each individual's track or track segment (i.e., if an individual has multiple track segments, the identifier for each track segment should be the ID rather than the individual). This is only if you have split your tracks due to large gaps (small gaps could be left as NAs). Note that complete pooling will estimate a single set of parameters for all individuals and therefore does not account for inter-individual variability.

I hope that's helpful. Natasha

SnowpeaSoho commented 9 months ago

Thank you very much, I will look up the Zenodo link and aim to use a TP cov such as time of year (seasonal influence).

A query in advance: is there anything built in for dealing with unavailable habitat (eg a lake for a terrestrial animal, or land for a marine animal) or do spatial covariates have to be completely filled?

I am looking forward to experimenting :) Best, Sophie

NJKlappstein commented 9 months ago

Hi Sophie,

If you have missing spatial covariates (i.e., if they are computed as NAs), the simulation function will remove these as potential locations (i.e., they cannot be included in the simulated movement track). So I think this will produce the result you are after.

Similarly, in model fitting, random points that have missing locations will not contribute to the likelihood.

Hope that helps, and sorry for my delayed response. Natasha

SnowpeaSoho commented 9 months ago

That all sounds like it should work great, thanks!

SnowpeaSoho commented 8 months ago

Hi Natasha, Thanks again for providing the code link 😊 I just wanted to let you know I have successfully walked through the manuscript workflow as preserved in your scripts, great job in reproducibility! I noticed only a few very minor details, which I have attached here in case its helpful for you at all, if updating. All the very best, Sophie