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(<ANY>,< numeric>,< numeric>,< character>,< numeric>,< logical>,< logical ANY>)
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_constrain_MigClim(<BiodiversityScenario>,< character>,< numeric>,< numeric>,< character>,< numeric>,< numeric>,< numeric>,< numeric>,< numeric>,< character>)
Add constrains to the modelled distribution projection through the MigClim approach
add_constraint(<BiodiversityScenario>,< character>)
Add a constraint to an existing scenario
add_constraint_adaptability(<BiodiversityScenario>,< character>,< character>,< numeric>,< numeric>)
Adds an adaptability constraint to a scenario object
add_constraint_boundary(<BiodiversityScenario>,< sf>,< character>) add_constraint_boundary(<BiodiversityScenario>,< ANY>,< character>)
Adds a boundary constraint to a scenario object
add_constraint_connectivity(<BiodiversityScenario>,< character>,< numeric>,< ANY>)
Adds a connectivity constraint to a scenario object.
add_constraint_dispersal(<BiodiversityScenario>,< character>,< numeric>)
Adds a dispersal constrain to a scenario object.
add_control_bias()
Add a specified variable that the model should control for
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_priors()
Add priors to an existing distribution object
add_pseudoabsence()
Add pseudo-absence points to a point data set
set_priors()
Add priors to an existing distribution object
sel_predictors()
Select specific predictors from a distribution object
rm_predictors()
Remove specific predictors from a distribution object
rm_priors()
Remove existing priors from an existing distribution 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_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.

Model summary and validation

Key functions to summarize, validate or extract information from trained 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.

explode_factorized_raster()
Split raster factor levels to stack
posterior_predict_stanfit()
Create a posterior prediction from a rstanfit object
alignRasters()
Align a Raster object to another by harmonizing geometry and extend.
emptyraster()
Create an empty RasterLayer 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
run_stan()
Fit cmdstanr model and convert to rstan object
wrap_stanmodel()
Wrap a list with stan model code
stancode(<DistributionModel>)
Show the stan code from a trained model
write_model(<ANY>,< character>,< logical>,< logical>)
Save a model for later use
write_output(<ANY>,< character>,< character>,< logical>) write_output(<BiodiversityScenario>,< character>,< character>,< logical>) write_output(<RasterLayer>,< character>,< character>,< logical>) write_output(<RasterStack>,< character>,< character>,< logical>) write_output(<data.frame>,< character>,< character>,< logical>) write_output(<stars>,< character>,< character>,< logical>)
Generic function to write spatial outputs
write_stanmodel()
Write a cmdstanr model output to a specific file
write_summary(<ANY>,< character>,< logical>,< logical>)
Generic function to write summary outputs from created models.
load_model(<character>,< logical>)
Load a pre-computed model
clamp_predictions()
Clamp a predictor matrix by given values
formatGLOBIOM()
Function to format a prepared GLOBIOM netCDF file for use in Ibis.iSDM
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

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 prototype description
BiodiversityDistribution-class BiodiversityDistribution
Biodiversity Distribution master class
BiodiversityScenario-class BiodiversityScenario
Prototype for a biodiversity scenario from a trained model
DistributionModel-class DistributionModel
Prototype for the trained Model object
Engine-class Engine
Engine prototype.
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 prototype description
Log-class Log
Log prototype.

Miscellaneous functions

Other functions only relevant for development