habitat covariates for density parameter-multiple sessions?

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

habitat covariates for density parameter-multiple sessions?

Postby FTvM » Thu Oct 06, 2011 8:55 pm

I'm using SECR/R with a DNA-based dataset of black bear captures in 2 separate sampling areas; one of my objectives is to determine if density is associated with a set of habitat covariates (i.e., mask covariates). If so, I plan to use model-averaged parameter estimates for the density covariates to map density.

I have completed such an analysis for one year (and the results look very promising) and tried to add another year as a second session. However, the program returns a message indicating a "mismatch between multisession object and covariates". The detectors and mask covariates are the same for both sessions.

My question is if multiple sessions can be used when using mask covariates? If so, what is the best way to link the mask covariate data to the multi-session capture history data?

Frank
FTvM
 
Posts: 6
Joined: Tue Aug 19, 2008 3:59 pm
Location: Bozeman, MT

Re: habitat covariates for density parameter-multiple sessio

Postby murray.efford » Thu Oct 06, 2011 9:29 pm

Frank
I can see the advantages of pooling data across seasons. I can't put my finger on where that problem comes from (were you providing one mask or a list of two masks?) but, even if you get past that, you will run into the problem I did just now with the 'skink' example:
secr.fit(infraCH, mask = LSmask, model = D~habclass)
"D.designdata does not yet handle mask covariates for multiple sessions"
which is pretty terminal. Adapting D.designdata for multiple sessions with covariates shouldn't be too hard, but needs a clear head, which I was lacking at the time. I'll look at it soon and get back to you.

I'm glad to hear you were able to make progress with the other models.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: habitat covariates for density parameter-multiple sessio

Postby murray.efford » Sun Oct 09, 2011 5:25 pm

I have re-written D.designdata to allow mask covariates with multiple sessions, and this will appear in the next release. Contact me offline if you would like to try the beta version, which seems stable. Sessions may all use the same mask; if each has a different mask it is provided in a mask list of length equal to the number of sessions. Mask covariates should be in a dataframe, the covariates attribute of each mask.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: habitat covariates for density parameter-multiple sessio

Postby jctroxler » Wed May 15, 2013 3:58 pm

I'm using SECR 2.5.0 and getting the same error as Frank. I'm trying to read in habitat covariates from a neighborhood analysis. It works fine for 1 session but if I try to run 3 sessions, it creates a "mismatch between multisession object and covariates". I'm using a single mask and the same set of detector coordinates across all 3 sessions. The .csv file contains 6 columns for XY coordinates and an additional column without a header indicating cell #.

write.table(MASKCOAST, file = "habitatxyALL.csv", sep = ",")
> habvar <- read.table(file = 'gridcovariatesALL.txt', header = TRUE)
> covariates(MASKCOAST) <- habvar

Error in `covariates<-`(`*tmp*`, value = list(X1.x = c(658406.0234, 659725.4766, :
mismatch between multisession object and covariates


Thanks for your help!
jctroxler
 
Posts: 5
Joined: Wed Oct 10, 2012 3:37 pm

Re: habitat covariates for density parameter-multiple sessio

Postby murray.efford » Wed May 15, 2013 4:33 pm

Hi
I'm hazy about the structure of MASKCOAST - single-session mask or list?. Probably the fastest way to sort this is to send me the files (using save(MASKCOAST, file='maskcoast.RData') if necessary). There has been a silent problem with covariates in some multisession analyses with varying number of occasions that should be fixed in the next version, but I don't think that relates.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: habitat covariates for density parameter-multiple sessio

Postby murray.efford » Fri May 17, 2013 4:27 pm

It seemed Jesse was also hazy about whether MASKCOAST was single- or multi-session. Assigning the covariates to a single-session mask worked just fine. Building a mask from a multi-session traps object results in a multi-session mask, even if traps were identical for each session. Covariates cannot be assigned simultaneously to all session-specific masks in a multi-session mask. However, secr.fit can accept a single-session mask as input for a multi-session analysis (assuming same mask for each session) so I'm hoping the problem is resolved.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: habitat covariates for density parameter-multiple sessio

Postby mdrever » Thu Oct 25, 2018 5:51 pm

hello SECR list,
I am struggling with adding habitat covariates to a multiple session model. We have capture/resight data for skinks from two big plots (625 detectors each at 'Shilo' and 'SWPP') in Manitoba, Canada. We have a very low resight rate (14 resights from >500 individuals marked at the two plots combined), and so I have used a suggestion from elsewhere in the forum to look at the two plots as separate sessions in order to maximize the available data on resights to estimate g0 and sigma. I may be pushing the data too far, but the majority of the capture happen in two of the three habitat types, and it would good to formally test for that difference. However, when I try to add the habitat covariates, I seem to convert my capt.hist into a traps object. Any help would be greatly appreciated. Annotated code and errors follow below. thank you very much for any guidance,
Mark.

## make the capture history as two sessions
skinks.CH <- read.capthist('skinks.txt', c('swpp.grid.txt','shilo.grid.txt'), detector = "multi",
covnames = 'Age', noccasions = 14 )
summary(skinks.CH) ## capture histories as a list ## plotting them looks as it should

#The plot effect can be tested by comparing the two models: ## this section runs well
#EX chosen by AIC from other available functions
fit0 <- secr.fit(skinks.CH, model = D ~ 1, buffer = 25, detectfn ='EX')
fit1 <- secr.fit(skinks.CH, model = D ~ session, buffer = 25, start = fit0, detectfn ='EX')

## compare the models ## supports different densities at the two sites (not shown)
fits <- secrlist(fit0 =fit0,fit1 =fit1 )
AIC (fits)

############## make the habitat masks ############################
covariates(traps(skinks.CH)[[1]]) <- all.grids[all.grids$Grid == 'SHILO',c('Habitat.Type')]
covariates(traps(skinks.CH)[[2]]) <- all.grids[all.grids$Grid == 'SWPP',c('Habitat.Type')]
names(attr(skinks.CH[[1]], "covariates")) <- 'Habitat.Type'
names(attr(skinks.CH[[2]], "covariates")) <- 'Habitat.Type'

skinks.mask <- make.mask(traps(skinks.CH), type = 'traprect', buffer = 17.5 )
skinks.mask <- addCovariates(skinks.mask, traps(skinks.CH), 'Habitat.Type', replace = TRUE)
names(attr(skinks.mask[[1]], "covariates")) <- 'Habitat.Type'
names(attr(skinks.mask[[2]], "covariates")) <- 'Habitat.Type'
## plotting the masks looks correct (not shown)

# adding the habitat mask to the model, and resulting error
fit2 <- secr.fit(skinks.CH, model = D ~ session + Habitat.Type , buffer = 25,
mask = skinks.mask , detectfn ='EX')

Error in secr.fit(skinks.CH, model = D ~ session + Habitat.Type, buffer = 25, :
requires 'capthist' object

> class(skinks.CH)
[1] "traps" "list"

> str(skinks.CH)
List of 2
$ : capthist [1:101, 1:14, 1:625] 0 0 0 0 0 0 0 0 0 0 ...
..- attr(*, "dimnames")=List of 3
.. ..$ : chr [1:101] "UNIQ011" "UNIQ012" "UNIQ013" "UNIQ014" ...
.. ..$ : chr [1:14] "1" "2" "3" "4" ...
.. ..$ : chr [1:625] "1" "2" "3" "4" ...
..- attr(*, "covariates")='data.frame': 101 obs. of 1 variable:
.. ..$ Habitat.Type: Factor w/ 3 levels "A","H","J": 3 1 1 3 1 3 1 1 1 1 ...
..- attr(*, "traps")=Classes ‘traps’ and 'data.frame': 625 obs. of 2 variables:
.. ..$ x: int [1:625] 250 325 275 25 525 250 350 450 400 225 ...
.. ..$ y: int [1:625] 325 400 325 475 0 500 325 500 225 350 ...
.. ..- attr(*, "detector")= chr "multi"
.. ..- attr(*, "spacex")= num 25
.. ..- attr(*, "spacey")= num 25
.. ..- attr(*, "spacing")= num 25
.. ..- attr(*, "covariates")='data.frame': 625 obs. of 1 variable:
.. .. ..$ value: Factor w/ 3 levels "Grassland","Open Woods",..: 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "session")= chr "SHILO"
$ : capthist [1:340, 1:14, 1:625] 0 0 0 0 0 0 0 0 0 0 ...
..- attr(*, "dimnames")=List of 3
.. ..$ : chr [1:340] "UNIQ001" "UNIQ002" "UNIQ003" "UNIQ004" ...
.. ..$ : chr [1:14] "1" "2" "3" "4" ...
.. ..$ : chr [1:625] "1" "2" "3" "4" ...
..- attr(*, "covariates")='data.frame': 340 obs. of 1 variable:
.. ..$ Habitat.Type: Factor w/ 3 levels "A","H","J": 1 1 3 3 1 3 3 1 3 1 ...
..- attr(*, "traps")=Classes ‘traps’ and 'data.frame': 625 obs. of 2 variables:
.. ..$ x: int [1:625] 25 525 150 200 150 375 25 425 475 25 ...
.. ..$ y: int [1:625] 600 200 200 500 225 225 275 325 200 225 ...
.. ..- attr(*, "detector")= chr "multi"
.. ..- attr(*, "spacex")= num 25
.. ..- attr(*, "spacey")= num 25
.. ..- attr(*, "spacing")= num 25
.. ..- attr(*, "covariates")='data.frame': 625 obs. of 1 variable:
.. .. ..$ value: Factor w/ 3 levels "Grassland","Open Woods",..: 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "session")= chr "SWPP"
- attr(*, "class")= chr [1:2] "traps" "list"
mdrever
 
Posts: 2
Joined: Wed Oct 24, 2018 3:45 pm

Re: habitat covariates for density parameter-multiple sessio

Postby murray.efford » Thu Oct 25, 2018 6:44 pm

Yes, fiddling with components of a multi-session capthist can give screwy results. I think you can fix it like this
Code: Select all
library(secr)

# wrong
CH <- subset(ovenCH, session = 1:2)
class(CH)
covariates(traps(CH)[[1]]) <- data.frame(i = 1:nrow(traps(CH)[[1]])) # fake covariate 'i' for demo
covariates(traps(CH)[[2]]) <- data.frame(i = 1:nrow(traps(CH)[[2]]))
class(CH)

# right
CH <- subset(ovenCH, session = 1:2)
covariates(traps(CH[[1]])) <- data.frame(i = 1:nrow(traps(CH[[1]])))
covariates(traps(CH[[2]])) <- data.frame(i = 1:nrow(traps(CH[[2]])))
class(CH)

covariates(traps(CH))


Note that you can model density as a function of a mask covariate (as you attempted), but you cannot model detection parameters (g0, sigma) as functions of mask covariates - that's where trap-level covariates come in (may be slow).
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: habitat covariates for density parameter-multiple sessio

Postby mdrever » Thu Oct 25, 2018 7:18 pm

Brilliant! thank you! Will keep the models very simple. thanks again!
mdrever
 
Posts: 2
Joined: Wed Oct 24, 2018 3:45 pm


Return to analysis help

Who is online

Users browsing this forum: No registered users and 13 guests