Help needed for a constraint parameter problem

Hello all,

Could you please help me to set the problem in rStan. Specifically, I want to know to how to write the .stan code for this problem. Many thanks for your help.

My observed data have a response vector Y and three predictor vectors X1, X2 and X3. Suppose that I want to fit a linear model, E(Y|X1, X2, X3)=beta_0+beta_1X1+beta_2X2+beta_3X3, with normal(0, sigma^2) measurement error.

The priors and the constrains are as follows: beta_0~Uniform(-M, M) (denoted by U(-M, M)), beta_1~U(-M, M), beta_2~U(-M, M), beta_3~U(-M, M), and log(sigma2)~U(-M, M), for some given M. Also, beta1+beta2+beta3=0.

The joint prior on beta_1, beta_2, beta_3 can also be written as follows:
z~discrete uniform distribution over indices 1, 2, 3.
For r=1, 2, define [z+r]=z+r if z+r<=3 else [z+r]=z+r-3.
beta_z~U(-M, M), beta_[z+1]~U(max(-M,—M-beta_z), min(M, M-beta_z))
beta_[z+2]=-(beta_z+beta_[z+1]).

See here: Defining a zero-sum constraint

Thanks Mike.