bam_sim: bam_sim: Simulate dispersal dynamics using the set B of the...

View source: R/bam_sim.R

bam_simR Documentation

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

Description

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

Usage

bam_sim(
  sp1,
  sp2,
  set_M,
  initial_points,
  periods_toxic,
  periods_suitable,
  nsteps,
  progress_bar = TRUE
)

Arguments

sp1

Niche model of the focal species (the one that disperses).

sp2

Niche model of the species with whom sp1 interacts (currently no dispersal dynamics for this species).

set_M

A setM object cointaining the adjacency matrix for sp1. See adj_mat

initial_points

A sparse vector returned by the function occs2sparse

periods_toxic

Time periods that sps2 takes to develop defense mechanisms (i.e. toxic).

periods_suitable

This is the time that sp2 takes to become non-toxic

nsteps

Number of steps to run the simulation

progress_bar

Show progress bar

Examples

## Not run: 
ura <- raster::raster(system.file("extdata/urania_omph/urania_guanahacabibes.tif",
                                  package = "bam"))
omp <- raster::raster(system.file("extdata/urania_omph/omphalea_guanahacabibes.tif",
                                  package = "bam"))
msparse <- bam::model2sparse(ura)
init_coordsdf <- data.frame(x=-84.38751, y= 22.02932)
initial_points <- bam::occs2sparse(modelsparse = msparse,init_coordsdf)
set_M <- bam::adj_mat(modelsparse = msparse,ngbs = 1)
ura_sim <- bam::bam_sim(sp1=ura, sp2=omp, set_M=set_M,
                        initial_points=initial_points,
                        periods_toxic=3,
                        periods_suitable=3,
                        nsteps=40)
# Animation example
anp <-"C:/Users/l916o895/Dropbox/TeoriadeBAM/articulo_bam/ura_omp_sim.gif"
new_sim <- bam::sim2Animation(sdm_simul = ura_sim,
                              which_steps = 1:ura_sim@sim_steps,
                              fmt = "GIF",
                              filename = anp)

## End(Not run)

luismurao/bam documentation built on Nov. 28, 2022, 3:02 p.m.