Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

  1. Do I pass the unit information prior parameters for a particular model from the list where the rest of the data is stored?
  2. Where do I declare these prior parameters? In the parameters block?


share|improve this question
up vote 6 down vote accepted

I would distinguish between the prior distribution and the parameters for the prior distribution. When I started with Stan, I would set the parameters to the prior distributions just as some values. So in the model step, I would have something like

model {    
     mu ~ normal(0, 1)
     y ~ normal(mu, s)

for a normal prior on the mean coefficient for the distribution of y.

However, as I've been using Stan more, I have tended to include them in the data step (i.e., the list you refer to where the rest of the data is stored). In this format, I would supplement the data step with

data {
    real mu_prior_1
    real<lower=0> mu_prior_2

and adjust the model step to something like

model {    
     mu ~ normal(mu_prior_1, mu_prior_2)
     y ~ normal(mu, s)

The main reason I've been doing this is because it makes it easier for me to change the priors without changing the rest of the Stan code.

share|improve this answer
This makes good sense programming-wise, and also philosophically. The prior parameters are, after all, a kind of "data". – Brash Equilibrium Apr 7 '14 at 21:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.