Learn R Programming

secr (version 4.6.9)

utility: Utility Functions

Description

Minor functions.

Usage

getMeanSD(xy)
maskarea(mask, sessnum = 1)
masklength(mask, sessnum = 1)
edist(xy1, xy2)
nedist(xy1, xy2, mask, inf = Inf, ...)
rlnormCV(n, mean, cv)

Value

For getMeanSD, a dataframe with columns `x' and `y' and two rows, mean and SD.

For maskarea, the summed area of mask cells in hectares (ha).

For masklength, the summed length of mask cells in kilometers (km).

For edist and nedist, a matrix with dim = c(nrow(xy1), nrow(xy2)).

For rlnormCV a vector of random deviates.

Arguments

xy

2-column matrix or dataframe

xy1

2-column matrix or dataframe

xy2

2-column matrix or dataframe

mask

mask or linearmask object

sessnum

integer; for multi-session masks, the number of the session

inf

numeric value to use for +infinity

...

other arguments for transition

n

number of observations

mean

mean on natural scale

cv

coefficient of variation on natural scale

Details

getmeanSD is used by make.mask to standardize mask coordinates.

For masklength the input should be a linear mask from secrlinear.

edist computes the Euclidean distance between each point in xy1 and each point in xy2. (This duplicates the functionality of `rdist' in package fields).

nedist computes the non-Euclidean distance between each point in xy1 and each point in xy2, in two dimensions. The calculation uses gdistance (van Etten 2017; see also Csardi & Nepusz 2006): a transition layer is formed representing the connections between adjacent points in mask. By default, points within a 16-point neighbourhood are considered `adjacent'. Distances are obtained by Dijkstra's (1959) algorithm as least cost paths through the graph of all points in the mask.

nedist has some subtle options. If `mask' is missing then the transition layer will be formed from `xy2'. If `mask' has a covariate named `noneuc' then this will be used to weight distances. The ... argument of nedist allows the user to vary arguments of transition (defaults transitionFunction = mean and directions = 16). Be warned this can lead to unexpected results! Point pairs that are completely separated receive the distance +Inf unless a finite value is provided for the argument `inf'. See secr-noneuclidean.pdf for uses of nedist.

rlnormCV is a wrapper for rlnorm that computes its meanlog and sdlog arguments from the mean and CV on the natural scale:

\(\mbox{sdlog} = \sqrt{\log(\mbox{CV}^2 + 1)}\), and

\(\mbox{meanlog} = \log(\mbox{mean}) - \mbox{sdlog}^2/2\).

References

Dijkstra, E. W. (1959) A note on two problems in connexion with graphs. Numerische Mathematik, 1, 269--271.

Csardi, G. and Nepusz, T. (2006) The igraph software package for complex network research. InterJournal, 1695. https://igraph.org

van Etten, J. (2017) R package gdistance: Distances and routes on geographical grids. Journal of Statistical Software, 76(1), 1--21. tools:::Rd_expr_doi("10.18637/jss.v076.i13")

Examples

Run this code

getMeanSD(possummask)

Run the code above in your browser using DataLab