--
*** 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 (2015)
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23JuCJOaYovp3fqge2pVOU4LsQpAe3dK5VDCf4Q%2BKigJ4aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi Peter,
Thanks for the comment. I probably shouldn’t have mentioned parallel chains in my post. The speed gain has nothing to do with running chains in parallel. The main comparison I wanted to make was between:
## Standard approach
system.time({
jm <- jags.model("scr0.jag", jd, ji, n.adapt=200)
jc <- coda.samples(jm, c("lam0","sigma","N","deviance"), n.iter=200)
})
and
## Faster
system.time({
jm.faster <- jags.model("scr0-faster.jag", jd.faster, ji, n.adapt=200)
jc.faster <- coda.samples(jm.faster, c("lam0","sigma","N","deviance"), n.iter=200)
})
The latter should be >2x faste
Regardless, thanks for the info about
Richard
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAH9coKatSWBeLLgYN2%2BMMiB3XLVpkSkvquOoXr3ao908FNY_AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi Richard,
that is a nice trick. Alternatively, if you don't have temporal covariates (which most people don't), you can just not loop over K and get about the same speed (actually this approach is independent of the size of K so for large K it is quite a bit faster than yours; try K=50):
for(j in 1:nTraps)
{
dSq.s2x[i,j] <- (s[i,1]-x[j,1])^2 +
(s[i,2]-x[j,2])^2
lambda[i,j] <-
lam0*exp(-dSq.s2x[i,j]/(2*sigma^2))*z[i]*opersum[j]
y[i,j] ~ dpois(lambda[i,j])
}
with
jd.fastest <- list(y=apply(yaug,c(1,2),sum), M=M,
opersum=rowSums(oper),
z=c(rep(1, n0), rep(NA, M-n0)),
xlim=xlim, ylim=xlim,
x=x, nTraps=nTraps, nOcc=nOcc)
As Ben summed it up nicely a few days ago: "I wonder how many months of total computation time has been wasted in these models to date by looping over K, especially for camera trap applications with many sampling occasions."
Best,
Mathias
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23JtTbAQWtod%2B1GnWm1Wvn8YVN58yD8uTpxrpyk5ZHBR5mw%40mail.gmail.com.
Hi All,
I’ve used the Richard trick in Nimble saving 2X aprox.
Regards,
José
=======
code <- nimbleCode({
lam0 ~ dunif(0, 3)
sigma ~ dunif(0, 2)
psi ~ dbeta(1,1)
for(i in 1:M) {
s[i,1] ~ dunif(xlim[1], xlim[2])
s[i,2] ~ dunif(ylim[1], ylim[2])
z[i] ~ dbern(psi) ## Provide the first n0 as data, ie z[i]=1
dSq.s2x[i,1:nTraps] <- (s[i,1]-x[1:nTraps,1])^2 + (s[i,2]-x[1:nTraps,2])^2
for(j in 1:nTraps) {
for(k in 1:nOcc) {
lambda[i,j,k] <- lam0*exp(-dSq.s2x[i,j]/(2*sigma^2))*oper[j,k]
}
}
}
for(i in 1:n0) {
for(j in 1:nTraps) {
for(k in 1:nOcc) {
y[i,j,k] ~ dpois(lambda[i,j,k])
}
}
}
for(i in (n0+1):M) {
zeros[i] ~ dpois(sum(lambda[i,1:nTraps,1:nOcc])*z[i])
}
N <- sum(z[1:M])
})
Time: 4.33509 mins
#==================
library(nimble)
## define the model
code <- nimbleCode({
lam0 ~ dunif(0, 3)
alpha1 ~ dnorm(0,.1)
sigma <- sqrt(1/(2*alpha1))
psi ~ dunif(0,1)
for(i in 1:M){
z[i] ~ dbern(psi)
s[i,1] ~ dunif(xlim[1],xlim[2])
s[i,2] ~ dunif(ylim[1],ylim[2])
d[i,1:nTraps] <- pow(s[i,1]-x[1:nTraps,1],2) + pow(s[i,2]-x[1:nTraps,2],2)
for(j in 1:nTraps){
p[i,j,1:nOcc] <- lam0*z[i]*exp(- alpha1*d[i,j])*oper[j,1:nOcc]
for(k in 1:nOcc){
y[i,j,k] ~ dpois(p[i,j,k])
}
}
}
N <- sum(z[1:M])
})
Time: 9.071667 mins
#==================
--
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23JuCJOaYovp3fqge2pVOU4LsQpAe3dK5VDCf4Q%2BKigJ4aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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 post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAH9coKatSWBeLLgYN2%2BMMiB3XLVpkSkvquOoXr3ao908FNY_AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Richard Chandler
Assistant Professor
Warnell School of Forestry and Natural Resources
University of Georgia
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
spatialcapturerec...@googlegroups.com.
--
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23JuCJOaYovp3fqge2pVOU4LsQpAe3dK5VDCf4Q%2BKigJ4aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAH9coKatSWBeLLgYN2%2BMMiB3XLVpkSkvquOoXr3ao908FNY_AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Richard Chandler
Assistant Professor
Warnell School of Forestry and Natural Resources
University of Georgia
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerecapture+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerecapture+unsub...@googlegroups.com.
Hi Andy,
Of course! These are the Nimble versions of Richard's code (faster: fasterSCR_Y.R; Y; normal: fasterSCR_N.R).
Regards,
José
De: hmec...@googlegroups.com [mailto:hmec...@googlegroups.com]
En nombre de Jeffrey Royle
Enviado el: miércoles, 16 de mayo de 2018 11:30
Para: spatialcapt...@googlegroups.com
CC: hmecology: Hierarchical Modeling in Ecology <hmec...@googlegroups.com>
Asunto: Re: Speeding up data augmentation in BUGS
hi all, this seems like a big deal, thanks a lot Richard and everyone for the discussion!
--
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23JuCJOaYovp3fqge2pVOU4LsQpAe3dK5VDCf4Q%2BKigJ4aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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 post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAH9coKatSWBeLLgYN2%2BMMiB3XLVpkSkvquOoXr3ao908FNY_AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Richard Chandler
Assistant Professor
Warnell School of Forestry and Natural Resources
University of Georgia
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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 post to this group, send email to
hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAE%2BwgF3Youe3ZhqpDjBnQeAV25oH-LyGDSsMcg7Chuz2bPAGzQ%40mail.gmail.com.
--
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23JuCJOaYovp3fqge2pVOU4LsQpAe3dK5VDCf4Q%2BKigJ4aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAH9coKatSWBeLLgYN2%2BMMiB3XLVpkSkvquOoXr3ao908FNY_AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Richard Chandler
Assistant Professor
Warnell School of Forestry and Natural Resources
University of Georgia
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerecapture+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerecapture+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAE%2BwgF3Youe3ZhqpDjBnQeAV25oH-LyGDSsMcg7Chuz2bPAGzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
*** 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 (2015)
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/HE1PR0101MB2265894A129088C8E318B34292920%40HE1PR0101MB2265.eurprd01.prod.exchangelabs.com.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerecapture+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Spatial Capture-Recapture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialcapturerecapture+unsubscr...@googlegroups.com.
--
*** 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 (2015)
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CADy23Js0AAkN0VLhSeUzYb2Ak5zGSHx-spP2fAE9x3NJUEDXVw%40mail.gmail.com.
--
*** 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/334456a4-de2b-4ff3-b1cf-e7192d01ea7d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/CAG8F9nG3vVoJyX4A8usEtfW8pAOp%3Dg1YHhr0T8aHALKfC_gJUA%40mail.gmail.com.
--
*** 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/b5a5abf0-768a-4590-99a1-33eb72780a64%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to hmec...@googlegroups.com.
Thank you very much for evaluating this. The model is running fine and I wouldn't have caught this. I can't figure how to marginalize N out of the model but it should be possible to condition on the realized N. As z[i] conforms to 'real' groups in the available population N, then sum(z[i]) should be the realized N and then psi=sum(lambda)*phi/sum(z[i]] would refer to the data augmentation rate in the available population....I think.On Wed, May 20, 2020 at 7:01 PM Richard Chandler <richard....@gmail.com> wrote:Yeah, it would be much harder to use the multinomial formulation if you have individual covariates such as group size. Unfortunately, I don't think the data augmentation formulation that you suggested would accomplish what you're after.Imagine the availability model is N(j)~Bin(M, phi=1). In that case, it should be true that N(1)=N(2)=...=N(J). However, the formulation you mentioned would simply set the expected values of N equal to one another. The realized values of N would be conditionally independent, and this would result in confounding between phi and the detection parameters. I think you would need to condition the detections on the realized values of N (not the expected values of N), or marginalize the N's out of the model.
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/baff1469-6cc4-4bb8-a3df-8a7d8462c128%40googlegroups.com.
> To unsubscribe from this group and stop receiving emails from it, send an email to hmec...@googlegroups.com.
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/46968d84-d02f-474f-b8ae-028e60c80121%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/46968d84-d02f-474f-b8ae-028e60c80121%40googlegroups.com.