Offset multiplier for arrays

This feels wonky, so maybe I’ve taken a misstep, but I wanted to check whether it’s possible to have a vector of offsets? In this case, I’d like N vectors of length J, with each dimension of the vector drawn from an independent distribution.

parameters {
  vector[J] mu;
  vector<lower=0>[J] sigma;
  vector<offset=mu, multiplier=sigma>[J] X[N];
}
model {
  for(i in 1:J}
    X[, i] ~ normal(mu[i], sigma[i]);
}

So if I’m reading the question & code right, every vector should have the same J offsets and multipliers? In that case, you just need to broadcast the offset & multiplier vectors to be arrays of length N:

parameters {
  vector[J] mu;
  vector<lower=0>[J] sigma;
  vector<offset=rep_array(mu,N),
         multiplier=rep_array(sigma,N)>[J] X[N];
}
model {
  for(i in 1:J)
    X[, i] ~ normal(mu[i], sigma[i]);
}
3 Likes

Nailed it - thank you!

1 Like