csim2pam {bamm}R Documentation

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

Description

Converts community simulation object into a Presence Absence Matrices (PAM) for a given simulation steps.

Usage

csim2pam(community_sim, which_steps)

Arguments

community_sim

An object of class community_bam.

which_steps

Steps in the simulation object to be converted into a PAM

Details

For details about the object community_sim see community_sim

Value

An object of class pam; it contains five slots. 1) pams: a list of sparse matrices with Presence-Absence information (PAMs). 2) which_steps: time steps corresponding to each PAM. 3) sp_names: a vector of species names. 4) the grid area used in the simulation. 5) Non NA cell (pixel) IDs.

Author(s)

Luis Osorio-Olvera & Jorge SoberĂ³n

References

SoberĂ³n J, Osorio-Olvera L (2022). “A Dynamic Theory of the Area of Distribution.” doi:10.48550/ARXIV.2212.06308, https://arxiv.org/abs/2212.06308..

Examples


lagos_path <- system.file("extdata/conejos",
                          package = "bamm")
enm_path <- list.files(lagos_path,
                       pattern = ".tif",
                       full.names = TRUE)[seq(1,10)]
en_models <- raster::stack(enm_path)
ngbs_vect <- sample(1:2,replace = TRUE,
                    size = raster::nlayers(en_models))
init_coords <- read.csv(file.path(lagos_path,
                                  "lagos_initit.csv"))[seq(1,10),]
nsteps <- 10
sdm_comm <- bamm::community_sim(en_models = en_models,
                               ngbs_vect = ngbs_vect,
                               init_coords = init_coords,
                               nsteps = nsteps,
                               threshold = 0.1)

pamt10 <- bamm::csim2pam(community_sim = sdm_comm ,
                        which_steps = 10)
pams <- bamm::csim2pam(community_sim = sdm_comm ,
                       which_steps = seq_len(10))
rich_pam <- bamm::pam2richness(pams,which_steps = c(1,5))
print(rich_pam)



[Package bamm version 0.4.3 Index]