Learn R Programming

secrfunc (version 1.0.0)

hdotpolycpp: Net Detection Hazard for Polygon and Transect Detectors

Description

Compute spatially explicit net probability of detection for individual(s) at given coordinates. Used by secr::pdot().

Usage

hdotpolycpp(xy, traps, Tsk, markocc, cumk, detectfn, gsb, convex, dim, grain, ncores)

Value

Rcpp NumericVector with one hazard for each row in 'xy'.

Arguments

xy

2-column matrix of coordinates

traps

2-column matrix; coordinates of detector polygon vertices

Tsk

detector usage (numeric matrix detectors x occasions)

markocc

integer vector of marking occasion codes (1 = marking)

cumk

integer vector of start indices of vertices for each detector

detectfn

integer detector code (see secr)

gsb

numeric vector of real parameter values (lambda0, sigma)

convex

logical; if TRUE all detector polygons are convex (non-convex untested)

dim

integer; 1 = transect, 2 = polygon

grain

integer grain argument of RcppParallel::parallelFor

ncores

integer number of threads

Details

Uses 'integrate' function from RcppNumerical. Sighting occasions are ignored.

Examples

Run this code

set.seed(123)

# 50 random points
xy <- matrix(runif(100), ncol = 2) * 2 - 1

# centred unit polygon 
traps <- matrix(c(0,0,1,1,0,0,1,1,0,0), ncol = 2) - 0.5

Tsk <- matrix(1, nrow = 1, ncol = 5)
markocc <- rep(1,5)
cumk <- c(0,5,0)   # zero-terminated
detectfn <- 14   # hazard half-normal
gsb <- c(lambda0 = 0.2, sigma = 0.5)

h <- hdotpolycpp(xy, traps, Tsk, markocc, cumk, detectfn, gsb, 
    convex = TRUE, dim = 2, grain = 1, ncores = 2)

Run the code above in your browser using DataLab