Old RStan Instruction

Outline

For reference, we keep here the old instructions for RStan. They may still work on some plate-forms. But we are now migrating to cmdstanr.

Installing (old RStan method)

There are two main steps to install Stan:

  1. Configuring a C++ Toolchain
  2. Installing RStan

Running Stan (old RStan method)

Download the following templates which you can use as a starting point for either R script or notebook.

For example:

require(rstan)
fit = stan(
  seed = 123,
  file = "../w08_mcmc1/beta_binomial.stan",  # Stan program
  data = list(n=3, k=3),        # named list of data
  iter = 1000                   # number of samples to draw

Extracting draws

samples = extract(fit)

Histograms with bayesplots

mcmc_hist(fit)