Open lorenze3 opened 10 months ago
Oops -- I've now realized this seems to be about the number of terms in the assignment and not character length.
but it seems to be possible to work around it by breaking the assignment into two formulae --
alist(
big_model <- <20 terms like b_varname * varname >,
big_model<- big_model[i] + <remaining terms like b_varname *varname>
)
although I'm not 100% sure that this code (which does compile and run) results in the same sampling as not having it broken into two pieces
Interesting bug.
To workaround, use multiple symbols:
big_model <- [stuff] big_model2 <- big_model + [more stuff]
Thanks for the response! And, dang it, I shoulda thought of that.
I really appreciate the work both in educating on bayesian regression in such an entertaining way and in making stan so easy to use from R.
I'm abusing the rethinking package to avoid writing macros to write stan code (because someone already did that, right?). I'd use brms for my problem except I want per-coefficient lower bounds (ie some coefficients to be non-negative, but not all). At any rate, I've got a very long deterministic assignment. Once I add 'too many' terms to the model, ulam() breaks up the assignment into two lines, but not in a way that is syntatically correct.
here's an attempt at a reproducible example:
If you check the resulting stan code in fff$model, you'll see that big_model[i] is split into two lines, but the first one ends in a +, and the second line does not increment the existing big_model[i]. I'll paste that code in below.
for my immediate purposes I'm just going to use shorter variable names, but this might be a simple fix? Changing the big_model assignment to
seems to work (ie the sampling runs instead of generating an error), in case there is some character limit in R or Stan that is hard to work around.