adj_mat {bamm}  R Documentation 
Creates an adjacency matrix of an area of interest. This could be the accessible area (M) of a species or any geographic region of interest.
adj_mat(modelsparse, ngbs = 1, eigen_sys = FALSE, which_eigs = 1)
modelsparse 
A setA object returned by the function

ngbs 
Numeric. Number of neighbors (see details). 
eigen_sys 
Logical. If TRUE the eigen analyses of the adjacency matrix will be returned. 
which_eigs 
Numeric. Which eigen value and eigen vector will be returned. 
The model is a raster object of the area where the dispersal process will occur. The number of neighbors depends on the dispersal abilities of the species and the spatial resolution of the niche model; for example, a species's with big dispersal abilities will move throughout more than 1 km^2 per day, so the idea is to give an approximate number of moving neighbors (pixels) per unit of time. For more information about see adjacency matrices in the context of the theory of area of distribution (Soberon and OsorioOlvera, 2022).
Returns an object of class setM
with 7 slots.
The first contains the adjacency matrix. A n x n sparse matrix (n=number of
nonNA cells of the niche model) where connected cells are represented by 1.
The second slot has the adjacency list. It is a list of matrices with four
columns (FromRasCell from cell ID of the raster, to cell ID of the
raster, from nonNA cell, to nonNA cell). Other slots contain
information about initial coordinates where dispersal occurs
(initial_points), number of cells used to define the neighborhood (ngbs),
nonNA coordinates (coordinates), and a matrix of eigen vectors (eigen_vec).
Luis OsorioOlvera & Jorge SoberĂ³n
SoberĂ³n J, OsorioOlvera L (2022). “A Dynamic Theory of the Area of Distribution.” doi:10.48550/ARXIV.2212.06308, https://arxiv.org/abs/2212.06308..
x_coord < c(106.5699, 111.3737,113.9332,
110.8913, 106.4262, 106.5699)
y_coord < c(16.62661, 17.72373, 19.87618,
22.50763, 21.37728, 16.62661)
xy < cbind(x_coord, y_coord)
p < sp::Polygon(xy)
ps < sp::Polygons(list(p),1)
sps < sp::SpatialPolygons(list(ps))
mx_grid < bamm::shape2Grid(sps,resolution = 0.25,ones = TRUE)
mx_sparse < bamm::model2sparse(model=mx_grid, threshold = 0.1)
adj_mx < bamm::adj_mat(modelsparse=mx_sparse,
ngbs=1,eigen_sys=TRUE,which_eigs=1)
print(adj_mx)
mx_grid_eigen < mx_grid
mx_grid_eigen[mx_sparse@cellIDs] < adj_mx@eigen_vec
raster::plot(mx_grid_eigen)