gfit: Fit an SECR model to survey data

Description Usage Arguments Details Author(s) See Also Examples

Description

Fit a Spatially Explicit Capture-Recapture (SECR) model to survey data collected from arrays of proximity detectors.

Usage

1
2
3
gfit(capthist, model = list(), mask = NULL, fixed = list(),
  model.options = list(), mask.options = list(),
  fitting.options = list(), start = NULL, trace = FALSE)

Arguments

capthist

gcapthist object (or a capthist object with proximity traps)

model

list of formulae for the model parameters (see Details)

mask

gmask object (if NULL a default mask is used)

fixed

list of fixed values for the model parameters

model.options

list of control options determining the type of model to be fitted (see Details)

mask.options

list of options for the default mask (see Details)

fitting.options

list of options controlling the fitting process (see Details)

start

numeric vector of starting values for the fitting algorithm

trace

if TRUE, information for each iteration of the fitting procedure is printed to the console

Details

Parameter estimates are obtained via numerical optimization using the nlm function.

model

Should contain a list of formulae for the following paramters:

D density (number of animals/groups per square kilometre)
g0 detection function intercept
sigma detection function scale (metres)
z detection function shape
bearings estimated bearings distribution scale
distances estimated distances distribution shape
pcall availability (proportion)

If no model is specified then intercept-only formulae are used.

Model formulae can be specified using any of the the available covrariates (see gibbonsecr-covariates for advice on model covariates).

Smooth terms from the mgcv package – including s, te and ti – can also be used. However, only the un-penalised components of the smooth terms are used (the design matrix is obtained from gam using fit = FALSE) and no smoothing penalties are estimated (i.e. models are fitted as un-penalised regression splines).

model.options

Should be a list of three elements, named detfunc, bearings and distances, with integer values. The table below shows the available settings (defaults in italics):

detfunc 0 = half normal 1 = hazard rate
bearings 0 = no model 1 = von Mises 2 = wrapped Cauchy
distances 0 = no model 1 = gamma 2 = lognormal

If any of the elements are left blank then the default values are used.

mask.options

Ignored unless the mask argument is NULL, in which case it should be a list of two elements named buffer and spacing giving the buffer and spacing to be used when constructing a default mask. If the mask and arguments are both NULL the should be a list of three elements, named detfunc,

fitting.options

Should be a list of the following elements:

hessian if TRUE, the estimated hessian matrix is returned (default = TRUE)
iterlim maximum number of fitting iterations (default = 1000)
LLonly if TRUE, then the log-likelihood using the starting values is returned (default = FALSE)
fit if FALSE, the arguments passed to nlm are returned (default = TRUE)

If any of the elements are left blank then the default values are used.

Author(s)

Darren Kidney darrenkidney@googlemail.com

See Also

plot.gsecr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
## Not run: 

library(ggplot2)
data(N.annamensis)

# default settings -------------------------------------------------------------

# - half normal detection function
# - von Mises bearings error distribution
# - no model for estimated distances
fit = gfit(
    capthist = N.annamensis.capthist,
    mask     = N.annamensis.mask
)
summary(fit)

# D ~ habitat ------------------------------------------------------------------

fit = gfit(
    capthist = N.annamensis.capthist,
    mask     = N.annamensis.mask,
    model    = list(D ~ habitat)
)
summary(fit)

ggplot() + coord_fixed() +
    geom_fit(fit, "densurf") +
    geom_capthist(fit$capthist, "array") +
    scale_fill_distiller(palette = "Spectral") +
    labs(x = "Longitude", y = "Latitude")

# predict density for each habitat
newdata = data.frame(habitat = c("primary", "secondary"))
predict(fit, submodels = "D", newdata = newdata)


# sigma ~ habitat ------------------------------------------------------------------

fit = gfit(
    capthist = N.annamensis.capthist,
    mask     = N.annamensis.mask,
    model    = list(sigma ~ habitat)
)
summary(fit)

newdata = data.frame(habitat = c("primary", "secondary"))

ggplot() +
    geom_fit(fit, "detfunc", newdata = newdata[1, , drop = FALSE], col = 2) +
    geom_fit(fit, "detfunc", newdata = newdata[2, , drop = FALSE], col = 4) +
    labs(x = "Radial distance (m)", y = "Detection probability")

ggplot() +
    geom_fit(fit, "detfunc", newdata = newdata[1, , drop = FALSE], col = 2) +
    geom_fit(fit, "detfunc", newdata = newdata[1, , drop = FALSE], fill = 2,
             ci = TRUE, method = "boot") +
    geom_fit(fit, "detfunc", newdata = newdata[2, , drop = FALSE], col = 4) +
    geom_fit(fit, "detfunc", newdata = newdata[2, , drop = FALSE], fill = 4,
             ci = TRUE, method = "boot") +
    labs(x = "Radial distance (m)", y = "Detection probability")

# predict density for each habitat
predict(fit, submodels = "sigma", newdata = newdata)


# D ~ s(x, y) ------------------------------------------------------------------

fit = gfit(
    capthist = N.annamensis.capthist,
    mask     = N.annamensis.mask,
    model    = list(D ~ s(x, y, k = 3))
)
summary(fit)

ggplot() + coord_fixed() +
    geom_fit(fit, "densurf") +
    geom_fit(fit, "densurf", contour = TRUE) +
    geom_capthist(fit$capthist, "array") +
    scale_fill_distiller(palette = "Spectral") +
    labs(x = "Longitude", y = "Latitude")

# predict density for each habitat
newdata = data.frame(habitat = c("primary", "secondary"))
predict(fit, submodels = "D", newdata = newdata)

## End(Not run)

dkidney/gibbonsecr documentation built on May 15, 2019, 9:11 a.m.