Convert Data To Or From BUGS Format
Convert data between ‘capthist’ and BUGS input format.
read.DA(DAlist, detector = "polygonX", units = 1, session = 1, Y = "Y", xcoord = "U1", ycoord = "U2", xmin = "Xl", xmax = "Xu", ymin = "Yl", ymax = "Yu", buffer = "delta", verify = TRUE) write.DA(capthist, buffer, nzeros = 200, units = 1)
DAlist |
list containing data in BUGS format |
detector |
character value for detector type: ‘polygon’ or ‘polygonX’ |
units |
numeric for scaling output coordinates |
session |
numeric or character label used in output |
Y |
character, name of binary detection history matrix (animals x occasions) |
xcoord |
character, name of matrix of x-coordinates for each detection in |
ycoord |
character, name of matrix of y-coordinates for each detection in |
xmin |
character, name of coordinate of state space boundary |
xmax |
character, name of coordinate of state space boundary |
ymin |
character, name of coordinate of state space boundary |
ymax |
character, name of coordinate of state space boundary |
buffer |
see Details |
verify |
logical if TRUE then the resulting capthist object is
checked with |
capthist |
|
nzeros |
level of data augmentation (all-zero detection histories) |
Data for OpenBUGS or WinBUGS called from R using the package R2WinBUGS (Sturtz et al. 2005) take the form of an R list.
These functions are limited at present to binary data from a square
quadrat such as used by Royle and Young (2008). Marques et al. (2011)
provide an R function create.data()
for generating simulated
datasets of this sort (see sim.capthist
for equivalent
functionality).
When reading BUGS data –
The character values Y
, xcoord
, ycoord
,
xmin
etc. are used to locate the data within DAlist
,
allowing for variation in the input names.
The number of sampling occasions is taken from the number of columns
in Y
. Each value in Y
should be 0 or 1. Coordinates may
be missing
A numeric value for buffer
is the distance (in the original
units) by which the limits Xl, Xu etc. should be shrunk to give the
actual plot limits. If buffer
is character then a component of
DAlist
contains the required numeric value.
Coordinates in the output will be multiplied by the scalar
units
.
Augmentation rows corresponding to ‘all-zero’ detection histories in
Y
, xcoord
, and ycoord
are discarded.
When writing BUGS data –
Null (all-zero) detection histories are added to the matrix of
detection histories Y
, and missing (NA) rows are added to the
coordinate matrices xcoord
and ycoord
.
Coordinates in the output will be divided by the scalar
units
.
For read.DA
, an object of class ‘capthist’.
For write.DA
, a list with the components
Xl | left edge of state space |
Xu | right edge of state space |
Yl | bottom edge of state space |
Yu | top edge of state space |
delta | buffer between edge of state space and quadrat |
nind | number of animals observed |
nzeros | number of added all-zero detection histories |
T | number of sampling occasions |
Y | binary matrix of detection histories (dim = c(nind+nzeros, T)) |
U1 | matrix of x-coordinates, dimensioned as Y |
U2 | matrix of y-coordinates, dimensioned as Y |
U1 and U2 are ‘NA’ where animal was not detected.
Marques, T. A., Thomas, L. and Royle, J. A. (2011) A hierarchical model for spatial capture–recapture data: Comment. Ecology 92, 526–528.
Royle, J. A. and Young, K. V. (2008) A hierarchical model for spatial capture–recapture data. Ecology 89, 2281–2289.
Sturtz, S., Ligges, U. and Gelman, A. (2005) R2WinBUGS: a package for running WinBUGS from R. Journal of Statistical Software 12, 1–16.
write.DA (hornedlizardCH, buffer = 100, units = 100) ## In this example, the input uses Xl, Xu etc. ## for the limits of the plot itself, so buffer = 0. ## Input is in hundreds of metres. ## First, obtain the list lzdata olddir <- setwd (system.file("extdata", package="secr")) source ("lizarddata.R") setwd(olddir) str(lzdata) ## Now convert to capthist tempcapt <- read.DA(lzdata, Y = "H", xcoord = "X", ycoord = "Y", buffer = 0, units = 100) #summary(tempcapt) ## Not run: plot(tempcapt) secr.fit(tempcapt, trace = FALSE) ## etc. ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.