Hi I would like to implement a random-walk prior for a parameter vector \gamma that is constraint to be non-negative. I came up with the following code

```
parameters {
row_vector[m] gammas_raw;
real<lower=0> tau;
}
transformed parameters {
row_vector<lower=0>[m] gammas;
{
row_vector[m] loc_gammas;
loc_gammas[1] = gammas_raw[1];
for(i in 2:m)
loc_gammas[i] = loc_gammas[i-1] + gammas_raw[i] * tau;
gammas = fabs(loc_gammas);
}
}
model {
gammas_raw ~ normal(0, 1);
tau ~ cauchy(0,1);
}
```

This essentially constructs a random-walk but then takes the absolute value.

Alternatively you could construct a process that behaves like a random walk but in case it would cross â€ś0â€ť towards the non-negatives it would behave differently. In mathematical terms: Suppose \gamma_i>0 is the current value and the increment is \delta_i<0 s.t. \gamma_{i+1} = \gamma_i + \delta_i < 0. In this case set \gamma_{i+1} = -\delta_i - \gamma_i >0. Thus in general \gamma_{i+1} = \vert \delta_i + \gamma_i\vert.

Are there any arguments against or in favour of the two approaches? Has this been studied elsewhere and are there other choices of random walk priors constrained (conditioned) to be non-negative?