Behrens' Bayesian Learner Model : How to share parameters between steps?

Yes, I am happy to share my code. I considered this for hours. The only reason I am not to do this is that it may be an impolite behavior that shares Stan code in PyMC3 community.

Here is my code:

data {
  int<lower=0> N; // trial number
  int y[N];
}

parameters {
  real k;
  real<lower=0.1, upper=0.9> r[N];
  real v[N];
}

model {
  k~uniform(-10,10);
  for(t in 1:N){
    if(t == 1){
      v[t] ~ uniform(0,100);
      r[t] ~ normal(0.5,0.3);
    }
    else{
      v[t] ~ normal(v[t-1],exp(k));
      r[t] ~ beta_proportion(r[t-1],exp(v[t]));
    }
    y[t] ~ bernoulli(r[t]);
  }
}
1 Like