Coding detector usage across sessions

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

Coding detector usage across sessions

Postby Tom.B » Tue Nov 06, 2012 12:59 pm

Hi all,

I have a data set consisting of 12 sessions (59 occasions in total). For 11 of those 12 sessions, the detector array was identical (200 traps arranged in a 10x10 grid, with 2 traps at each point). However, for the first session I only used a subset of those traps (90 traps in a 10x9 grid, one trap per point).

I've tried coding this into the trap file like so...

A1A -45.0 -45.0 11111111111111111111111111111111111111111111111111111111111
A1B -45.0 -45.0 00001111111111111111111111111111111111111111111111111111111

But when I go to read.capthist I get the following error -

Session 1
Conflicting number of occasions in usage matrix
capthist : 4 occasions
usage(traps(capthist)) : 59 occasions

Evidently secr is assuming all occasions are part of the same session.

Is there a better way of approaching this? All I want to do is use a different trap layout for the first session.

I've considered just excluding the first session from the analysis, but session 2 has very low capture numbers which causes further issues with calculating start values.

Thanks,
Tom
Tom.B
 
Posts: 19
Joined: Fri Jan 22, 2010 12:01 pm

Re: Coding detector usage across sessions

Postby murray.efford » Tue Nov 06, 2012 3:40 pm

Tom
Your diagnosis is correct. The missing fact is that 'secr' uses a distinct detector layout for each session. If you provide only one then it is copied across sessions in your capthist object. You are free to modify these individually as follows:

Code: Select all
## remove usage attribute from detectors in all sessions
for (i in 1:12)
    usage(traps(myCH[[i]])) <- NULL
## restrict detectors to first 90 for session 1
traps(myCH)[[1]] <- subset(traps(myCH)[[1]], 1:90)


Replace 1:90 with the indices of the traps you used in session 1. 'usage' is not needed if the same set of traps was used on each occasion within a session.

Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Coding detector usage across sessions

Postby Tom.B » Tue Nov 06, 2012 5:17 pm

Thanks Murray, looks promising. Will give it a shot tomorrow.
Tom.B
 
Posts: 19
Joined: Fri Jan 22, 2010 12:01 pm

Re: Coding detector usage across sessions

Postby Tom.B » Wed Nov 07, 2012 6:35 am

OK, so using your code seems to work well-

Code: Select all
> cmmaleCH<-read.capthist("CMmale.txt", "10x10x2grid.txt", fmt="trapID", covnames=c("Age", "Rep"))
No errors found :-)
> usage(traps(cmmaleCH[[1]]))<-NULL
> traps(cmmaleCH)[[1]]<-subset(traps(cmmaleCH)[[1]],1:90)

> summary(cmmaleCH[[1]])
Object class      capthist
Detector type     multi
Detector number   90
Average spacing   10 m
x-range           -45 35 m
y-range           -45 45 m

etc


However, secr.fit is now unhappy with me specifying cmmaleCH as the capthist -

Code: Select all
> cmmaledetect0<-secr.fit(cmmaleCH, detectfn=0, trace=TRUE, buffer=100)
Error in secr.fit(cmmaleCH, detectfn = 0, trace = TRUE, buffer=100)  :
  requires 'capthist' object


It runs fine if I specify cmmaleCH[[1]] or another single session.

Any way around this?

Thanks again,
Tom
Tom.B
 
Posts: 19
Joined: Fri Jan 22, 2010 12:01 pm

Re: Coding detector usage across sessions

Postby murray.efford » Wed Nov 07, 2012 1:42 pm

Try with the right parentheses on 'traps' moved right outside the ]]:

Code: Select all
traps(cmmaleCH[[1]]) <-subset(traps(cmmaleCH[[1]]),1:90)


(Remember I'm assuming that it's the first 90 traps you used in session 1)

Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Coding detector usage across sessions

Postby Tom.B » Fri Nov 09, 2012 7:45 am

Well don't I feel silly now :oops:

Thanks again Murray. I may have one further unrelated question for you, but will start a separate thread once I've checked a few things.
Tom.B
 
Posts: 19
Joined: Fri Jan 22, 2010 12:01 pm

Re: Coding detector usage across sessions

Postby jlaufenb » Mon Apr 13, 2015 1:36 pm

Hi Murray,

I have a similar situation requiring session-specific trap arrays. I have 2 years of data with 8 occasions each from the same study area, but the trap array slightly changed between years. Overall, I have 144 trap sites where 126 of them were operated in year 1 and 129 of them were operated in year 2. So far, I have read in a traps file containing all 144 traps and used that with the capture data to create a capthist object. Given that I have specified years as sessions, I took the above suggestion and subsetted the traps element for each session of the capthist object. However, verify() returns the following warning:

Code: Select all
Session Y1
traps object incompatible with reported detections
traps(capthist) : 126 detectors
capthist : 144 detectors
Session Y2
traps object incompatible with reported detections
traps(capthist) : 129 detectors
capthist : 144 detectors


Since the original post here is a few year old, I thought I'd ask is there a better way to handle/format this type of data? Are spatially independent trap arrays treated as sessions handled differently?

Thanks
Jared
jlaufenb
 
Posts: 49
Joined: Tue Aug 05, 2008 2:12 pm
Location: Anchorage, AK

Re: Coding detector usage across sessions

Postby murray.efford » Mon Apr 13, 2015 4:26 pm

Hi Jared
Assuming you have 'proximity' detectors, the capthist component for each session is based on a 3-D array whose 3rd dimension has length equal to the number of traps. Hence the mismatch you have encountered when you work backwards from a pooled set of traps (capthist in each session still has the enlarged 3rd dimension). I think the solution is to input your capthist again, providing a vector of session-specific trapfile names to read.capthist, or using make.capthist. You may also need to specify a vector of session-specific 'occasions'.
Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Coding detector usage across sessions

Postby jlaufenb » Wed Apr 15, 2015 9:34 am

Hi Murray,

Thanks for the response. My solution was to create separate traps objects for each session using the read.traps() function and then read them into the make.capthist() function as a list for the traps argument. Below is some code to illustrate for others:

Code: Select all
trapsS1 <- read.csv("trapsY1.csv")
trapsS2 <- read.csv("trapsY2.csv")

trapsS1.secr <- read.traps(data = trapsS1, detector = "proximity")
trapsS2.secr <- read.traps(data = trapsS2, detector = "proximity")

caps.secr <- read.csv("mycaps.csv") # years treated as sessions

my.capthist <- make.capthist(captures=caps.secr, traps = list(trapsS1.secr,trapsS2.secr), fmt="trapID")


Note: The session-specific trap objects must be brought into the make.capthist() function as a list. Otherwise, you get the following error message:
Code: Select all
multi-session 'traps' list does not match 'captures'


Jared
jlaufenb
 
Posts: 49
Joined: Tue Aug 05, 2008 2:12 pm
Location: Anchorage, AK

Re: Coding detector usage across sessions

Postby murray.efford » Wed Apr 15, 2015 5:34 pm

It sounds like you have this sorted. I think this simpler code should work, too:
Code: Select all
my.capthist <- read.capthist(captfile = "mycaps.csv", trapfile = c("trapsY1.csv", "trapsY2.csv"))
although I'm not 100% sure about csv.
Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand


Return to analysis help

Who is online

Users browsing this forum: No registered users and 2 guests