# News

##

###

## Development updates

### 2023

#### 4.2-5 Modeling options and Tuning (2023-09-12)

##### Major Changes

- Reformat modeling options, how they are created and how they are given to models :
  - Create `BIOMOD.options.default` and `BIOMOD.options.dataset` classes, retrieving default parameters and values with `formalArgs` function
  - Modeling options can now be different for PA x cross-validation datasets x models
  - Add `ModelsTable` and `OptionsBigboss` datasets containing single models informations and pre-defined modeling options
  - Move `BIOMOD_ModelingOptions` to `bm_ModelingOptions`
  - Call `bm_ModelingOptions` directly in `BIOMOD_Modeling` and add related `OPT.[...]` parameters
- Move `BIOMOD_Tuning` to `bm_Tuning` and adapt it to match with new modeling options
- Modify the call to single models in `bm_RunModelsLoop` in a more generalized way dealing with new modeling options

##### Minor Changes

- Remove `BIOMOD_PresenceOnly` function and add `BOYCE` and `MPA` indices into `bm_FindOptimStat` function
- Save ensemble projections with `FLT4S` datatype only when EMcv is activated, otherwise use `INT2S`
- Add vignette for data preparation (questions you should ask yourself before modeling)
- Correct getters (variable importance, built models)
- Update examples and documentation

##### Bugfix

- 4.2-4-10 : fixed `wrap` applied to a `data.frame` in `BIOMOD_Projection`
- 4.2-4-9 : fixed `predict` method for `RF` with `do.classif = FALSE`
- 4.2-4-8 : improved tests in `bm_PlotEvalMean`
- 4.2-4-7 : fixed `do.classif` ignored in `BIOMOD_ModelingOptions`
- 4.2-4-6 : fixed parallelization in `BIOMOD_Projection`
- 4.2-4-5 : fixed summary method for `BIOMOD.formated.data` and `BIOMOD.formated.data.PA`
- 4.2-4-4 : fixed `bm_PlotResponseCurves` for ensemble models merged by algo (for Maxent)
- 4.2-4-3 :
  - added `point.size` argument to `plot.BIOMOD.Formated.data`
  - added `maxcell` argument to `plot.BIOMOD.projected.out`
- 4.2-4-2 : set XGBOOST `verbose = 0` (from `verbose = 1`)
- 4.2-4-1 : fixed `BIOMOD_FormatingData` checks for `resp.xy`

#### 4.2-4 XGBOOST (2023-06-21)

##### Major Changes

- added XGBOOST as a possible algorithm in `BIOMOD_Modeling`

##### Minor Changes

- changed `CV.do.full.models` default value to `FALSE`

##### Bugfix

- 4.2-3-5 :
  - fixed some more issues related to categorical variables badly interacting with missing values. Projection and Ensemble Forecasting are now only calculated on cells without any missing values.
  - removed obsolete code for SRE pseudo absences sampling with categorical variables, as SRE do not work with categorical variables
  - added internal function to get mask of data `.get_data_mask`
- 4.2-3-4 : fixed bug in `BIOMOD_Modeling` when using `sampsize` as a vector. argument `strata` was badly formatted
- 4.2-3-3 : fixed bug in `BIOMOD_EnsembleModeling` for additional projection with only one environmental variables
- 4.2-3-2 : fixed bugs in `BIOMOD_EnsembleForecasting` when several projection are running simultaneously and using the same temporary directory
- 4.2-3-1 : fixed bugs in `bm_CrossValidation` with `user.defined` tables badly formatted (TRUE/FALSE for data not in the given PA dataset are now properly transformed into NA)

#### 4.2-3 Cross-Validation and Pseudo-Absences (2023-05-09)

##### Major Changes

- Improved pseudo-absence management: it is now possible to have pseudo-absence dataset of different size and algorithm can be setup to run on different pseudo-absence dataset (with `models.pa` argument in `BIOMOD_Modeling`).
- Rework and harmonization of cross-validation function. `BIOMOD_CrossValidation` have been renamed `bm_CrossValidation` and cross-validation with k-fold, stratified and environmental strategy now work properly with pseudo-absence dataset. All cross-validation strategy can now be called directly through `BIOMOD_Modeling`.

##### Minor Changes

- improved Documentation (`get_evaluations`, `BIOMOD_EnsembleModeling`, `bm_RunModelsLoop`, `bm_RunModel`)
- updated website tutorial to use current biomod2 version
- removed unused parameter `save.output`. output are now automatically saved.
- improved management of categorical raster for both `terra` and `raster`
- `CV.perc` (formerly `data.split.perc`) now uses a 0-1 range (instead of 0-100)
- deprecated arguments for `BIOMOD_EnsembleModeling` now gives an error.
- added argument `metric.select.dataset` to `BIOMOD_EnsembleModeling` to choose the dataset which evaluation metric should be used to filter and/or weigh the ensemble models. Default value is now ‘validation’ instead of ‘evaluation’.
- added argument `na.rm` to `BIOMOD_EnsembleModeling` to harmonize the management of `NA` among individual model predictions.

##### Bugfix

- validation metric calculation now properly use the calibration threshold (i.e a threshold optimized on calibration data instead of validation data). This can lead to less optimistic threshold-dependent validation metric.
- fixed SRE projection assuming the same variables ordering in calibration and projection data
- ensemble model can again be calculated over models without validation
- correct print for multiple values in `RF$sampsize` parameter in `BIOMOD_ModelingOptions`
- fixed layer name in `BIOMOD_Projection` and `BIOMOD_EnsembleForecasting` when `terraOption(todisk = TRUE)` is activated (for large or numerous raster).
- fixed Ensemble Models based on models without cross-validation (“allRun”)
- model is now robust to using `data.table` object (that are converted into standard `data.frame`).
- fixed projection raster name when using `do.stack = FALSE` and `resp.name` with `.` inside.
- fixed using user-defined pseudo-absences along with `filter.raster = TRUE` in `bm_PseudoAbsence`.
- fixed weights calculation when using only one pseudo-absence dataset
- fixed summary and show method for `BIOMOD.formated.data.PA`

##### Internal

- add internal function `get_species_data` and `get_eval_data`
- removed `.BIOMOD_Modeling.prepare.data`
- reorganised `bm_RunModelsLoop` to do the PA loop within the function
- `calib.lines` and `eval.lines` variable names are standardised (no more `calibLines` or `eval_lines`)
- removed dependency to `data.table` (removed use of `rbindlist`)
- added `.get_env_class` to reduce code redundancy
- renamed `categorical_stack_to_terra` into `.categorical_stack_to_terra`
- dispatched some of `BIOMOD_FormatingData` checks into `bm_PseudoAbsences`

#### 4.2-2 Improvement patch (2023-01-13)

##### Major Changes

- `'.tif'` is available as an output format for raster projection
- `'.tif'` is the new default output format for raster projection
- Improved `plot` and `summary` methods for `BIOMOD_FormatingData` output. These method now support the use of `calib.lines` to explore how the cross-validation dataset are structured.
- Updated `plot` methods for `BIOMOD.projection.out` objects so that it uses `ggplot2` for nicer plots.
- Binary and Filtered transformation are now properly stored in `BIOMOD.projection.out` objects. They can be loaded from the disk with `get_predictions` or represented through `BIOMOD.projection.out` plot method.
- `get_predictions` now return a proper `data.frame` (unless projection on spatial data) with many additional information available. Old behavior can be reproduced by using `get_predictions(x, model.as.col = TRUE)`.
- `get_evaluations` now return a cleaner `data.frame` with more consistent information available.

##### Minor Changes

- Simplified maxent model names: ‘MAXENT.Phillips’ -> ‘MAXENT’ (based on `maxent.jar`); ‘MAXENT.Phillips.2’ -> ‘MAXNET’ (based on `maxnet` package).
- `BIOMOD_FormatingData` now gives warning when several input data points are located in the same raster cells
- Added options `filter.raster` in `BIOMOD_FormatingData` to filter data points so that none are located in the same raster cells.
- `BIOMOD_EnsembleModeling` now have an argument `em.algo` to select the ensemble algorithm to be computed. Separate arguments are now deprecated (`prob.mean`, `prob.median`, `prob.cv`, `prob.ci`, `committee.averaging`, `prob.mean.weight`). Building all possible ensemble models can now be done with `em.algo = c('EMmean','EMmedian','EMcv','EMci','EMca','EMwmean')`.
- Some possible values for `em.by` have slightly changed: ‘PA_dataset’ -> ‘PA’, ‘PA_dataset+repet’ -> ‘PA+run’ and ‘PA_dataset+algo’ -> ‘PA+algo’
- Added an appropriate message when all models fail for `BIOMOD_Modeling` and `BIOMOD_EnsembleModeling`.

##### Bugfix

- Fixed `MAXENT.Phillips.2` and single variable models.
- Fixed ensemble models when several filtering metrics were asked and some combination of ensemble/metrics had no models
- Bugfix for projection for ensemble models to ensure that the proper set of models was selected
- Bugfix for `BIOMOD_CrossValidation` for block-stratified sampling
- Bugfix for `BIOMOD_CrossValidation` for pseudo-absences

##### Internal Changes

- Array have disappeared from most internal functions
- Removed `rasterVis` from `Suggests`
- Added `tidyterra` and `ggtext` to `Suggests`
- Added checks to `get_evaluation` when models have no evaluations.

### 2022

#### 4.2-1 Bugfix patch

##### Major Changes

- Package `sp` is back into `Imports` due to the need to use `sp::read.asciigrid`
- Added control for `terra` version number (>= 1.6-33) as `terra` 1.6-41 was released on CRAN.
- With `do.stack = TRUE`, only stacked projection are now saved to the disk.

##### Minor Changes

- Added `initial_heap_size` and `max_heap_size` in `MAXENT.Phillips` modeling options
- Improved projection efficiency for raster with `MAXENT.Phillips`.

##### Bugfix

- Fixed `MAXENT.Phillips` predict method for large dataset (require `sp::read.asciigrid`).
- Fixed ensemble models using a single PA dataset with `em.by = 'all'` or `'algo'`.
- Models using repetition dataset cannot be merged anymore with models using Full dataset in `BIOMOD_EnsembleModeling`.
- Fixed error in `BIOMOD_EnsembleForecasting` when a single evaluation metric was available and binary/filtered transformation were asked for.
- Bugfix for plot method for `BIOMOD.formated.data.PA` object.
- Fixed `MAXENT.Phillips` for Windows.
- Fixed using `do.stack = FALSE` with `BIOMOD_Projection`.
- Fixed `EMcv` ensemble modeling for `data.frame` by removing dependency to `raster::cv`.
- Fixed `free` method with `PackedSpatRaster`
- Fixed `BIOMOD_FormatingData` in case where no coordinates are given

##### Internal

- Updated github workflow : removed obsolete ubuntu 18.04 ; added test on r-devel ; added cache for R packages.
- Updated `MAXENT.Phillips` `predict2` method for `SpatRaster` so that it saves environmental data as `.asc` and do not use the `data.frame` method.
- Fixed some automatic boolean conversion
- Cleaned up `BIOMOD.formated.data@data.mask` slot. `data.mask` can now be safely saved and re-opened ; `data.mask` can now store a different extent for evaluation dataset

#### 4.2-0 Terra Update

##### Major Changes

- Package now rely only on `terra` (`> 1.6.33`) and do not automatically import `raster` and `sp`.
- Moved `raster` and `sp` package into `SUGGESTS` rather than `DEPENDS`.
- `raster` and `sp` input data type are still supported.
- Package dataset now are now documented and loaded with `data()` .

##### Minor Changes

- `bm_BinaryTransformation` now always returns `0`/`1` and never `TRUE`/`FALSE`
- Added a check to `bm_PlotResponseCurves` for `new.env` possible data types.
- `BIOMOD_Projection` and `BIOMOD_EnsembleForecasting` now properly support matrix as `new.env`
- `get_prediction` on `biomod.projection.out` generated from `BIOMOD_Projection` based on `SpatRaster` with arg `as.data.frame = TRUE` are now possible.
- `bm_BinaryTransformation` now return same type of object as its input
- Improved communication for `BIOMOD_RangeSize`, indicating how comparison are done depending on the number of models in current vs future.
- Added argument check for `BIOMOD_CrossValidation`

##### Bugfix

- MAXENT.Phillips models can now properly fail
- bugfix for `bm_BinaryTransformation` with `data.frame`/`matrix` and `do.filtering = TRUE`
- Removed obsolete warning about CTA and categorical variables when using raster
- `bm_PlotResponseCurves` now work with factors in univariate representation
- `bm_PlotResponseCurves` properly handles `SpatRaster` and `Raster` as `new.env`
- Bugfix for predictions with `MAXENT.Phillips` and a single environmental variable
- Bugfix for `BIOMOD_EnsembleForecasting` so that it properly accounts for `new.env.xy` when projecting on `matrix` or `data.frame`.
- `BIOMOD_EnsembleModeling` now works when called for a single ensemble model
- Improved argument check for `BIOMOD_RangeSize`. Comparisons with non-binary values throw errors.
- bugfix for `BIOMOD_RangeSize` and data.frame method
- `BIOMOD_RangeSize` `data.frame` method now handles 1 current vs n future projection
- bugfix for `BIOMOD_PresenceOnly` that can now work when evaluation data are provided
- bugfix for `BIOMOD_PresenceOnly` that can now work when only the EM have been provided
- expanded support for `BIOMOD_PresenceOnly` to `SpatRaster` and `SpatVector`.
- `build_clamping_mask` now support categorical variables
- fixed ensemble model EMcv based on a single environmental variable

##### Internal Changes

- New internal function `.categorical2numeric` to transform categorical variables into numeric within a `data.frame`.
- New internal function `.get_categorical_names` to retrieve categorical variable names from a `data.frame`.
- Split `load_stored_object` method into a method for `BIOMOD.stored.SpatRaster` and a method for all other `BIOMOD.stored.data`.
- `BIOMOD.stored.SpatRaster` stores `PackedSpatraster` and not `SpatRaster`.
- New internal function `.CompteurSp` based on old function CompteurSp that was defined within a function.
- Removed obsolete function `check_data_range()`.

#### 4.1-3

##### Bugfix

- Ensemble models that fails (e.g. EMcv with only one models) will not crash the full ensemble run. Instead a warning is generally displayed at the beginning and the resulting object will list failed models.
- Fixed CTA raster prediction for categorical variables.
- Fixed binary transformation in `BIOMOD_EnsembleForecasting`.

#### Internal Changes

- New internal function .get_kept_models to generate list of models kept by ensemble modeling depending on `metric.select`.
- Improved checks for `BIOMOD_EnsembleModeling` to generate warnings when ensemble models are expected to be run with <= 1 models.
- Repaired support for cross-validation table given as `data.frame` instead of `matrix`.

#### 4.1-2 (2022-09-29)

##### Major changes

- `dir.name` can now be provided as project argument so that results may be saved in a custom folder.
- `predict` with `CTA` algorithm and categorical variables on raster is now possible.
- Changed evaluation for EM models merging PA datasets (`em.by = "algo"` or `em.by = "all"`) so that evaluation uses the union of PA data sets instead of the whole environmental space supplied.

##### Minor changes

- Individual EM models projected as raster are now saved with `INT2S` data format when `on_0_1000` is set to `TRUE`.
- Homogenize the use of load functions (use `get_[...]`, `load_stored_object` and `BIOMOD_LoadModels`, instead of `get(load(...))`) and the workflow within `get_[...]` functions (use `load_stored_object` and similar arguments such as `as.data.frame`, `full.name`, …).
- Adapting predict workflow to properly use S4 class.
- Homogenize `BIOMOD.ensemble.models.out` and `BIOMOD.models.out` objects
  - Add slots in `BIOMOD.ensemble.models.out` object for evaluations, variables importance and predictions.
  - Moved `.Models.save.objects` in `BIOMOD_modeling` to `.fill_BIOMOD.models.out` in `biomod2_internal.R`.
  - Save slots within `BIOMOD.ensemble.models.out` and use `load_stored_object` to directly get them within `get_[...]` functions.

##### Bug Fix

- Validation data can now be properly combined with Pseudo-Absence in `BIOMOD_FormatingData`, instead of throwing an error linked to `data.mask`.
- Argument `on_0_1000` can now be passed without errors so that projection may either be on a range from 0 to 1 or from 0 to 1000. The latter option being more effective memory-wise.
- Completed argument check for function `BIOMOD_EnsembleModeling` so that `em.by` can not be of `length > 1`.
- Corrected function `.get_models_assembling` so that it did not confound `MAXENT.Phillips2` with `MAXENT.Phillips` when grouping models by algorithm in `BIOMOD_EnsembleModeling`.
- `get_predictions` method for `BIOMOD.ensemble.models.out` now accepts an `evaluation` arg. Evaluation values, variables’ importance and Calibration/Evaluation predictions for ensemble models are now properly saved by `BIOMOD_EnsembleModeling()`.
- Evaluation metrics are no longer calculated for models `prob.ci.inf` et `prob.ci.sup`.
- Package now properly pass R CMD check.
- `BIOMOD_PresenceOnly` now properly manage `NA`.
- Corrected `bm_PlotResponseCurves` to only plot `show.variables`.
- `get_predictions.BIOMOD.projection.out` now properly works when asked for a subset of model.

##### Miscellaneous

- Using models with a single predictor requires updating `gbm` package to its development version at rpatin/gbm can be used. (see issue https://github.com/biomodhub/biomod2/issues/102)

#### 4.1-1 (2022-08-30)

- add `do.progress` parameter (to render or not progress bar) and `dir.name` parameter in `BIOMOD_FormatingData` and `biomod2` objects (Mathieu B. request)
- fix `BIOMOD_PresenceOnly` function by removing `ecospat` dependency

#### 4.1 (2022-07-12)

- fix bugs following major release 4.0

#### 4.0 (2022-03-01)

- MAJOR RELEASE
- clean all functions, reorganize files, remove old / unused functions
- standardize function names and parameter names
- update `roxygen2` documentation for all functions, including examples
- create github website to host documentation, examples, vignettes, news

### 2021

#### 3.5-3 (2021-11-02)

- clean BIOMOD classes definitions and functions (`biomod2_classes` files)
- clean `BIOMOD_FormatingData` function
- clean `BIOMOD_ModelingOptions` function
- fix `BIOMOD_FormatingData` : test class condition only a first element (to deal with `matrix` / `array` objects)
- fix `BIOMOD_EnsembleForecasting` for `EMcv` model when only one single model was kept

#### 3.5-2 (2021-10-18)

- fix `BIOMOD_PresenceOnly` function (previously `BIOMOD_presenceonly`)
- fix `BIOMOD_CrossValidation` function (previously `BIOMOD_cv`)
- fix internal function to find `MinMax` values, when factor included : should get clamping mask to work

### 2018-2019

#### 3.3-20 (2019-03-05)

- Remove maxent Tsurukoa because not maintained anymore (required by CRAN team)

#### 3.3-18 (2018-07-04)

- fix the gbm multicore issue

#### 3.3-17 (2018-04-23)

- correct the single presence pseudo-absences generation bug (Matthias G.)

### 2016

#### 3.3-6 (2016-01-14)

- add `get_predictions` function for ensemble models

#### 3.3-5 (2016-01-04)

- MARS models are now computed throw `earth` package (was `mda` in previous versions)
- MARS now supports factorial explanatory variables
- MARS now supports `formula`

### 2015

#### 3.3-4 (2015-11-04)

- update `BIOMOD_tuning` function (Frank B.)

#### 3.3-3 (2015-10-27)

- force sampling of each level of factorial variables
- add `betamultiplier` parameter to tune MAXENT.Phillips (Frank B. request)

#### 3.3-00 (2015-10-05)

- MAJOR RELEASE
- optimize the memory consumption of projections and ensemble projections procedure
- add the possibility to run `MAXENT.Phillips` with proper background data
- classical version of `MAXENT` has been renamed `MAXENT.Phillips`
- add a new version of MAXENT `MAXENT.Tsuruoka`

#### 3.2-00 (2015-07-28)

- add 3 new functions in `biomod2` (Frank B. contribution)
- `BIOMOD_cv` to control models cross validation procedure
- `BIOMOD_presenceonly` to evaluate biomod models using boyce and mpa indices
- `BIOMOD_tuning` to automatically tune `BIOMOD_ModelingOptions` parameters

### 2014

#### 3.1-59 (2014-10-23)

- add model evaluation scores plotting function
- dependence to `ggplot2`

#### 3.1-53 (2014-08-06)

- new ensemble models names to be more coherent with formal models names

#### 3.1-44 (2014-05-20)

- possibility to use user defined function to influence the way models are weighted in weighted mean ensemble models (thanks to Frank B.)

#### 3.1-43 (2014-05-20)

- add of `as.data.frame` argument for `get_evaluations()` function to enable formal and ensemble models evaluation scores merging

#### 3.1-42 (2014-05-19)

- enable ensemble forecasting models selection (thanks to Robin E.)

### 2013

#### 3.1-17 (2013-10-23)

- add parameter to control amount of memory reserved for `MAXENT` calculations (via java) (thanks to Burke G.)
- optimization of memory consumption in models projections when `do.stack` argument is set to `FALSE`
- binary and filtering projections output re-activated

#### 3.1-1 (2013-09-04)

- limitation of package dependencies
- fairely definition of package namespace
- add functions to update `biomod2` objects from a version to the current one

#### 3.0.2 (2013-07-23)

- new functions to evaluate a-posteriori models quality
- remove weights for models scaling and set it `FALSE` by default

#### 3.0.0 (2013-07-01)

- MAJOR RELEASES
- ensemble models are now `biomod2` models objects (should be predicted, evaluated, and you can do variables importance) the same way than all formal `biomod2` models
- possibility to produce ensemble models response plot
- ensemble forecasting output is now a `biomod2_projection` object: should be plotted…
- ensemble forecasting is now doable without doing previous projections (even if it is still advised). Can work with raw explanatory variables
- getter and setter function have been renamed
- new `variable_importance` function
- …

#### 2.1.37 (2013-06-12)

- change (temporally?) gam default package from `mgcv` to `gam` to deal with memory (cache) over-consuming (thanks to Burke G.)
- update of `response.plot2` function (optimization + deal with factorial variables)

#### 2.1.32 (2013-05-30)

- weights for user defined pseudo-absences are now supported (thanks to Rui F.)
- deal with unknown factors predictions (thanks to Denis M.)

#### 2.1.13 (2013-03-06)

- Add `ProbDensFunc()` function to package to produce nice plots that show inter-models variability

#### 2.1.12 (2013-03-04)

- add `rasterVis` dependency for nicer `biomod2` plots
- `PA.dist.min` and `PA.dist.max` are now defined in meters when you work with unprojected rasters in disk pseudo absences selection

#### 2.1.9 (2013-02-28)

- possibility to indicate manually which data should be used for calibration (resp. for validation) of models within `BIOMOD_Modeling`

#### 2.1.9 (2013-02-27)

- one var modeling supported (thanks Anne O.)
- new options for response curves plotting (`col`, `lty`, `data_species`…)

#### 2.1.8 (2013-02-25)

- response plot supports now formal models

#### 2.1.0 (2013-02-21)

- MAJOR RELEASE
- CRAN SUBMISION
- add of a `modeling.id` arg (`BIOMOD_Modeling`) for prevent from no wanted models overwriting and facilitate models tests and comparisons (thanks Frank B.)
- change of `biomod2` dataset
- vignettes and help files update (thanks Sam P. & Signe N.)
- save link between modeling and projection objects
- add `pROC` package dependency
- add a modeling cleaner that remove modeling objects from both memory and hard drive: `RemoveProperly()`

#### 2.0.11 (2013-02-18)

- possibility to consider a user.defined pseudo absences selection (thanks to Signe N.)
- possibility to switch off stepwise glm selection (*thanks Frank B.)

#### 2.0.9 (2013-02-15)

- automatic save on hard drive of `BIOMOD_Projection` outputs

#### 2.0.8 (2013-02-14)

- `BIOMOD_LoadModels` supports multiple models input
- deal with `NA` in evaluation table issue (*thanks Frank B.)

#### 2.0.7 (2013-02-12)

- bug on weights corrected (thanks to Lugi M.)

#### 2.0.3 (2013-01-18)

- deal with `MAXENT` categorical variables and categorical raster input

#### 2.0.0 (2013-01-17)

- MAJOR RELEASE
- CRAN SUBMISION
- models built within `biomod2` are now defined as “biomod2 models objects” (own scaling models, own predict function, …)
- full paths are replaced by relative paths to favor portability
- harmonization of names of objects that are saved on hard drive (more coherence between functions)
- possibility to save projections directly in raster format (`.grd` or `.img`)

### Year 0

#### 1.x.x

- development phase