array3d2SCR.fn: utility function to convert 3-d encounter history array to...

Description Usage Arguments Details Value Author(s) Examples

Description

individuals x sampling occasion x traps into a 2 dimensional matrix where column 1=traps, column 2=individuals and column 3=sample occasion which can passed into the function SCRf.fn~~

Usage

1
array3d2SCR.fn(y = object)

Arguments

y

i=number of individuals, k=number of sampling occasion, and j=number of traps ~~

Details

A typical object is constructed of an array containing zero and 1 variables indicating if individual i was observed on sampling occasion k in trap j

Value

matrix of nrows and 3 columns is returned where columns contain trap number, individual, and sampling occasions of observed animals. Object can be used as a input for the function SCRf.fn

Author(s)

Andy Royle aroyle@usgs.gov

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
##---- test.data<-array(dim=c(200,3,50)) 
##-- for(i in 1:200)
	{
	for(j in 1:3)
	{
	for(k in 1:50)
	{
	test.data[i,j,k]<-rbinom(1,1,0.2)
	}
	}
	}
SCR.data<-array3d2SCR.fn(test.data)

##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (y = tiger.data3d) 
{
    dd <- dim(y)
    nind <- dd[1]
    nrep <- dd[2]
    ntrap <- dd[3]
    indid <- repid <- trapid <- NULL
    for (i in 1:nind) {
        yi <- y[i, , ]
        indid <- c(indid, rep(i, sum(yi > 0, na.rm = TRUE)))
        repid <- c(repid, row(yi)[!is.na(yi) & yi > 0])
        trapid <- c(trapid, col(yi)[!is.na(yi) & yi > 0])
    }
    o <- cbind(trapid, indid, repid)
    dimnames(o) <- list(NULL, c("trapid", "individual", "sample"))
    o <- o[order(o[, 1]), ]
    o
  }

jaroyle/SCRbayes documentation built on May 18, 2019, 4:48 p.m.