Questions tagged [stan]

Stan is software for Bayesian estimation using the No-U-Turn sampling (NUTS) algorithm instead of the simpler Gibbs sampling (BUGS).

Stan is software for Bayesian estimation using the No-U-Turn sampling (NUTS) algorithm instead of the simpler Gibbs sampling (BUGS). It is specially useful for models that have highly correlated posterior distributions and thus where the Gibbs sampler would take too long to converge.

It also implements algorithms such as BFGS to solve optimization problems.

Stan is open-source. It can be used as stand-alone software, or can interface with either R (via RStan) or Python (via PyStan).

To understand the contrast between the MCMC sampling algorithms, see:

  1. Can someone explain Gibbs sampling in very simple words? (A very helpful CV thread.)
  2. Hoffman, M.D. & Gelman, A. (2011). The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo. http://arxiv.org/abs/1111.4246v1
236 questions
22
votes
2 answers

How to summarize credible intervals for a medical audience

With Stan and frontend packages rstanarm or brms I can easily analyze data the Bayesian way as I did before with mixed-models such as lme. While I have most of the book and articles by Kruschke-Gelman-Wagenmakers-etc on my desk, these don't tell me…
21
votes
2 answers

Parameters without defined priors in Stan

I've just started to learn to use Stan and rstan. Unless I've always been confused about how JAGS/BUGS worked, I thought you always had to define a prior distribution of some kind for every parameter in the model to be drawn from. It appears that…
JoFrhwld
  • 2,247
  • 3
  • 20
  • 22
19
votes
1 answer

Stan $\hat{R}$ versus Gelman-Rubin $\hat{R}$ definition

I was going through the Stan documentation which can be downloaded from here. I was particularly interested in their implementation of the Gelman-Rubin diagnostic. The original paper Gelman & Rubin (1992) define the the potential scale reduction…
14
votes
1 answer

Hamiltonian Monte Carlo and discrete parameter spaces

I've just started building models in stan; to build familiarity with the tool, I'm working through some of the exercises in Bayesian Data Analysis (2nd ed.). The Waterbuck exercise supposes that the data $n \sim \text{binomial}(N, \theta)$, with…
Sycorax
  • 76,417
  • 20
  • 189
  • 313
14
votes
2 answers

How can I model a proportion with BUGS/JAGS/STAN?

I am trying to build a model where the response is a proportion (it is actually the share of votes a party gets in constituencies). Its distribution is not normal, so I decided to model it with a beta distribution. I also have several predictors.…
Joël
  • 163
  • 2
  • 8
12
votes
2 answers

Why are there recommendations against using Jeffreys or entropy based priors for MCMC samplers?

On their wiki page, the developers of Stan state: Some principles we don't like: invariance, Jeffreys, entropy Instead, I see a lot of normal distribution recommendation. So far I used Bayesian methods that didn't rely on sampling, and was kind of…
wirrbel
  • 565
  • 3
  • 15
10
votes
2 answers

Does stan do predictive posteriors?

Does stan (in particular, rstan) have built-in facilities to generate predictive posterior distributions? It's not hard to generate the distribution from the stan fit, but I'd rather not reinvent the wheel.
Anon
  • 101
  • 1
  • 4
10
votes
1 answer

How to plot prior distributions in Stan?

I tried to run a Stan model without data to get plots for the prior distributions. However, this does not seem to be possible, I get an error message about my model not containing samples. So, is there a way for getting at the prior distributions?…
Jens Kouros
  • 885
  • 5
  • 16
9
votes
1 answer

Where do I declare prior parameters in Stan?

I am fitting several multi-level hierarchical regression models using rstan. Each of these models has a unit information prior over the top-level distribution. The unit priors' parameters were originally store in an R list. My questions are: Do I…
Brash Equilibrium
  • 3,565
  • 1
  • 25
  • 43
9
votes
2 answers

Bayesian lighthouse location estimation

I am trying to learn Stan in R and as a fun challenge I am trying to estimate the location of a lighthouse based on the observed flashes. But the models I tried do not converge (Rhat != 1) or have estimated parameters with a large spread. The…
Pieter
  • 1,847
  • 9
  • 23
9
votes
0 answers

Horseshoe priors and random slope/intercept regressions

I'm interested in using the horseshoe prior (or the related hierarchical-shrinkage family of priors) for regression coefficients of a traditional multilevel regression (e.g., random slopes/intercepts). Horseshoe priors are similar to lasso and…
9
votes
1 answer

What is the difference between R hat and psrf?

In convergence diagnosis in WinBUGS/JAGS/Stan, there are different statistics reported for each variable. In WinBUGS/Stan, Rhat ($\hat{R}$) is reported. In JAGS with the runjags package, psrf (Potential Scale Reduction Factor) is reported (it is…
Tomas
  • 5,735
  • 11
  • 52
  • 93
8
votes
1 answer

Divergent transitions in Stan

Intuitively, what does the warning "There were 214 divergent transitions after warmup." mean? I understand that the samples obtained are useless, and that increasing adapt_delta, and max_treedepth, and lowering stepsize can help. In addition,…
JLee
  • 813
  • 3
  • 12
8
votes
1 answer

What is the purpose of "transformed variables" in Stan?

I find references to transformed values in the Stan Reference and User Guides, and example code but no clear tutorial explanation. I'd be grateful for a link. Michael Betancourt, in his Stan Modeling Language lecture, says this: "The transformed…
John Strong
  • 251
  • 3
  • 6
8
votes
1 answer

Coding resources: Accessible introductions to Bayesian Structural Time series?

Hey, all. I am asking this question in not necessarily a "subjectively recommend something for me" approach, but with a clear focus on just an accessible beginner's reference. My situation is I have been learning the theory behind Bayesian…
1
2 3
15 16