Learn R Programming

bamm

Authors: Luis Osorio-Olvera & Jorge Soberon

Overview

The bamm package is an R package designed to estimate dynamic models of species distributions using the concepts of the BAM scheme. It allows to operate on large matrices (tens of millions of cells) regarding to each element of the BAM, for example, the adjacency matrix (connectivity matrix), and the niche suitability matrices.

The dynamic model behind the package is the cellular automata

$$\mathbf{G}_j(t+1) =\mathbf{B}_j(t)\mathbf{A}_j(t) \mathbf{C}_j \mathbf{G}_j(t)$$

The main functions of the package are:

  • model2sparse: it is the basic function of the package, it converts

a binary niche model (in raster format) to sparse matrix model (object of class setA).

  • adj_mat: the function returns the sparse representation of the adjacency

matrix of a given raster (generally is the M area but can be any area) given a movement hypothesis. The user can ask the function to return the eigen-analysis of the matrix.

  • bam_clusters: function to estimate the connectivity of suitable areas

given an adjacency matrix. It returns three objects: a) an dynamic map (open-street map) of connected areas or clusters; b) the data.frame with coordinates the geographic cluster membership; c) a raster object of with cluster IDs.

  • csd_estimate:This function is used to estimate the CSD-plot. It gives

you an idea about the dispersal distance that a species needs to travel to fill its potential area of distribution.

  • occs2sparse: Converts occurrence data into a sparse matrix object.

This object is used to declare the initial conditions for modeling the invasion dynamics of a species.

  • sdm_sim: Simulate single species dispersal dynamics using the cellular

automaton of the area of distribution.

Installation

CRAN

install.packages("bamm")

GitHub

if (!require('devtools')) install.packages('devtools')
devtools::install_github('luismurao/bamm')
# If you want to build vignette, install pandoc before and then
devtools::install_github('luismurao/bamm',build_vignettes=TRUE)

Acknowledgements

We are grateful to our many colleagues in the University of Kansas Niche Modeling Group for many vivacious and useful discussions on the topics of the paper. LOO acknowledges partially supported by Programa de Apoyo a Proyectos de Investigación e Innovación Tecnológica PAPIIT-IA202824 and Consejo Nacional de Ciencia y Tecnología (CONACyT; postdoctoral fellowship number 740751; CVU: 368747). LOO and JS acknowledges Blitzi Soberon for moral support.

Copy Link

Version

Install

install.packages('bamm')

Monthly Downloads

213

Version

0.6.0

License

GPL (>= 3)

Maintainer

Luis Osorio-Olvera

Last Published

February 3rd, 2026

Functions in bamm (0.6.0)

leaflet-class

Class leaflet leaflet
models2pam

models2pam: Converts binary rasters to a PAM
model2sparse

model2sparse: Converts a niche model into a diagonal sparse matrix
null_dispersion_field_distribution

null_dispersion_field_distribution: Null distribution of the dispersion field
diversity_range-class

Class diversity_range
occs2sparse

occs2sparse: Converts occurrence data into a sparse matrix object
predict,bam-method

Predict method of the package bamm.
setM-class

Class for the M set of the bamm diagram
diversity_range_analysis

range_diversity_analysis: diversity analysis
setA-class

Class for the A (Abiotic) Set of BAM Diagram
sdm_sim

sdm_sim: Simulate single species dispersal dynamics using the BAM framework.
shape2Grid

shape2Grid: Function to create a grid given a spatial polygon
show,setA-method

Show information in setA class bamm.
permute_pam

permute_pam: Function to permute a Presence-Absence-Matrix.
pam2richness

pam2richness: Converts Presence Absence Matrix (pam object) to richness raster
sim2Raster

sim2Raster: Convert a BAM simulation object to RasterStack
pol2pam

Convert distribution polygons to a presence-absence matrix (PAM)
plot,diversity_range,ANY-method

Plot method for objects of class diversity_range bamm.
sim2Animation

sim2Animation: Animate BAM simulation object.
pam-class

Class pam Presence-Absence Matrix
pam2bioindex

pam2bioindex: PAM to biodiversity index
bam_ssim

bam_ssim: Simulate dispersal dynamics using the set B of the BAM framework.
bioindex-class

Class bioindex
bam_sim

bam_sim: Simulate dispersal dynamics using the set B of the BAM framework.
adj_mat

adj_mat: Function to compute the adjacency matrix of an area.
community_sim

community_bam: Community bamm
bam_clusters

bam_clusters: Function to estimate the connectivity of suitable areas
csd-class

Class csd
bam-class

Class bam digram
community_sim-class

Class community_sim digram
bioindex_sparse-class

Class bioindex_sparse
csd_estimate

csd_estimate: Estimate the connectivity suitability and dispersal plot
jaccard

jaccard: Estimates the Jaccard index for comparing two binary maps
eigen_bam

eigen_bam: Compute the Eigen system of two bam objects
csim2pam

csim2pam: Converts community simulation to a Presence Absence Matrix (PAM)
g_area-class

S4 Class Hierarchy for BAM (Biotic-Abiotic-Movement) Modeling