Can I add priors to intermediate variables?

As you will see in my question, I’m not an expert in statistics. But I hope you can provide some guidance.

Let’s assume I have this model:

y = ax + b

a = \frac{10(c + d)}{3}

The parameters here are b, c and d. Thus, I would specify priors for them.

Could I also specify a prior a, given that it is an intermediate calculation that depends on c & d?

Please don’t mind the model itself. I’m more concerned abouth whether there are cases where we could add priors to intermediate variables.


Yes, you can declare and define ‘a’ in the transformed parameters block and add a prior on a in the model block. However, note that having a prior on c & d implies a prior in a, and I’ve never understood what it implies logically when you add an additional Explicit prior in a itself in this way. I’ve only seen it done in a handful of circumstances, so while it’s permitted by the language, you’ll want to work out whether it makes sense for your case.

1 Like

Long story short, for c & d, I don’t have any information, so priors are quite flat. But I have some sense where a could land. Does that make sense?

Ah, yes, and that makes sense to me as a scenario where one would want to do it this way.

See if this discussion on @andrewgelman’s blog addresses your question.


It does, thanks.

1 Like