I'm soooo confused. I thought you were adamantly opposed
to having to loop over the iterations, as in:
n_iter <- 10
for (i in 1:n_iter){
generated <- list(delta=array(NA, c(n_sims,K)), log_weight=rep(NA, n_sims))
for (n in 1:n_sims) {
And I'm really surprised given your opposition to writing
data = c("x", "y", "N") that you'd be OK with this:
vector extrap_impsampling_rng(int J_prime, int T_prime, int K, vector y_prime_bar,
vector x_prime, vector mu_delta_p, matrix Sigma_delta_p, vector mu_delta_g,
matrix Sigma_delta_g, real df_g, int J_tilde, vector mu_a, vector sigma_a, real sigma_y) {
...
which seems just the kind of duplication you wanted to avoid.
I'd like to add tuple types to Stan so we can have proper structs.
I should probably stop looking at and responding to all these e-mails
and spend more time adding to the Stan language!
- Bob
> On Apr 16, 2015, at 10:53 AM, Andrew Gelman <
Gel...@stat.columbia.edu> wrote:
>
> Hi, attached is my code. I don’t know whether this is helpful, you can feel free to ignore it. I ended up writing the “generated quantities block” as a function and passing the information in that way. This actually ended up being cleaner than using generated quantities, because it meant that I din’t have to have such a big pile of data coming into the main Stan program. The only awkward thing was that a Stan function can return only one thing, so I had to hack it by concatenating two Stan variables into a single vector output, then untangle them at the other end.
> A
>
> <extrap.R><testify.R><stan.R><extrap_impsampling_function.stan><data_fit.stan>