Learn R Programming

secr (version 4.6.9)

smooths: Smooth Terms in SECR Models

Description

From version 2.9.0, the model formulae provided to secr.fit may include smooth terms as specified for the mgcv function `gam', with some restrictions. Smooth terms may be used for both density and detection parameters.

Arguments

Background

Regression splines are a very flexible way to represent non-linear responses in generalized additive models (e.g., mgcv, Wood 2006). Borchers and Kidney (2014) have shown how they may be used to model 2-dimensional trend in density in secrgam, an R package that extends secr. Their approach is to use mgcv to construct regression spline basis functions from mask x- and y-coordinates, and possibly additional mask covariates, and to pass these as covariates to secr. The idea of using mgcv to construct the basis functions is applied within secr from version 2.9.

Smooth semi-parametric responses are also useful for modelling variation in detection parameters such as g0 and sigma over time, or in response to individual or detector-level covariates, when (1) a linear or other parametric response is arbitrary or implausible, and (2) sampling spans a range of times or levels of the covariate(s).

For a concrete example, consider a population sampled monthly for a year (i.e., 12 `sessions'). If home range size varies seasonally then the parameter sigma may vary in a more-or-less sinusoidal fashion. A linear trend is obviously inadequate, and a quadratic is not much better. However, a sine curve is hard to fit (we would need to estimate its phase, amplitude, mean and spatial scale) and assumes the increase and decrease phases are equally steep. An extreme solution is to treat month as a factor and estimate a separate parameter for each level (month). A smooth (semi-parametric) curve may capture the main features of seasonal variation with fewer parameters.

Warning

This implementation of smooth models results in large fitted objects, on account of the need to store setup information from mgcv. It is also vulnerable to future changes in mgcv.

Expect that the implementation will change in later versions of secr, and that smooth models fitted in the this version will not necessarily be compatible with predict and predictDsurface in later versions.

Details

The specification of smooth terms is explained in formula.gam. Only a subset of options are relevant to `secr'. Penalized splines are not available. The smooth function may be `s' or `te'.

The `wiggliness' of the curve is controlled by the argument k, which in this implementation is set by the user. The argument `fx' should be set to TRUE.

See also the example in secr-densitysurfaces.pdf.

References

Borchers, D. L. and Kidney, D. (2014) Flexible density surface estimation for spatially explicit capture--recapture surveys. Technical Report, University of St Andrews.

Wood, S. N. (2006) Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC.

See Also

Examples

Run this code

if (FALSE) {

## smooth density surface
possum.model.sxy <- secr.fit(possumCH, mask = possummask,
    model = D ~ s(x,y, k = 6, fx = TRUE), trace = FALSE)
fittedsurface <- predictDsurface(possum.model.sxy)
par(mar = c(1,1,1,6))
plot(fittedsurface)
plot(fittedsurface, plottype = 'contour', add = TRUE)
par(mar = c(5,4,4,2) + 0.1)  ## reset to default

## Now try smooth on g0

## For the smooth we use 'Session' which is coded numerically (0:4)
## rather than the factor 'session' ('2005', '2006', '2007', '2008',
## '2009')

ovenbird.model.g0 <- secr.fit(ovenCH, mask = ovenmask,
    model = g0 ~ session, trace = FALSE)
ovenbird.model.sg0 <- secr.fit(ovenCH, mask = ovenmask,
    model = g0 ~ s(Session, k = 3, fx = TRUE), trace = FALSE)

AIC(ovenbird.model.g0, ovenbird.model.sg0)

## Or over occasions within a session...

fit.sT3 <- secr.fit(captdata, model = g0 ~ s(T, k = 3, fx = TRUE),
    trace = FALSE)
pred <- predict(fit.sT3, newdata = data.frame(T = 0:4))

plot(sapply(pred, '[', 'g0', 'estimate'))

}

Run the code above in your browser using DataLab