make.marking: Capture History for Telemetry-calibrated Cue Counts

make.markingR Documentation

Capture History for Telemetry-calibrated Cue Counts

Description

Build in one step a capthist object for telemetry type 'marking' (telemetry-calibrated cue counts; see section 'Telemetry-calibrated cue counts') from the detections and telemetry of collared animals and the sightings of animals that are not individually identified. The function may be used for single-session or multi-session data, and allows a session in which no animal was collared.

Usage


make.marking(traps, detections = NULL, telemetry = NULL, marked = NULL,
    Tu = NULL, Tm = NULL, noccasions = NULL, verify = TRUE, ...)

Arguments

traps

traps object for the cameras, without a telemetry detector, with usage (K x S) if effort varies; or, for a multi-session capthist, a named list of traps objects (class c("traps", "list")) one per session. The detector type is taken from traps: "count", or "proximity" (see Details).

detections

data frame of the detections of collared animals at cameras, in the format of the captures argument of make.capthist with fmt = "trapID": columns Session, ID, Occasion, Detector (a row name of traps), with one row for each detection (repeat the row for each further count). Column names are ignored. Further columns (5 onwards) are individual covariates, taken from the first row of each animal (as in make.capthist); other covariates may be added later with covariates<- (see Details). A row with Occasion 0 (no detection) is ignored. Every animal must also have telemetry fixes. NULL if no collared animal was detected.

telemetry

telemetry fixes: a data frame with columns ID, x, y (and Session for several sessions; a column Occ is ignored); the output of read.telemetry; or a list of such data frames, one per session. May be NULL, or have no fixes for a session, in which case that session has no collared animals.

marked

matrix of the proportion of each sighting occasion that each collared animal was detectable (collar active), with one row per collared animal (row names are IDs) and S columns; a list of matrices for several sessions (NULL allowed). If NULL all collars are assumed active throughout (see marked).

Tu, Tm

sightings of unmarked animals (Tu) and of marked animals that were not identified (Tm) as counts for each detector and occasion (K x S); see Details.

noccasions

integer number of sighting occasions S; needed only if traps has no usage attribute and Tu is not a matrix.

verify

logical; if TRUE the result is checked with verify.

...

other arguments passed to read.table when reading files of sightings.

Details

The usual route to a capthist for telemetry type 'marking' is a sequence of functions: make.capthist for the detections of collared animals, read.telemetry, addTelemetry with type = "marking", marked<-, addSightings and covariates<-. make.marking combines these steps and produces an object of the same form: the cameras are detectors 1..K, followed by a notional telemetry detector (a copy of the first camera) that is used on one additional occasion that pools all fixes; markocc is 0 for the S sighting occasions and 1 for the telemetry occasion; the usage matrix is (K + 1) x (S + 1); the attribute telemetryxy holds the fixes of each collared animal; and there is one row for every collared animal (every animal with fixes), all-zero if it was never detected at a camera.

Unlike the sequence, which returns the detections unchanged when there is no telemetry, make.marking builds a complete object for a session in which no animal was collared (no fixes). This is needed for a multi-session analysis in which detection parameters are shared among sessions and density is estimated for each, including sessions without collars (D ~ session). At least one session must have a collared animal.

Sessions. For several sessions traps must be a named list; the names are the session names, and the Session values in detections (and in telemetry if it has a Session column) must match them. For one session the session name is the single value of Session in detections (otherwise in telemetry, otherwise "1"). A data frame for several sessions may be replaced by a list with one component per session.

Sightings. Tu and Tm may be given as

  • a data frame, or the name of a text file (read with read.table and the ... arguments), whose first column is a session label and whose other columns are the occasions, with K rows (one per detector, in the order of traps) for each session stacked one above another (the format of addSightings). Sessions are taken in order of first appearance, not alphabetical order. If the labels equal the session names they are matched by name; otherwise they are matched by position, with a message.

  • a matrix (single session only)

  • a list with one component per session, each NULL, a matrix, or the name of a file whose first column is dropped

and the dimensions are checked against traps and its usage. Uncertain sightings (attribute Tn) are not accepted because no sighting model uses them.

Detector types. Detectors are "count" (expected count is a hazard; the model fitted by secr.fit) or "proximity" (binary detection). A binary model for telemetry-calibrated cue counts is not yet available in secr, and secr.fit stops if given proximity detectors with telemetry type 'marking'; a message is given when proximity detectors are specified. With proximity detectors repeated detections of an animal at a detector on one occasion are set to 1, with a warning. With "count" detectors a warning is given if every count in Tu is 0 or 1, as that may indicate presence/absence data for which the count model is not appropriate.

Animals are in sorted order of ID, as from read.telemetry, and row names are the IDs (addTelemetry pads IDs to a common width). Individual covariates from detections are matched to animals by ID and have the IDs as row names. Covariates held in a separate table are added afterwards, in the row order of the capthist, e.g. for one session covariates(ch) <- tab[match(rownames(ch), tab$ID), "Sex", drop = FALSE].

Value

A capthist object, or for several sessions a multi-session capthist, with telemetry type 'marking' and, if specified, attributes Tu, Tm (see addSightings), marked and individual covariates. Factor covariates have the same levels in all sessions (shareFactorLevels).

Telemetry-calibrated cue counts

Telemetry type ‘marking’ is used for telemetry-calibrated cue counts: cameras (or other ‘count’ detectors) detect all animals, but identify only animals wearing radio-collars (the ‘marked’ animals). The collared animals also provide telemetry fixes. The identified sightings and fixes of the collared animals (detections, telemetry) are used to estimate the detection parameters, and the counts of sightings of animals that were not identified as collared (Tu, and optionally Tm for collared animals that were seen but not identified) then give density.

Cues of collared animals recorded in Tm or as identified sightings are not counted again as unmarked cues; this is the principal difference from a model that treats the sightings of unmarked animals independently of those of marked animals. The probability that a sighting of a collared animal is identified (parameter pID, ‘q’) is estimated only if Tm is present.

A collar may not function throughout the survey. Use marked (see also marked) to specify when each animal could be recognised as marked (default is all occasions). Collared animals that were never detected contribute information only through their fixes and exposure.

The model is fitted by secr.fit with detectfn = "HHN" (or ‘HEX’). The activity centres of collared animals are integrated by summing over the mask or, usually faster, by Gauss-Hermite quadrature around the mean of the fixes (details = list(telemetryint = "GH"); see details). Density is estimated from the total sightings of unmarked animals after allowing for the collared animals' own sightings, so collars need not be deployed in proportion to density, but the collared animals should be representative of the population in their detectability (absolute density is biased low if collars favour animals that are individually more detectable). A density model such as D ~ x is possible if the mask has covariate x; coefficients are then estimated from the spatial pattern of unmarked sightings, and derived reports D as a cue-weighted density (the mean of D(x) over the mask weighted by the expected number of cues from an animal centred at x) that is better determined than the mean density over the mask. A mask covariate named ‘marking’ gives a non-uniform prior for the activity centres of collared animals (default uniform).

With CL = TRUE the likelihood is conditional on the collared animals: it uses their identified sightings, their telemetry and, if present, Tm. The unmarked sightings Tu contribute only through their spatial pattern across detectors, and only when there is a (relative) density model such as D ~ x; the density level is not estimated. The detection parameters (including pID) and the density coefficients are those of the full likelihood, and the CL fit is a quick way to obtain them. Density requires the full likelihood (CL = FALSE); derived, derivedDcoef, derivedDsurface and region.N are not available for a CL fit of this type.

Sightings are overdispersed relative to the Poisson (the unmarked total is a sum over animals of correlated cues). The scale factor ‘chat’ is computed analytically from the fitted model by specifying details = list(chatmethod = "analytic"); secr.fit evaluates it at the estimates (a second maximisation starting from the first). An existing fit may be updated with secr.refit(fit, details = list(chatmethod = "analytic")). Simulation of chat (details$nsim) is not available for this telemetry type. See details.

Finite mixture models (e.g. model = list(sigma ~ h2, lambda0 ~ h2)) are supported when the class of every collared animal is known: the classes are given by a categorical individual covariate named in hcov, and an error is reported if any collared animal has an unknown class. The classes of the unmarked animals are unknown and are modelled as a latent mixture with population proportions pmix. By default pmix is estimated from the class composition of the collared animals, which assumes that collaring was independent of class. If that is doubtful (for example, sex-biased collaring) fix pmix at an external value with fixed = list(pmix = p), where for two classes p is the proportion in the second class. For three classes (h3) give the proportions in classes 2 and 3, or in all three classes.

A capthist with telemetry type ‘marking’ may also be assembled by the sequence of functions listed in Details; addTelemetry then sets the telemetry type, adds the telemetry occasion and detector, and sets markocc (0 for each sighting occasion and 1 for the telemetry occasion, e.g. c(0,0,0,0,0,1)) unless markocc has already been set.

See Also

addTelemetry, addSightings, make.capthist, read.telemetry, markocc, marked, secr.fit, verify

Examples


## cameras: 5 x 5 grid, 4 sighting occasions
tr <- make.grid(nx = 5, ny = 5, spacing = 100, detector = "count")
usage(tr) <- matrix(1, nrow(tr), 4)

## fixes for three collared animals (A, B, C)
set.seed(123)
tel <- data.frame(ID = rep(c("A","B","C"), each = 10), x = rnorm(30, 200, 40),
    y = rnorm(30, 200, 40))

## detections of two of them at cameras (Session, ID, Occasion, Detector)
det <- data.frame(Session = 1, ID = c("A","A","C"), Occasion = c(1,3,2),
    Detector = rownames(tr)[c(1,7,12)])

## sightings of unmarked animals (detectors x occasions)
Tu <- matrix(rpois(25*4, 0.5), 25, 4)

ch <- make.marking(tr, det, tel, Tu = Tu)
summary(ch)

## two sessions; no animal was collared in the second
trl <- list(year1 = tr, year2 = tr)
class(trl) <- c("traps", "list")
det$Session <- "year1"
tel$Session <- "year1"
Tu2 <- list(Tu, matrix(rpois(25*4, 0.5), 25, 4))
ch2 <- make.marking(trl, det, tel, Tu = Tu2)
sapply(ch2, nrow)   # number of collared animals in each session

## simulated cameras count all animals, but only collared animals are identified
set.seed(1)
tr  <- make.grid(nx = 9, ny = 9, spacing = 11, detector = "count")
msk <- make.mask(tr, buffer = 30, spacing = 5, type = "traprect")
pop <- sim.popn(D = 50, core = msk, buffer = 0)
collared <- 1:nrow(pop) %in% sample(nrow(pop), 15)
dp <- list(lambda0 = 1, sigma = 4)

## identified sightings of collared animals, and telemetry fixes
sightCH <- sim.capthist(tr, popn = subset(pop, collared), detectfn = "HHN",
    detectpar = dp, noccasions = 5, renumber = FALSE)
teCH <- sim.capthist(make.telemetry(), popn = subset(pop, collared),
    detectfn = "HHN", detectpar = dp, noccasions = 50, renumber = FALSE)

## counts at each detector and occasion of animals without collars (K x S matrix)
uCH <- sim.capthist(tr, popn = subset(pop, !collared), detectfn = "HHN",
    detectpar = dp, noccasions = 5, renumber = FALSE)
Tu <- t(apply(uCH, 2:3, sum))

## detections as a data frame (one row per detection), and fixes as a data frame
w <- which(sightCH > 0, arr.ind = TRUE)
w <- w[rep(seq_len(nrow(w)), sightCH[w]), , drop = FALSE]
det <- data.frame(Session = 1, ID = rownames(sightCH)[w[,1]], Occasion = w[,2],
    Detector = rownames(tr)[w[,3]])
fixes <- telemetryxy(teCH)
tel <- data.frame(ID = rep(names(fixes), sapply(fixes, nrow)),
    x = unlist(lapply(fixes, "[[", "x")), y = unlist(lapply(fixes, "[[", "y")))

## these traps have no usage attribute, so the number of occasions is needed
ch <- make.marking(tr, det, tel, Tu = Tu, noccasions = 5)
markocc(traps(ch))     # 5 sighting occasions + telemetry


fit <- secr.fit(ch, mask = msk, detectfn = "HHN", trace = FALSE,
    details = list(telemetryint = "GH"))
predict(fit)

## model-based overdispersion (chat) and cue-weighted density
## (or specify details = list(chatmethod = "analytic") in the first call)
fit2 <- secr.refit(fit, details = list(chatmethod = "analytic"), trace = FALSE)
predict(fit2)
derived(fit2)



secr documentation built on Nov. 25, 2026, 9:06 a.m.