--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/xVKzZGexHEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
Thanks for doing the legwork and writing in.
How are you calculating n_eff? Stan is much more conservative
than JAGS (uses cross-chain information and also longer-term correlations)
and there can be huge differences in estimated effective sample size.
How big is the data set? You'll find that HMC has more
of an advantage with more dimensions.
Marginalizing out parameters almost always helps with efficiency. Especially
discrete ones that are difficult to mix with Gibbs sampling.
The Stan code isn't very efficient as written.
for(j in 1:4){
b0[j]~normal(0, 10);
b1[j]~normal(0, 10);
}
Vectorize to
b0 ~ normal(0, 10);
Same for the other distributions.
This
sigmayearphi~uniform(0,3);
doesn't match its declaration, which should include the upper bound:
real<lower=0, upper=3> sigmayearphi;
The model should define a finite log density for any parameter
meeting the constraints. With only lower=0, sigmayearphi = 4 satisfies
the constraint, but produces a -infinity log density.
You can pull the first line above the loop:
for (k in 1:last[i]) {
if(k>1) increment_log_prob(log(phi[i, k-1]));
and just use
increment_log_prob(log(phi[i, 1:(last[i] - 1)]));
Those were the things that jumped out at me, but there may be
more if you can find expressions that are repeated --- you don't
want to every apply log or inv_logit or any other expensive function
to the same argument twice.
- Bob
> On May 3, 2016, at 6:22 PM, Cole Monnahan <mon...@uw.edu> wrote:
>
> I've been comparing the speed of Stan vs JAGS on some ecological models. In reading the book
>
> Korner-Nievergelt et al (2015). Bayesian Data Analysis in Ecology Using Linear Models with R, BUGS, and Stan. (link to website with code)
>
> I ran across example 14.5, which is a mark-recapture model that uses a "trick" to avoid discrete latent parameters by integrating them out with a while loop (the parameter chi, which represents the probability of never seeing the animal again). The authors found it was substantially more efficient than WinBUGS. However, when I coded it myself in JAGS I incorporated this trick instead of modeling the discrete states directly, making the parameterization identical. And to my surprise JAGS was more efficient (minESS/time), albeit not that much. To me this suggests that it was removing the need to track the states directly that was the major difference.
>
> I was quite surprised by that, and wondering if there are any computational improvements that can be made to the Stan model.
>
> I looked through the manual and thought maybe trying to use ragged arrays. The variable `last` represents the last time period the animal was seen, effectively determining the size of the loop over time for that animal. But it is not clear to me how to implement them, or even if that is something worth trying in this case. I also considered using the "ones trick" from BUGS so that the likelihood statements could be vectorized, but wasn't sure how to wrangle the code to accomplish this.
>
> Does anyone have any thoughts? Or is this just not the type of model that Stan would be expected to outperform JAGS?
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/xVKzZGexHEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
| model | Npar | max.cor | JAGS | Stan | Stan/JAGS |
| swallows_nc | 177 | 0.800 | 0.421 | 0.098 | 0.230 |
| swallows | 177 | 0.889 | 0.570 | 0.063 | 0.110 |
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<data.RDS><run_model.R><swallows_nc.jags><swallows_nc.stan><sims.ind.RDS>
<model_comparison_qqplots.pdf>
<model_comparison_convergence.png>