Priors for Occupancy

130 views
Skip to first unread message

Joshua Hubbell

unread,
Dec 3, 2020, 4:00:06 PM12/3/20
to hmecology: Hierarchical Modeling in Ecology
Hi All,

I am still very new to the Bayesian approach. I am fortunate in that I have access to both historical and contemporary occupancy data for a rare freshwater fish. With that in mind, the Bayesian approach seemed to be best suited for tackling the research objectives of the project that I'm currently working on. With that in mind, I have a couple of questions:

1.  What distributions seem to work best for specifying informative priors on psi and p and betas for covariates? In this case, I'd be using estimates of psi, p, and the betas from the historical models as priors for the contemporary models. 

2.  There appears to be remarkably mixed views on DIC vs. WAIC in the literature. Recent papers (Stevens & Conway, 2019) suggest that neither method is appropriate; rather they suggest using logarithmic scoring rule).  However, it seems that this assumption is mostly based on the premise that the analyst would use out-of-sample data to test the model's predictive performance. I think I read somewhere that other users on this forum more or less reached this same assertion. What are your opinions? 

Any guidance, as always, is much appreciated.

Thanks!

-Josh




Kery Marc

unread,
Dec 4, 2020, 6:06:22 AM12/4/20
to Joshua Hubbell, hmecology: Hierarchical Modeling in Ecology
Dear Josh,

about 1. it is best to simply analyse all data in one single model in what could be called an integrated model. In that way, the "flux" of the information from the old to the new data happens automatically. When you fit one model to the old data and then distill the information about the resulting estimates into some distribution to be used as a prior in the analysis for the new data, you simply take two steps and do things more approximately, instead of doing all at once and exact. --- And of course, in such a combined analysis you can then more directly compare distribution between then and now, full with proper uncertainty. Sure this is one objective of your analysis.

about 2: don't know.

Best regards  --- Marc



From: hmec...@googlegroups.com [hmec...@googlegroups.com] on behalf of Joshua Hubbell [jhubbel...@gmail.com]
Sent: 03 December 2020 22:00
To: hmecology: Hierarchical Modeling in Ecology
Subject: Priors for Occupancy

--
*** Three hierarchical modeling email lists ***
(1) unmarked: for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology (this list): for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2016, 2020)
---
You received this message because you are subscribed to the Google Groups "hmecology: Hierarchical Modeling in Ecology" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/6f6e449d-52ba-421a-89a4-3dc060f226b3n%40googlegroups.com.

Joshua Hubbell

unread,
Dec 4, 2020, 3:37:41 PM12/4/20
to hmecology: Hierarchical Modeling in Ecology
Marc,

Thank you very much for your rapid response. One more quick question: I'm assuming the best way to integrate the two datasets into one model would be to  include a categorical factor (e.g., Time)  to account for how differences in  time period are affecting psi. I would think that would work?

Sincerely,

Josh

Kery Marc

unread,
Dec 5, 2020, 4:42:51 AM12/5/20
to Joshua Hubbell, hmecology: Hierarchical Modeling in Ecology
Dear Josh,

yes, of course. Question: how many years do you have in the early and the current period ?

Re. model selection: I skimmed the Stevens and Conway paper and since they find the log predictive density produced a better selection of models than either the DIC or WAIC, I would probably try that. And they even provide some code for it for the a multi-year occupancy model.

Best regards  --- Marc

Sent: 04 December 2020 21:37

To: hmecology: Hierarchical Modeling in Ecology
Subject: Re: Priors for Occupancy

Joshua Hubbell

unread,
Dec 6, 2020, 7:53:42 PM12/6/20
to hmecology: Hierarchical Modeling in Ecology
Marc,


Following  your advice, I  chose to include a categorical factor (Period) in the likelihood so that psi could be modeled as a random intercept, allowing for the formulation of two separate parameters (contemporary occupancy and historic occupancy). I'm certain I'm not far off in the coding of the model, but I continue to get an error message from R stating "compilation error, index out of range, taking subset of psi". I have no idea what this means, and as far as I can tell, the model is set up correctly.

Code is attached below. The code was pulled from this wonderful tutorial (https://bcss.org.my/tut), which I believe was put together by Mike Meredith?

Thoughts?

Thanks,

Josh

Kery Marc

unread,
Dec 7, 2020, 2:56:22 AM12/7/20
to Joshua Hubbell, hmecology: Hierarchical Modeling in Ecology

Dear Josh,

 

no code attached. However, the error message indicates that there is a discrepancy between the dimensions of your data and of the parameters for psi in your model. For instance, perhaps you have 1000 sites earlier and 2000 sites now and then you define psi in the model to have length 1000 for both. Check this out. Getting absolutely clear about the dimensions of the objects in the models is one of the biggest challenge at first when using the BUGS language.

 

And yes, the tutorial is my Mike Meredith. Outstanding. Probably worth of being published as an intro book.

 

Best regards  -- Marc

Joshua Hubbell

unread,
Dec 7, 2020, 3:42:55 PM12/7/20
to hmecology: Hierarchical Modeling in Ecology
Marc,

Thank you for the quick reply.

Using your suggestion I went back and examined the code, but, I cannot seem to identify the error. If you or anyone else would be willing to give
this a look, I'd be thoroughly appreciative! Data is attached below. Here's the code:

#####Single-Season Occupany Model
data<-read.csv("data.csv", header = T, row.names = "ID")

#detection data
y<-data[,2:3]
n<-nrow(data)
n.occas<- ncol(y)

#Site Covariates
Period<- as.integer(data$Period)
DA<- log(data[,17])
PC1<- data[,13]
PC2<- data[,14]
Area<- log(data[,15])
Bar.Type<- log(data[,16])
Sinuosity<- log(data[,18])

#observation covariates
Effort<- data[,6:7]

#Single-Season Occupancy Model with Observation Covariate and Random Intercept on Psi (Period)
#Organize Data into List for input into JAGS
jags.data<-list(y=y,n.sites=n,n.occas=n.occas, Effort=Effort, Period=Period, nCat=2)

########################
require(jagsUI)
sink("model.jags.txt")
cat("
model{

# Priors
  for(i in 1:nCat) {
    psi[i] ~ dunif(0,1)
    }
alpha.p ~ dnorm(0, 0.01)
beta1.p ~ dnorm(0, 0.01)

# Likelihood
# Ecological model for the partially observed true state
for (i in 1:n.sites) {
   z[i] ~ dbern(psi[Period[i]])                # True occurrence z at site i
   
   # Observation model for the observations
    for (j in 1:n.occas) {
      y[i,j] ~ dbern(mu.p[i,j]) # Detection-nondetection at i and j
      mu.p[i,j] <- z[i] * p[i,j]
      logit(p[i,j]) <- alpha.p + beta1.p * Effort[i,j] 
      } #j
   } #i
   site.occup<- sum(z[])
    }
    ", fill=TRUE)
sink()





data.csv

Jose Jimenez Garcia-Herrera

unread,
Dec 7, 2020, 4:55:42 PM12/7/20
to Joshua Hubbell, hmecology: Hierarchical Modeling in Ecology

Hi Joshua,

 

You have in your data:

 

Effort[31,2]= NA

 

Discard this row or assign some value.

Also, you have to use “Period+1” if you are indexing 1,2.

 

Period<- as.integer(data$Period) + 1

 

Good luck!

--

*** Three hierarchical modeling email lists ***
(1) unmarked: for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology (this list): for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2016, 2020)
---
You received this message because you are subscribed to the Google Groups "hmecology: Hierarchical Modeling in Ecology" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages