build.data: Format "secr-like" data for use in mcmc.OpenSCR or...

Description Usage Arguments Author(s) Examples

View source: R/build.data.R

Description

Format "secr-like" data for use in mcmc.OpenSCR or mcmc.OpenSCR.sex

Usage

1
2
build.data(dataIn = NA, X = NA, K = NA, obstype = NA, buff = NA,
  vertices = NA, primary = NA, sex = NA, tf = NA)

Arguments

dataIn

a matrix with 4 or 5 columns. If observations are already summed over occasions (K index), the columns indicate the individual number, trap number, primary period number, and number of observations for that individual at that trap on that primary period. If the observations are not summed over occasion, the colums indicate the individual number, trap number, secondary occasion number, primary period number and number of observation for that individual at that trap on that secondary occasion on that primary period. All individuals, traps, secondary occasions, and primary periods should be numbered sequentially starting at 1.

X

a list with elements that consists of J[l] x 2 matrices housing the X and Y trap locations for each primary period, l. If the traps do not vary across primary periods, just repeat the same traps in each list element. If population was not observed in primary period l, enter NA instead of a matrix. The row numbers of J[l] correspond to the trap numbers in dataIn

K

a vector of integers indicating the number of secondary occasions within each primary period

obstype

a character indicating the observation model "bernoulli" or "poisson"

buff

an optional numeric specifying the buffer for the traps to produce the state space. It is applied to the minimum and maximum X and Y trap locations across primary periods, producing a square or rectangular state space.

vertices

an optional *list* of matrices with the X and Y coordinates of a polygonal state space with one polygon in each list element. If there is just one polygon, the list is of length 1. @param primary an optional vector of length t with entries 1 if data was recorded in that primary period and 0 if not. This allows population dynamics to occur at equal interval primary periods even if data was not recorded at each primary period. If not entered, the population is assumed to have been sampled in all primary periods.

sex

an vector of sexes for use in the sex-specific sampler. Each of the n individuals should have an entry with 1 indicating male, 2 female, and NA unknown.

tf

an optional list of vectors of length t containing the trap operation information. Each vector has one element for each trap and indicates how many occasions each trap was operational in that primary period.

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
## Not run: 
#simulate some data
t=3
N=50
p0=0.3
lam0=-log(1-p0)
sigma=1
phi=0.7
gamma=0.3
buff=2
X=list(expand.grid(4:11,4:11),expand.grid(4:11,4:11),expand.grid(4:11,4:11))
K=c(10,10,10)
M=125
obstype="bernoulli"
data=simOpenSCR(N=N,phi=phi,gamma=gamma,lam0=lam0,sigma=sigma,K=K,X=X,t=t,M=M,buff=buff,
              obstype=obstype,)
#Create "secr-like" input matrix
idx=which(data$y>0,arr.ind=TRUE)
dataIn=matrix(NA,nrow=nrow(idx),ncol=4)
for(i in 1:nrow(idx)){
  dataIn[i,]=c(idx[i,],data$y[idx[i,1],idx[i,2],idx[i,3]])
}
#Your input data should have this format if it is summed across secondary occasions
str(dataIn)
data.formatted=build.data(dataIn,X, K, obstype="bernoulli",buff=3)
str(data.formatted)
all(data.formatted$y==data$y)

## End(Not run)

benaug/OpenPopSCR documentation built on Feb. 3, 2022, 10:04 a.m.