Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with BIOMOD_PresenceOnly - Can biomod calculate continous boyce index? #285

Closed
tongruiju opened this issue Jun 26, 2023 · 9 comments
Closed
Labels
help wanted How to use biomod2 functions and outputs

Comments

@tongruiju
Copy link

Dear Team,

I have used Biomod to make my predictions. I now need to evaluate the predicted maps using the continuous Boyce index. I am wondering if there is a way to do this using Biomod.

Best,
Ruiju

@tongruiju tongruiju added the help wanted How to use biomod2 functions and outputs label Jun 26, 2023
@rpatin rpatin changed the title Help with BIOMOD_xxx - Can biomod calculate continous boyce index? Help with BIOMOD_PresenceOnly - Can biomod calculate continous boyce index? Jun 26, 2023
@rpatin
Copy link
Contributor

rpatin commented Jun 26, 2023

Dear Ruiju,
Thank you for reporting :pray
You can calculate the Boyce index with BIOMOD_PresenceOnly:

# Evaluate models with Boyce index and MPA
myBiomodPO <- BIOMOD_PresenceOnly(bm.mod = myBiomodModelOut,
                                  bm.em = myBiomodEM)
myBiomodPO

# Evaluate models with Boyce index and MPA (using background data)
myBiomodPO <- BIOMOD_PresenceOnly(bm.mod = myBiomodModelOut,
                                  bm.em = myBiomodEM, 
                                  bg.env = values(myExpl))
myBiomodPO

Note that the function BIOMOD_PresenceOnly will disappear in next biomod2 version (eta end of summer) and calculations of MPA and Boyce Index will be fully integrated within BIOMOD_Modeling as other evaluation metrics.
Best,
Rémi

@tongruiju
Copy link
Author

Dear Rémi,
Thanks a lot for your response. As far as I know the Boyce index is different to the Continous Boyce Index.
I wonder if the Boyce index calculated by biomod is the Continous Boyce Index?

Best regards,
Ruiju

@rpatin
Copy link
Contributor

rpatin commented Jun 26, 2023

Dear Ruiju,
Happy to help !
It is the same thing. You can check ecospat documentation or the following reference for more informations:

Hirzel, A. H., Le Lay, G., Helfer, V., Randin, C., and Guisan, A. 2006. Evaluating the ability of habitat suitability models to predict species presences. Ecological Modelling, 199(2), 142-152

Best regards,
Rémi

@tongruiju
Copy link
Author

Hi Rémi,

I see the distinction between the Boyce index and the continious Boyce index. Please refer to the following paragraph from (Hirzel et al., 2006).
The main shortcoming of the Boyce index is its sensitivity to the number of suitability classes b and to their boundaries (Boyce et al., 2002; personal observations). To fix this problem, we derived a new evaluator based on a “moving window” of width W (say W= 0.1) instead of fixed classes. Computation
starts with a first class covering the suitability range [0,W] whose P/E ratio is plotted against the average suitability value of the class, W/2. Then, the moving window is shifted from a small amount upwards and the P/E is plotted again. This operation is repeated until the moving window reaches the last possible range [1 −W, 1]. This provides a smooth P/E curve, on which a “continuous Boyce index” Bcont(W) is computed.

So, how is the Boyce index of biomod2 calculated? If it is calculated using a specific number of suitability classes then it is Boyce index. If it is calcalated based on a “moving window” of width, then it is continous Boyce index.

Best,
Ruiju

@rpatin
Copy link
Contributor

rpatin commented Jun 28, 2023

Hi Ruiju,

biomod2 calculate the Boyce index based on ecospat.boyce from package ecospat. Given that its documentation mention Hirzel et al. 2006, which was published in a collaboration with ecospat team, I suppose they calculate the continuous Boyce Index.
If you want further information I suggest asking the question to ecospat team directly.

Best,
Rémi

@tongruiju
Copy link
Author

tongruiju commented Jun 28, 2023

Hi Rémi,

Thanks very much for your assistant.
From my understanding, it is more accurate to use background data for calculating the Boyce index.
However, since my dataset is large, it is very time-consuming to calculate using the provided codes:

myBiomodPO <- BIOMOD_PresenceOnly(bm.mod = myBiomodModelOut,
                                  bm.em = myBiomodEM, 
                                  bg.env = values(myExpl)

I am wondering if it is possible to use a certain number of random selected background points instead of the entire background. If so, I would like to know how to modify the code and what format the extracted environmental variables of the selected background points should be. Thank you very much in advance.

Best,
Ruiju

@rpatin
Copy link
Contributor

rpatin commented Jul 10, 2023

Hi Ruiju,
You can provide BIOMOD_PresenceOnly with a data.frame containing a subset of the environmental data.
Here is the way to go (given that you work with terra and spatRaster):

library(terra)
n.sample <- 100 # adjust the sample size to suit your needs
myExpl.subsampled.df <- spatSample(myExpl, size = n.sample, na.rm = TRUE)
myBiomodPO <- BIOMOD_PresenceOnly(bm.mod = myBiomodModelOut,
                                  bm.em = myBiomodEM, 
                                  bg.env = myExpl.subsampled.df)

Best regards,
Rémi

@rpatin rpatin closed this as completed Aug 16, 2023
@riyapakhre
Copy link

Hii,
I've performed sdm using MaxEnt software and now need to calculate the Continuous Boyce Index. I am planning to use ecospat.Boyce for the purpose, however, I'm confused about the inputs required. Any kind of help shall be welcomed. Thanks!

@MayaGueguen
Copy link
Contributor

Hello there,

Please note that this is biomod2 help page 👀

We are indeed using in our code the ecospat.boyce from the ecospat package.
As it was the only function together with ecospat.mpa we were using from this package, we included the code directly in one of our file with reference to simplify dependencies. The code is visible here.
Note that (unless it changed since August 2022), it should be the same as the code from the function ecospat.boyce from the ecospat package.

As indicated in the comments, the function requires as inputs the predicted values for all points (parameter fit) and the predicted values only for points that were observed as presences (parameter obs).

Hope it helps,

Maya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted How to use biomod2 functions and outputs
Projects
None yet
Development

No branches or pull requests

4 participants