Skip to contents

Setting up and train models

Key functions for setting up species distribution models and adding information to them. Start with distribution() and see articles examples on how to build a model from there. Also includes functions to specify priors for a model.

distribution()
Create distribution modelling procedure
BARTPrior()
Create a tree-based split probability prior for BART
BARTPriors()
Helper function when multiple variables are supplied for a BART prior
BREGPrior()
Create a new spike and slab prior for Bayesian generalized linear models
BREGPriors()
Helper function when multiple variables are supplied for a BREG prior
GDBPrior()
Monotonic constrained priors for boosted regressions
GDBPriors()
Helper function when multiple variables are supplied for a GDB prior
GLMNETPrior()
Regression penalty priors for GLMNET
GLMNETPriors()
Helper function when multiple variables are supplied for a GLMNET prior
INLAPrior()
Create a new INLA prior
INLAPriors()
Helper function when multiple variables and types are supplied for INLA
STANPrior()
Create a new STAN prior
STANPriors()
Helper function when multiple variables and types are supplied for STAN
XGBPrior()
Create a new monotonic prior for boosted regressions
XGBPriors()
Helper function when multiple variables are supplied for XGBOOST
Prior-class Prior
Base Prior class
PriorList-class PriorList
List of Priors supplied to an class
print(<distribution>) print(<BiodiversityDistribution>) print(<BiodiversityDatasetCollection>) print(<BiodiversityDataset>) print(<PredictorDataset>) print(<DistributionModel>) print(<BiodiversityScenario>) print(<Prior>) print(<PriorList>) print(<Engine>) print(<Settings>) print(<Log>) print(<Id>) print(<Id>) print(<tbl_df>)
Print
summary(<distribution>) summary(<DistributionModel>) summary(<PredictorDataset>) summary(<BiodiversityScenario>) summary(<PriorList>) summary(<Settings>)
Summarises a trained model or predictor object
priors() priors()
Creates a new PriorList object
pseudoabs_settings()
Settings for specifying pseudo-absence points within the model background
train()
Train the model from a given engine

Add or modify data and parameters

Functions to add or modify data and parameters in a distribution object. These can be used to add or remove biodiversity, covariates and priors in various forms.

add_biodiversity_poipa()
Add biodiversity point dataset to a distribution object (presence-absence).
add_biodiversity_poipo()
Add biodiversity point dataset to a distribution object (presence-only)
add_biodiversity_polpa()
Add biodiversity polygon dataset to a distribution object (presence-absence)
add_biodiversity_polpo()
Add biodiversity polygon dataset to a distribution object (presence-only)
add_constraint()
Add a constraint to an existing scenario
add_constraint_MigClim()
Add constrains to the modelled distribution projection using the MigClim approach
add_constraint_adaptability()
Adds an adaptability constraint to a scenario object
add_constraint_boundary()
Adds a boundary constraint to a scenario object
add_constraint_connectivity()
Adds a connectivity constraint to a scenario object.
add_constraint_dispersal()
Add dispersal constraint to an existing scenario
add_constraint_minsize()
Adds a size constraint on a scenario
add_control_bias()
Add a control to a BiodiversityModel object to control biases
add_control_extrapolation()
Add a control to a BiodiversityModel object to control extrapolation
add_latent_spatial()
Add latent spatial effect to the model equation
add_log()
Adds a log file to distribution object
add_offset()
Specify a spatial explicit offset
add_offset_bias()
Specify a spatial explicit offset as bias
add_offset_elevation()
Specify elevational preferences as offset
add_offset_range()
Specify a expert-based species range as offset
add_predictor_elevationpref()
Create lower and upper limits for an elevational range and add them as separate predictors
add_predictor_range()
Add a range of a species as predictor to a distribution object
add_predictors()
Add predictors to a Biodiversity distribution object
add_predictors_globiom()
Add GLOBIOM-DownScaleR derived predictors to a Biodiversity distribution object
add_predictors_model()
Add predictors from a fitted model to a Biodiversity distribution object
add_priors()
Add priors to an existing distribution object
add_pseudoabsence()
Add pseudo-absence points to a point data set
set_priors(<BiodiversityDistribution>)
Add priors to an existing distribution object
set_priors()
Add priors to an existing distribution object
sel_predictors()
Select specific predictors from a distribution object
rm_biodiversity()
Remove specific BiodiversityDataset from a distribution object
rm_latent()
Function to remove a latent effect
rm_offset()
Function to remove an offset
rm_predictors()
Remove specific predictors from a distribution object
rm_priors()
Remove existing priors from an existing distribution object
get_data()
Small helper function to obtain predictions from an object
get_ngbvalue()
Function to extract nearest neighbour predictor values of provided points
get_priors()
Create priors from an existing distribution model
get_rastervalue()
Function to extract directly the raster value of provided points

Engines

Statistical models used for estimation of species distributions.

engine_bart()
Engine for use of Bayesian Additive Regression Trees (BART)
engine_breg()
Engine for Bayesian regularized regression models
engine_gdb()
Use of Gradient Descent Boosting for model estimation
engine_glm()
Engine for Generalized linear models (GLM)
engine_glmnet()
Engine for regularized regression models
engine_inla()
Use INLA as engine
engine_inlabru()
Use inlabru as engine
engine_stan()
Use Stan as engine
engine_xgboost()
Engine for extreme gradient boosting (XGBoost)

Create spatial-temporal projections

After a model has been trained, the functions in here can be used to create projections with scenario() objects. Constraints can be on such scenarios to limit extrapolations.

scenario()
Create a new scenario based on trained model parameters
project.BiodiversityScenario() project(<BiodiversityScenario>)
Project a fitted model to a new environment and covariates
simulate_population_steps()
Simulate population dynamics following the steps approach
add_constraint()
Add a constraint to an existing scenario
add_constraint_MigClim()
Add constrains to the modelled distribution projection using the MigClim approach
add_constraint_adaptability()
Adds an adaptability constraint to a scenario object
add_constraint_boundary()
Adds a boundary constraint to a scenario object
add_constraint_connectivity()
Adds a connectivity constraint to a scenario object.
add_constraint_dispersal()
Add dispersal constraint to an existing scenario
add_constraint_minsize()
Adds a size constraint on a scenario

Model summary and validation

Key functions to summarize, validate or extract information from trained models.

plot(<DistributionModel>) plot(<BiodiversityDatasetCollection>) plot(<PredictorDataset>) plot(<Engine>) plot(<BiodiversityScenario>)
Plot wrappers
print(<distribution>) print(<BiodiversityDistribution>) print(<BiodiversityDatasetCollection>) print(<BiodiversityDataset>) print(<PredictorDataset>) print(<DistributionModel>) print(<BiodiversityScenario>) print(<Prior>) print(<PriorList>) print(<Engine>) print(<Settings>) print(<Log>) print(<Id>) print(<Id>) print(<tbl_df>)
Print
summary(<distribution>) summary(<DistributionModel>) summary(<PredictorDataset>) summary(<BiodiversityScenario>) summary(<PriorList>) summary(<Settings>)
Summarises a trained model or predictor object
coef(<DistributionModel>)
Obtains the coefficients of a trained model
validate()
Validation of a fitted distribution object
similarity()
Calculate environmental similarity of reference datasets to predictors.
effects(<DistributionModel>)
Plot effects of trained model
partial() partial.DistributionModel()
Obtain partial effects of trained model
spartial() spartial.DistributionModel()
Obtain spatial partial effects of trained model
partial_density()
Visualize the density of the data over the environmental data
limiting()
Identify local limiting factor
threshold()
Threshold a continuous prediction to a categorical layer
ensemble()
Function to create an ensemble of multiple fitted models
ensemble_partial()
Function to create an ensemble of partial effects from multiple models
ensemble_spartial()
Function to create an ensemble of spartial effects from multiple models

Utility functions

These functions are used by engines or spatial processing in the package. Most of them are for internal use, but can be of use if input needs to be reformatted.

posterior_predict_stanfit()
Create a posterior prediction from a rstanfit object
alignRasters()
Align a SpatRaster object to another by harmonizing geometry and extend.
emptyraster()
Create an empty SpatRaster based on a template
get_ngbvalue()
Function to extract nearest neighbour predictor values of provided points
get_rastervalue()
Function to extract directly the raster value of provided points
predictor_transform()
Spatial adjustment of environmental predictors and raster stacks
predictor_derivate()
Create spatial derivative of raster stacks
predictor_filter()
Filter a set of correlated predictors to fewer ones
interpolate_gaps()
Approximate missing time steps between dates
run_stan()
Fit cmdstanr model and convert to rstan object
wrap_stanmodel()
Wrap a list with stan model code
sanitize_names()
Sanitize variable names
get_data()
Small helper function to obtain predictions from an object
stancode() stancode.DistributionModel()
Show the stan code from a trained model
write_model()
Save a model for later use
write_output()
Generic function to write spatial outputs
write_summary()
Generic function to write summary outputs from created models.
load_model()
Load a pre-computed model
formatGLOBIOM()
Function to format a prepared GLOBIOM netCDF file for use in Ibis.iSDM
mask.DistributionModel() mask.BiodiversityDatasetCollection() mask.PredictorDataset() mask.BiodiversityScenario()
Mask data with an external layer
myLog()
Custom messaging function for scripts
predictor_homogenize_na()
Homogenize NA values across a set of predictors.
thin_observations()
Functionality for geographic and environmental thinning
unwrap_model()
Unwrap a model for later use
wrap_model()
Wrap a model for later use

Class definitions and methods

These pages document the package’s internal data structures and functions for manipulating them—they contain information that is really only useful when adding new functionality to the package.

BiodiversityDataset-class BiodiversityDataset
BiodiversityDataset prototype description
BiodiversityDatasetCollection-class BiodiversityDatasetCollection
BiodiversityDatasetCollection super class description
BiodiversityDistribution-class BiodiversityDistribution
Biodiversity Distribution master class
BiodiversityScenario-class BiodiversityScenario
Class for a biodiversity scenario from a trained model
DistributionModel-class DistributionModel
Class for the trained Model object
Engine-class Engine
Engine class description
Prior-class Prior
Base Prior class
PriorList-class PriorList
List of Priors supplied to an class
Settings-class Settings
Prototype for model settings object
PredictorDataset-class PredictorDataset
PredictorDataset class description
Log-class Log
Log prototype.

Miscellaneous functions

Other functions only relevant for development

as.Id()
As Id
is.Id()
Check whether a provided object is truly of a specific type
check()
Check objects in the package for common errors or issues
bivplot()
Bivariate plot wrapper for distribution objects
ibis_dependencies()
Install ibis dependencies
ibis_future()
Options to set up ibis for parallel processing with future
ibis_options()
Print ibis options
is.Raster()
Tests if an input is a SpatRaster object.
is.Waiver()
Is the provided object of type waiver?
is.formula()
Check whether a formula is valid
is.stars()
Tests if an input is a stars object.
new_id()
Identifier
new_waiver()
Waiver
plot(<DistributionModel>) plot(<BiodiversityDatasetCollection>) plot(<PredictorDataset>) plot(<Engine>) plot(<BiodiversityScenario>)
Plot wrappers
print(<distribution>) print(<BiodiversityDistribution>) print(<BiodiversityDatasetCollection>) print(<BiodiversityDataset>) print(<PredictorDataset>) print(<DistributionModel>) print(<BiodiversityScenario>) print(<Prior>) print(<PriorList>) print(<Engine>) print(<Settings>) print(<Log>) print(<Id>) print(<Id>) print(<tbl_df>)
Print
run_stan()
Fit cmdstanr model and convert to rstan object
myLog()
Custom messaging function for scripts