Aware! The code about splines adds the intercept twice too. One time in calling bs
and another time in a0. B has full rank checked by rankMatrix.
To model the random walk just do:
gamma_raw ~ normal(0, 1);
gamma = cumulative_sum(gamma_raw) * tau;
If you want smoothing, I’d go instead with the mgcv package and specify bs=“ts” or bs=“ad”.
See: https://stats.stackexchange.com/questions/305338/adaptive-gam-smooths-in-mgcv
If I’m not mistaken the variance for gamma[1] → Infinitive. Does an intercept makes sense?
I’d say no and define a long tailed prior to the variance of the first element of the random walk.
And yes, I wouldn’t specify the random walk like you cited.