build.data: Format encounter data for SPIM or regular SCR. Open SPIM to...

Description Usage Arguments Value Author(s) Examples

View source: R/build.data.R

Description

This function formats the input object into a data set in the necessary format to run the spatial partial ID model. You should number the nC complete identity individuals as 1:nC with individuals that had a both capture numbered 1:nB and any other complete identity individuals numbered (nB+1):nC. The function will format for closed or open population SPIM as well as closed and open population regular SCR.

Usage

1
2
build.data(input, K, X, IDknown = NA, buff = NA, vertices = NA,
  model = "2side", tf = NA)

Arguments

input

a data frame with columns ID, trap, occ, and type. Each capture event has its own row with individual ID, capture occasion, trap number, and capture type (B, L, or R) (for the SPIM model only)

K

the integer number of capture occasions

X

the J x 3 matrix of trap locations and number of cameras at each trap. columns are X, Y, #cams (1 or 2)

IDknown

the vector listing the complete indentity individuals, 1:nC. Leave blank or set to NA if no identities are complete. Not applicable for regular SCR.

buff

the distance to buffer the trapping array in the X and Y dimensions to produce the state space

vertices

a matrix of n_verts X 2 X and Y locations for the vertices of a polygon state space

model

a character indicating which model to construct the data for. Current options are "SCR" and "2side"

tf

a vector or matrix indicating trap operation. If not accounting for operation across occasions, tf is a 1 x J vector indicating the number of occasions each trap was operational. In this scenario, single or double camera stations are either on or off. If accounting for operation across occasions, tf is a J x K matrix with entries 2 if 2 cameras were operational, 1 if a single camera was operational, and 0 if no cameras were operational.

Value

A properly formatted data set.

Author(s)

Ben Augustine

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
## Not run: 
#SPIM trivial example
X=cbind(1:6,1:6,rep(2,6))
ID=c(1,1,2,4,5,3)
occ=c(1,2,1,4,2,1)
trap=c(1,2,3,3,2,1)
type=c("B","L","B","R","R","L")
input=data.frame(ID=ID,trap=trap,occ=occ,type=type)
data=build.data(input,X=X,K=5,IDknown=1:2,buff=2,model="2side")

#SPIM Less trivial example from hybrid camera trap study
data(singlecamInput)
singlecamInput$input
data=build.data(singlecamInput$input,X=singlecamInput$X,K=singlecamInput$K,IDknown=NA,buff=singlecamInput$buff,model="2side")
str(data)

#SPIM hybrid cameras with 2-D trap file and vertices
data(hybridcamInput)
vertices=rbind(c(1,1),c(1,10),c(10,10),c(10,1),c(1,1)) #must close vertices back to starting point
data=build.data(hybridcamInput$input,X=hybridcamInput$X,K=6,IDknown=1:12,buff=2,model="2side",
vertices=vertices,tf=hybridcamInput$tf)
str(data)

#SPIM 

#Regular SCR data
data(singlecamInput)
singlecamInput$input
data=build.data(singlecamInput$input,X=singlecamInput$X,K=singlecamInput$K,buff=singlecamInput$buff,model="SCR")
str(data)

## End(Not run)

benaug/SPIM documentation built on Jan. 23, 2022, 4:29 a.m.