sim.genCatSMR: Simulate data from the generalized categorical spatial mark...

Description Usage Arguments Value Author(s) Examples

View source: R/sim.genCatSMR.R

Description

This function simulates data from a generalized spatial mark resight survey for categorically marked populations. Capture histories from the marking and sighting process are produced. If there is only one categorical identity covariate with one value, the function simulates from typical generalized mark resight. Imperfect determination of marked status is controlled through "pMarkID" and imperfect individual identification of marked individuals is controlled through "pID". Telemetry data for marked indiviuals is added through "tlocs".

Usage

1
2
3
4
5
sim.genCatSMR(N = 50, lam0.mark = 0.25, lam0.sight = 0.25,
  sigma = 0.5, K1 = 10, K2 = 10, Korder = NA, X1 = X1, X2 = X2,
  buff = 3, obstype = "bernoulli", ncat = ncat, pIDcat = pIDcat,
  IDcovs = IDcovs, gamma = gamma, pMarkID = c(1, 1), tlocs = 0,
  pID = 1)

Arguments

N

abundance

lam0.mark

the detection function baseline detection rate for the marking process. Converted to p0, the baseline detection probability if the obstype="bernoulli".

lam0.sight

the detection function baseline detection rate for the sighting process. Converted to p0, the baseline detection probability if the obstype="bernoulli".

sigma

the detection function spatial scale parameter assumed to be the same for both capture processes. This could be relaxed.

K1

the number of marking occasions

K2

the number of sighting occasions

Korder

a character vector of length K1+K2 specifying the order of the marking and sighting occasions. Vector elements are either "M" or "S" arranged in the order the marking and sighting occasions occurred. See example below. Korder does not need to be an input if all sighting occasions occurred after the final marking occasion.

X1

a matrix with two columns for the X and Y trap locations of the marking process. J1 rows.

X2

a matrix with two columns for the X and Y trap locations of the sighting process. J2 rows.

buff

an integer indicating the distance to buffer the combined trapping array (X1 and X2), to create the state space

obstype

a vector of length two indicating the observation model, "bernoulli" or "poisson", for the marking and sighting process

ncat

an integer indicating the number of categorical identity covariates

pIDcat

a vector of length ncat containing the probability that the value of each categorical identity covariate is observed upon capture

IDcovs

a list of length ncat containing the values each categorical identity covariate can take. The length of each list element determines the number of values each categorical identity covariate can take.

gamma

a list of the category level probabilities of the same dimension as IDcovs. The category level probabilities for each covariate must sum to 1.

pMarkID

a vector of length 2 containing the probability the marked status is observed upon capture for marked and unmarked individuals, respectively. If these are less than 1, unknown marked status samples are produced.

tlocs

a single integer indicating the number of telemetry locations to simulate for each marked individual.

pID

the probability a marked individual's identity is obtained upon capture. If this is less than one, marked but unknown identity samples are produced.

Value

a list with many elements. y.mark is the capture history for the marking process where all individual identities of captured individuals are known or unidentified individuals are excluded. y.mark is the capture history from the marking process. y.sight is the complete sighting history for all captured individuals. y.sight.marked is the sighting history of the marked, observed marked status, and individually identified samples. y.sight.unmarked is the sighting history of the observed marked status unmarked individual samples. y.sight.unk is the sighting history for the samples for which marked status could not be determined. y.sight.marked.noID is the sighting history of the observed marked status marked, but not individually identified samples. Not all structures will be produced if there is perfect observation of mark status and/or individual identity of marked individuals. y.mark is of dimension n.marked x J1 x K1, where n.marked is the number of individuals captured and marked. y.sight is of dimension n.total x J2 x K2, where n.total is the total number of individuals captured and sighted. y.sight.unmarked is of dimension n_um x J2 x K2, where n_um is the number of unmarked samples observed. The other latent identity sighting histories are similarly structured with one observation per i.

G.x structures housing the observed categorical identity covariates correspond to the y.sight.x structures, linked by the i dimension. Missing values, if simulated, are indicated with a 0.

IDlist is a list containing ncat and IDcovs, inputs to the simulation function.

IDmarked, IDum, IDunk, and IDmnoID indicate which individual in "sfull" each ith row of the latent identity sighting histories came from. These could be used to reassemble the latent identity data sets into y.sight.

"locs" contains an n.marked x nlocs x 2 array of telemetry locations, if simulated, for the marked individuals. The i dimension of locs corresponds to the first n.marked i elements of y.sight and the i dimension of y.sight.marked.

"markedS" contains a history of which of the marked individuals were marked on each occasion.

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
33
34
35
36
37
## Not run: 
N=50
lam0.mark=0.05 #marking process baseline detection rate
lam0.sight=0.25 #sighting process baseline detection rate
sigma=0.50 #shared spatial scale parameter
K1=10 #number of marking occasions
K2=10 #number of sighting occasions
buff=2 #state space buffer
X1<- expand.grid(3:11,3:11) #marking locations
X2<- expand.grid(3:11+0.5,3:11+0.5) #sighting locations
pMarkID=c(0.8,0.8) #probability of observing marked status of marked and unmarked individuals
pID=0.8 #probability of determining identity of marked individuals
obstype=c("bernoulli","poisson") #observation model of both processes
ncat=3  #number of categorical identity covariates
gamma=IDcovs=vector("list",ncat) 
nlevels=rep(2,ncat) #number of IDcovs per loci
for(i in 1:ncat){ 
  gamma[[i]]=rep(1/nlevels[i],nlevels[i])
  IDcovs[[i]]=1:nlevels[i]
}
#inspect ID covariates and level probabilities
str(IDcovs) #3 covariates with 2 levels
str(gamma) #each of the two levels are equally probable
pIDcat=rep(1,ncat) #category observation probabilities
#Example of interspersed marking and sighting. 
Korder=c("M","M","S","S","S","S","M","M","S","M","M","S","M","M","S","S","S","S","M","M")
#Example with no interspersed marking and sighting.
Korder=c(rep("M",10),rep("S",10))
#if Korder is not of length K1+K2, there will be an error.
#Omitting Korder assumes no sighting occurred before marking ended.
tlocs=25
data=sim.genCatSMR(N=N,lam0.mark=lam0.mark,lam0.sight=lam0.sight,sigma=sigma,K1=K1,
                   K2=K2,Korder=Korder,X1=X1,X2=X2,buff=buff,obstype=obstype,ncat=ncat,
                   pIDcat=pIDcat,IDcovs=IDcovs,gamma=gamma,pMarkID=pMarkID,pID=pID,tlocs=tlocs)
data$markedS #marked status history across occasions for marked individuals

## End(Not run)

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