10

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? Maybe it's possible to run Stan without the sampler?

Jens Kouros
  • 885
  • 5
  • 16

1 Answers1

7

As my previous answer was deleted, here is a more explicit one, with an example using a simple sampling from the prior:

library(rstan)

model = "
parameters {
  real p;
}
model {
  p ~ normal(1,3);
}
"

fit = stan(model_code = model, 
           pars = c('p'),
           control=list(adapt_delta=0.99, max_treedepth=10),
           iter = 5000, chains = 1, 
           warmup = 1000, verbose=FALSE)

print(fit)

with output:

Inference for Stan model: a067aa7e9d60dcf5fa2c08c3db339374.
1 chains, each with iter=5000; warmup=1000; thin=1; 
post-warmup draws per chain=4000, total post-warmup draws=4000.

      mean se_mean  sd  2.5%   25%   50%   75% 97.5% n_eff Rhat
p     1.02    0.07 3.0 -4.84 -1.02  1.01  3.07  6.83  1607    1
lp__ -0.50    0.02 0.7 -2.47 -0.66 -0.23 -0.05  0.00  1346    1

Hope this helps...

Pascal
  • 312
  • 1
  • 6