N-mixture model in winbugs

360 views
Skip to first unread message

Kaylan

unread,
Dec 11, 2014, 9:01:21 AM12/11/14
to unma...@googlegroups.com
I hope it is appropriate to post a winbugs-related question here.  If not, could somebody point me in a better direction? Regardless, I'm attempting to run N-mixture models in WINBUGS in a bayesian framework with random effects.  Just to test that I was setting my models up correctly, I ran a null model in WINBUGS via R2WinBUGS.  That was one and a half days ago and the model is still running.  Is this normal for Winbugs?  My code is below:

library(R2WinBUGS)
bugsData<-list(y=as.matrix((df8[,c("c.1","c.2","c.3")]),nsites=5175,nOccasions=3))
str(bugsData)

bugsInits<-function() list(a0=runif(1),b0=runif(1),N=as.integer(rep(15,5175)))

bugsPars<-c("a0","b0")

modFile<-"I:/model.txt"

mod<-bugs(bugsData, bugsInits, bugsPars, modFile, n.chains=1, n.iter=2000, n.burnin=1000, n.thin=1, 
debug=T, codaPkg=T, working.directory=tempdir())



#MOD FILE:

model{

# Priors

a0 ~ dnorm(0, 0.01)I(-5, 5)
b0 ~ dnorm(0, 0.01)I(-5, 5)

# Model

for(i in 1:nSites) {
log(lambda[i]) <- a0 
N[i] ~ dpois(lambda[i])
for(j in 1:nOccasions) {
logit(p[i, j]) <- b0
y[i, j] ~ dbin(p[i, j], N[i])
}
}


}

Kery Marc

unread,
Dec 11, 2014, 9:11:00 AM12/11/14
to unma...@googlegroups.com

Hi Kaylan,

 

before somebody says that no BUGS is allowed on this list, let me say this: unfortunately, with over 5000 sites, for an Nmix model such run times are nothing out of the ordinary for WinBUGS. You could try JAGS, which for these types of models may easily be twice as fast. Also, during the model building and exploration phase, you should consider running many fewer iterations (e.g., at the very beginning steps of a modeling project, 12, with a burnin of 2).

 

One more comment about this:

a0 ~ dnorm(0, 0.01)I(-5, 5)

b0 ~ dnorm(0, 0.01)I(-5, 5)

 

These are simple vague normal priors for the two intercepts of the hierarchical model. I would not truncate them using the I() construct. Some people (including myself), do this sometimes for constraining normally distributed random effects, but even then I would use wider bounds (e.g., -15, 15). JAGS doesn't need this trick (and indeed doesn't allow it).

 

Kind regards  --- Marc

______________________________________________________________
 
Marc Kéry
Tel. ++41 41 462 97 93
marc...@vogelwarte.ch
www.vogelwarte.ch

Swiss Ornithological Institute | Seerose 1 | CH-6204 Sempach | Switzerland
______________________________________________________________

*** Intro book on Bayesian statistical modeling: Kéry, 2010, Introduction to WinBUGS for Ecologists, Academic Press; see www.mbr-pwrc.usgs.gov/pubanalysis/kerybook
*** Book on Bayesian statistical modeling: Kéry & Schaub, 2012, Bayesian Population Analysis using WinBUGS, Academic Press; see
www.vogelwarte.ch/bpa 
*** Upcoming workshops:
http://www.phidot.org/forum/viewforum.php?f=8

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages