Difference between sampling and stan in fitting

I have a standard LDA model from the reference manual in the book.

I am wondering what is the differences between the following methods in fitting the model:

  1. sampling(…)
  2. stan(,)
  3. vb(…) Also, is that BBVI or CAVI?

rstan::stan() will compile the model and compute posterior samples, rstan::sampling() computes posterior samples given a model previously compiled with rstan::stan_model(). rstan::vb() will attempt approximate sampling (as opposed to full sampling achieved by rstan::stan() and rstan::sampling()).

1 Like

1 and 2 aren’t very different. Stan is a more general wrapper that takes a stan model, stan code, or a stan file, compiles the model if necessary, then calls sampling(). Sampling() [and vb()] take compiled stan models. So sampling() takes two explicit steps (compile the model, then sample it), stan() only requires one step (it compiles and samples).
You shouldn’t see any difference between sampling() on a stan_model, and stan() on a model file/string/precompiled model.