as.transfun: create a transition function

Description Usage Arguments Details Examples

Description

A utility function to enable users to create bespoke transition functions (transfun objects) for use in transitions.

Usage

1
as.transfun(fun, param, type = c("probability", "rate", "dispersal"))

Arguments

fun

an R function describing the transition. This must take only one argument: landscape and return a numeric vector (see details).

param

a named list of the parameters of fun (see details).

type

what type of transition this function represents, a probability or a rate

Details

fun must take only one argument, landscape, an object of class landscape. landscape objects contain three elements which may be used in the function: population, a dataframe giving the number of individuals of each stage (columns) in each patch (rows); area; a numeric vector giving the area of each patch in square kilometres; and features, a dataframe containing miscellaneous features (columns) of each habitat patch (rows), such as measures of patch quality or environmental variables. See examples for an illustration of how to these objects. Parameters of the transfun should be passed to as.transfun as a named list. These can then be used in fun by accessing them from this list. Note that param isn't an argument to fun, instead it's modified directly in the function's envirnment (because reasons).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# a very simple (and unnecessary, see ?p) transfun
fun <- function(landscape) param$prob
prob <- as.transfun(fun, param = c(prob = 0.3), type = 'probability')

# a density-dependent probability
dd_fun <- function (landscape) {
    adult_density <- population(landscape, 'adult') / area(landscape)
    param$p * exp(- adult_density/param$range)
}

dd_prob <- as.transfun(dd_fun,
                       param = list(p = 0.8,
                                    range = 10),
                       type = 'probability')

pop documentation built on May 1, 2019, 10:16 p.m.

Related to as.transfun in pop...