ca_array: Run ca() over a parameter array.

Description Usage Arguments Details Value Examples

Description

Run ca() over a parameter array.

Usage

1
2
3
ca_array(model, init, width = 50, height = width, parms = model$parms,
  save = FALSE, filename = "sim", directory = "", salt = 345678,
  stat_covers_length = 10, ...)

Arguments

model

A valid object of class 'ca_model'. Defaults to musselbed. Valid values are: musselbed, grazing.

init

A valid numerical vector of initial cover. Length must be equal to length(model$states).

width

An integer number. Defaults to 50 and is ignored if a landscape object is provided in init.

height

An integer number. Defaults to width if provided and is ignored if a landscape object is provided in init.

parms

A list of parameters with one or several parameters containing a vector of parameter values. Those will be combined full-factorially using expand.grid()

save

Logical. If TRUE, each individual run is saved to a file. They can be loaded into the current working environment using load("filename").

filename

A character vector specifying the root of the filename of the saved files, including a relative path. It will be extended by an individual iteration ID and the fileending ".Rd". Note: If running in parallel on a cluster, output files will be saved in the workers home directory!

salt

An integer number. Used as seed when generating seeds for each single simulation run. Those generated seeds are returned in the output of the function.

...

parameters handed over to function ca().

Details

The function is used to create gradients along one parameter value or an array of parameter values. It runs the simulation for each parameter value or combination of parameter values while making use of a parallel backend provided by foreach.

Make sure to adapt the type of parallel backend to your computer infrastructure (see package vignette of the foreach -package).

Value

Returns a dataframe with global and local cover for each state for each parameter value or combination of parameter values given in parms.

The function returns a dataframe with global and local cover for each state for each parameter value or combination of parameter values given in 'parms', as well as the seed used for the individual simulation run.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
  p <- list(
    r = 0.4, # recolonisation of empty sites dependent on local density
    d = seq(0,1,0.1), # wave disturbance 
    delta = 0.01, # intrinsic disturbance rate
    replicates = 1:2  # repeat the same parameter set twice
  ) 
  
# provides parallel backend
 library(foreach)
 library(doMC)

 registerDoMC(cores=7)
 
 musselgradient <- ca_array(musselbed, parms = p, init = c(0.6,0.2,0.2), t_max = 400, save = TRUE, file = "out/musselbed")
 
 registerDoSEQ()

 musselgradient
 plot(musselgradient[,"mean_cover.+"] ~ musselgradient$d, pch = 20)

## End(Not run)

fdschneider/caspr documentation built on May 16, 2019, 12:12 p.m.