Trouble fitting multi-session secr.fit model

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

Trouble fitting multi-session secr.fit model

Postby hgamblin » Tue Nov 16, 2021 8:06 pm

Hi all, I'm having trouble getting my capture history to reflect multiple sessions. I've tried following the "Multi-session models in secr" PDF and searching for various solutions, but I haven't been able to find a solution. My study design has 11 sessions (G01, G02, ...G12), each with 18 detectors set out for 5 occasions. We survey for island foxes one grid at a time over the course of 3 months, with each grid containing 18 traps (6 x 3 spaced 250 m apart) left out for 5 nights. Unfortunately, when I create my capture history, it treats each session as if there were 198 detectors set out (18 traps x 11 grids), when I would like it to reflect 18 detectors per session.

Here is the code I've use for my capture history (foxCH), as well as a summary of foxCH:

Code: Select all
> foxCH = read.capthist("2021gridcapt.txt","2021gridtrap.txt", detector = "single")
No errors found :-)
Warning messages:
1: In make.capthist(captures = capturelist[[i]], traps = trps, fmt = fmt,  :
  dropping repeat detections within occasions at exclusive detectors (traps)
2: In make.capthist(captures = capturelist[[i]], traps = trps, fmt = fmt,  :
  dropping repeat detections within occasions at exclusive detectors (traps)
3: In make.capthist(captures = capturelist[[i]], traps = trps, fmt = fmt,  :
  dropping repeat detections within occasions at exclusive detectors (traps)


There should be 18 detectors associated with each session (G01, G02, ... G12), but they are each showing all 198 detectors used throughout the season.

Code: Select all
> summary(foxCH, terse = TRUE)
           G01 G02 G03 G04 G05 G06 G08 G09 G10 G11 G12
Occasions    5   5   5   5   5   5   5   5   5   5   5
Detections  59  26  22  26  25  33  25  22  23  45  23
Animals     25  14  16  14   9  13   8  10  12  19  11
[b]Detectors  198 198 198 198 198 198 198 198 198 198 198[/b]


Here is a brief summary of my session capture data and associated detector data for reference:

Code: Select all
> foxcapt = read.table("C:/Users/Hospital/Desktop/2021_Grid_Densities/2021gridcapt.txt")
> head(foxcapt)
   V1     V2 V3     V4
1 G01 619591  5 G01T15
2 G01 450500  5 G01T36
3 G01 619947  4 G01T33
4 G01 605234  2 G01T13
5 G01 622471  2 G01T18
6 G01 647185  2 G01T17

> foxtrap = read.table("C:/Users/Hospital/Desktop/2021_Grid_Densities/2021gridtrap.txt")
> head(foxtrap)
      V1     V2      V3
1 G01T13 352594 3653294
2 G01T14 352444 3653094
3 G01T15 352294 3652894
4 G01T16 352494 3652744
5 G01T17 352644 3652944
6 G01T18 352794 3653144
...
193 G12T31 363713 3639826
194 G12T32 363515 3639673
195 G12T33 363316 3639521
196 G12T38 363469 3639323
197 G12T39 363667 3639475
198 G12T40 363865 3639627


Is there a way I can fix my capture history to assign the 18 detector names (i.e. G01T13, or G12T31) to their associated session (i.e., G01, or G12)? The fitted secr.fit model with the current foxCH and a buffer of 800m lists all 11 unique sessions, but provides the same incorrect estimate of density for each one. If I use the same code but input capture and trap text files for one grid (i.e., Grid 1), I get a reasonable density estimate. I know I can upload 11 capture and trap text files and run separate models as they've done in previous years on this project, but I'm hoping I can fix my capture history to allow for multi-sessions.

Thank you all so much for your help!
hgamblin
 
Posts: 2
Joined: Tue Nov 16, 2021 5:52 pm

Re: Trouble fitting multi-session secr.fit model

Postby murray.efford » Tue Nov 16, 2021 11:06 pm

Hi
You can use 1 capture file and 11 trap files (listed in order by session). Or if the layout is the same for each grid (as you describe) then just define a single 'standard' grid and replace the detector labels (I don't get how you have named detectors, but let's assume there are 18) in your capture file (trapID <- substring(trapID, 4,6) would work if labelling had been consistent).
Murray
murray.efford
 
Posts: 648
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Trouble fitting multi-session secr.fit model

Postby hgamblin » Wed Nov 17, 2021 10:58 am

Hi,

Thank you so much for your help! The original study design included 40 traps per grid, but recent analysis showed that reducing effort did not effect estimates, so the study design includes a subset of 18 of those original 40 per grid, which is why the trap names are different per grid.

I went ahead and made 11 unique trap files for each grid, but unfortunately I'm having trouble running read.capthist.

Attempt 1:
Code: Select all
>foxCH = read.capthist("2021_AllGridsCapt.txt", "2021_G01trap.txt", "2021_G02trap.txt", "2021_G03trap.txt", "2021_G04trap.txt", "2021_G05trap.txt", "2021_G06trap.txt", "2021_G08trap.txt", "2021_G09trap.txt", "2021_G10trap.txt", "2021_G11trap.txt", "2021_G12trap.txt", detector = "single")


I see in the help for ?read.capthist trapfile = name of trap layout file or (for a multi-session captfile) a vector of file names, one for each session, so I tried to create a vector using list.files().

Attempt 2:
Code: Select all
>"2021AllGridsTrap" = list.files("C:/Users/Hospital/Desktop/2021_Grid_Densities/AllGridsTest/2021_AllGridsTrap")
>foxCH = read.capthist("2021_AllGridsCapt.txt", `2021AllGridsTrap`, detector = "single")


My apologies if creating a vector of file names to input into the read.capthis is basic R 101 - I'm in the process of relearning R so I'm not well versed.
hgamblin
 
Posts: 2
Joined: Tue Nov 16, 2021 5:52 pm

Re: Trouble fitting multi-session secr.fit model

Postby murray.efford » Wed Nov 17, 2021 3:34 pm

A vector of names is just a vector of character values that you make with c().
e.g. c("2021_G01trap.txt", "2021_G02trap.txt", "2021_G03trap.txt", "2021_G04trap.txt", "2021_G05trap.txt", "2021_G06trap.txt", "2021_G08trap.txt", "2021_G09trap.txt", "2021_G10trap.txt", "2021_G11trap.txt", "2021_G12trap.txt")

[It would be tidier to go with the 'standard grid' idea: create a dataframe 'oldnew' with columns 'old' and 'new' and 198 rows, showing the new name for each old site
old new
G01T13 T01
G01T14 T02
G01T15 T03
etc.
then replace the specific names in the capture dataframe:
capt$trap <- oldnew$new[match(capt$trap, oldnew$old)]
This requires you to generate a dataframe of captures 'capt', a standard traps object 'trps' and combine them with make.capthist()]

As you say, this is R coding that is really outside the scope of this forum. But you seem to be getting there.
murray.efford
 
Posts: 648
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 1 guest