fxi | R Documentation |

Display contours of the probability density function for the estimated
location of one or more range centres, compute values for
particular points X, or compute mode of pdf. The pdf is given by
`f(X_j|\omega_i) = \mbox{Pr}(\omega_i|X_j)\pi(X_j)`

, where `\pi(X)`

is the probability density
of range centres across the mask (Borchers and Efford 2008).

```
fxi.contour (object, i = 1, sessnum = 1, border = 100, nx = 64,
levels = NULL, p = seq(0.1,0.9,0.1), plt = TRUE, add = FALSE,
fitmode = FALSE, plotmode = FALSE, fill = NULL,
output = c('list','sf','SPDF'), ncores = NULL, ...)
fxi.secr(object, i = NULL, sessnum = 1, X = NULL, ncores = NULL)
fxi.mode(object, i = 1, sessnum = 1, start = NULL, ncores = NULL, ...)
```

`object` |
a fitted secr model |

`i` |
integer or character vector of individuals (defaults to all in fxi.secr), or a single individual as input to fxi.mode |

`sessnum` |
session number if |

`border` |
width of blank margin around the outermost detectors |

`nx` |
dimension of interpolation grid in x-direction |

`levels` |
numeric vector of confidence levels for Pr(X|wi) |

`p` |
numeric vector of contour levels as probabilities |

`plt` |
logical to plot contours |

`add` |
logical to add contour(s) to an existing plot |

`fitmode` |
logical to refine estimate of mode of each pdf |

`plotmode` |
logical to plot mode of each pdf |

`X` |
2-column matrix of x- and y- coordinates (defaults to mask) |

`fill` |
vector of colours to fill contours (optional) |

`output` |
character; format of output (list, sf or SpatialPolygonsDataFrame) |

`ncores` |
integer number of threadss to be used for parallel processing |

`start` |
vector of x-y coordinates for maximization |

`...` |
additional arguments passed to |

`fxi.contour`

computes contours of probability density for one
or more detection histories. Increase `nx`

for smoother
contours. If `levels`

is not set, contour levels are set
to approximate the confidence levels in `p`

.

`fxi.secr`

computes the probability density for one or more
detection histories; `X`

may contain coordinates for one or
several points; a dataframe or vector (x then y) will be coerced to a
matrix.

`fxi.mode`

attempts to find the x- and y-coordinates
corresponding to the maximum of the pdf for a single detection history
(i.e. `i`

is of length 1). `fxi.mode`

calls
`nlm`

.

`fxi.contour`

with `fitmode = TRUE`

calls `fxi.mode`

for each individual. Otherwise, the reported mode is an approximation
(mean of coordinates of highest contour).

If `i`

is character it will be matched to row names of
object$capthist (restricted to the relevant session in the case of a
multi-session fit); otherwise it will be interpreted as a row number.

Values of the pdf are normalised by dividing by the
integral of `\mbox{Pr}(\omega_i|X)\pi(X)`

over the habitat mask in `object`

. (May differ in secr 4.0).

Setting `ncores = NULL`

uses the existing value from the environment variable
RCPP_PARALLEL_NUM_THREADS (see `setNumThreads`

).

If `start`

is not provided to `fit.mode`

then (from 2.9.4) the weighted mean of
all detector sites is used (see Warning below).

The ... argument gives additional control over a contour plot; for
example, set `drawlabels = FALSE`

to suppress contour labels.

`fxi.contour`

(output = 'list') –

Coordinates of the plotted contours are returned as a list with one component per polygon. The list is returned invisibly if plt = TRUE.

An additional component ‘mode’ reports the x-y coordinates of the highest point of each pdf (see Details).

`fxi.contour`

(output = 'SPDF') –

Contours are returned as a SpatialPolygonsDataFrame (see package sp) with one component per animal. The attributes dataframe has two columns, the x- and y-coordinates of the mode. The SpatialPolygonsDataFrame is returned invisibly if plt = TRUE.

`fxi.contour`

(output = 'sf') – simple features 'sf' object, as for SPDF.

`fxi.secr`

–

Vector of probability densities

`fxi.mode`

–

List with components ‘x’ and ‘y’

`fxi.mode`

may fail to find the true mode unless a good starting
point is provided. Note that the distribution may have multiple modes and
only one is reported. The default value of `start`

before secr 2.9.4
was the first detected location of the animal.

From secr 2.8.3, these functions work with both homogeneous
and inhomogeneous Poisson density models, and `fxi.secr`

accepts
vector-valued `i`

.

See `fx.total`

for a surface summed across individuals.

Borchers, D. L. and Efford, M. G. (2008) Spatially explicit maximum
likelihood methods for capture–recapture studies. *Biometrics*
**64**, 377–385.

`pdot.contour`

, `contour`

, `fx.total`

```
## Not run:
fxi.secr(secrdemo.0, i = 1, X = c(365,605))
## contour first 5 detection histories
plot(secrdemo.0$capthist)
fxi.contour (secrdemo.0, i = 1:5, add = TRUE,
plotmode = TRUE, drawlabels = FALSE)
## extract modes only
## these are more reliable than those from fit.mode called directly as
## they use a contour-based approximation for the starting point
fxiout <- fxi.contour (secrdemo.0, i = 1:5, plt = FALSE, fitmode = TRUE)
t(sapply(fxiout, "[[", "mode"))
## using fill colours
## lty = 0 suppresses contour lines
## nx = 256 ensures smooth outline
plot(traps(captdata))
fxi.contour(secrdemo.0, i = 1:5, add = TRUE, p = c(0.5,0.95), drawlabels
= FALSE, nx = 256, fill = topo.colors(4), lty = 0)
## output as SpatialPolygonsDataFrame
spdf <- fxi.contour(secrdemo.0, i = 1:3, plt = FALSE, p = c(0.5,0.95),
nx = 256, output = 'SPDF', fitmode = TRUE)
## output as simple features
sf <- fxi.contour(secrdemo.0, i = 1:3, plt = FALSE, p = c(0.5,0.95),
nx = 256, output = 'sf', fitmode = TRUE)
## save as ESRI shapefile test.shp etc.
## replace tempdir() with your own folder name
library(rgdal)
writeOGR(spdf, dsn = tempdir(), layer = 'test', driver="ESRI Shapefile")
## or
library(sf)
st_write(sf, 'testsf.shp')
## plot contours and modes
plot(spdf)
points(data.frame(spdf))
## End(Not run)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.