Help with map_rect and arrays of vectors

We are trying to use the map_rect function to run a user-defined function many times.
We defined the function as follows:
functions {
vector beta_pdf(vector alpha, vector[] beta, real[] x, int[] fakeout) {
// specify first value of vector of length 1 to make it “real”
real output = exp(beta_lpdf(x | alpha, beta[1])) * fabs(-1 + 2 * x[1]);
return [output]’;
}
}
We’re probably not using the function as it was intended; we don’t need an integer input, hence the unused “fakeout.”
We intend to pass in just one value for alpha and beta, and a vector for x.

We then attempt to call the function as follows:
map_rect(beta_pdf, alpha[i], beta[i], x, fakeout)

but the inputs have to be of the form:
function, vector, vector[], real[ , ], int[ , ]

We were able to make the second element happy by writing:
to_vector([alpha[i]])

But we cannot figure out how to turn the third input into an array of vectors.
Any help would be appreciated!

1 Like

Can you post the full model? It’s a bit harder to nail down without the types of the individual objects

1 Like