changing study area size

49 views
Skip to first unread message

jcl...@utk.edu

unread,
Dec 30, 2024, 2:33:02 PM12/30/24
to secr
I have about 14 years of spatially explicit CMR data on bears in a core study area but then we added a bunch of hair traps in year 15 to the secondary area surrounding the core as we thought the range had probably expanded.  I expect the densities to decrease as you get away from the core range so I added a distance covariate on D to account for this.  

I want to use all years of data to help me estimate the densities in the primary and secondary ranges in the last year.  The problem is that the estimate of N is much higher than the estimate if I use only year 2020 data.  The distance covariate makes a difference but I was unsure about how to apply it to just the last year and wondered if that might be causing a problem.  So, I used the mean covariate value for years 1 through 14 (all traps were in the core so the true distance = 0) and then used the actual distance values for year 15.  Does that seem reasonable?  I was trying to keep the distance covariate during years 1-14 (Distance = 0) from having too much of an effect on year 15 estimates so that is why I went with the mean value during 2020 rather than the actual distance (0) for the first 14 years.  Thanks..

Murray Efford

unread,
Jan 6, 2025, 11:26:41 PMJan 6
to secr
Hi Joe
Sorry for the slow response - just winding myself up for 2025!

Maybe you've already solved this one. What package are you using? openCR doesn't model density in space so I assume you mean secr. I'm unclear how you are calculating 'N', but let's assume modelling density will get you there. Why not simply fit a density model with a 2-level mask covariate (primary, secondary). The catch is that if you are using year-specific masks then for each one you will need to force the covariate to be a factor with both levels.

Mock example below.
Murray

library(secr)
setNumThreads(8)

# fake multisession data with extended sampling in last session
ovenCHp2 <- ovenCHp
primary <- subset(ovenCHp2, session=5)
secondary <- primary
traps(secondary) <- shift(traps(secondary),c(400,0))
ovenCHp2[[5]] <- append.capthist(primary, secondary)
session(ovenCHp2[[5]]) <- '2009ps'

# add mask covariate to single-session mask
msk <- make.mask(traps(ovenCHp2[[5]]), buffer = 250, nx = 30)
covariates (msk)$ps <- factor(ifelse(msk$x<200, 'primary','secondary'))

# plot
par(mfrow=c(2,3))
for (i in 1:5) {
    plot(msk, cov='ps', dots=F, mesh='black', legend=F)
    plot(traps(ovenCHp2[[i]]), add=T)
    plot(ovenCHp2[[i]], add=T)
}

# fit and predict
fit <- secr.fit(ovenCHp2, D~ps, mask = msk)
newdat <- expand.grid(session = factor(2005:2009), ps = factor(c('primary','secondary')))
predict(fit, newdata = newdat)

jcl...@utk.edu

unread,
Jan 7, 2025, 8:35:50 AMJan 7
to secr
Thanks Murray.  I decided that using the mean covariate value was a bad idea so I simply ran a D~session*distcore model and fixed all the betas except the last one to zero.  That seemed to work well.  
Joe

jcl...@utk.edu

unread,
Jan 7, 2025, 10:39:30 AMJan 7
to secr
Ok, the model fit fine (model = list(D~session*DistCore.3, g0~bk, sigma~1)) and my estimates for the last year with the covariate seems good, but I am having trouble getting an estimate of N using region.N.  I get the error message:
Error in object$beta.vcv[indx, indx] : subscript out of bounds 
In addition: There were 50 or more warnings (use warnings() to see the first 50)
and the warnings say 
Warning messages: 1: In fb[is.na(fb)] <- beta : 
number of items to replace is not a multiple of replacement length

Any ideas on why region.N doesn't work?

I estimated N directly by summing density in all the mask points:
(Nhat_2020<-sum(exp(b0+b1*1+b2*distcore_sess15+b3*1*distcore_sess15))*100 #182.6118 females)
but I need to estimate the variance and using the delta method gives me an estimate of 0 for the variance.



jcl...@utk.edu

unread,
Jan 7, 2025, 11:11:09 AMJan 7
to secr
I got the delta method from emdbook to work finally so all good!

Murray Efford

unread,
Jan 7, 2025, 2:30:36 PMJan 7
to secr
I'm glad you cracked this. It seems rather complicated, but at least you got there.
region.N seems to be having trouble with the fixed betas - I'll look into that later.
Murray

jcl...@utk.edu

unread,
Jan 7, 2025, 3:03:04 PMJan 7
to secr
Thank you as always Murray!
Reply all
Reply to author
Forward
0 new messages