# Rounding parameters to define rows in 'look up table'

Dear all,

Is it possible to somehow round the value of a parameter to use it to index a look up table?

I am trying to build a regression model in which however I have an additional parameter that determines the value of the regressor. As an example, I want to measure binary choices people make (to take an immediate value or a future one) as a function of the size of the ‘future value’; but how high this ‘future value’ is depends on their mental model and I want to fit an extra parameter to account for how they compute this.

The technical problem I’ve now run into is that computing the future value is prohibitively long within the Stan model. What I can do instead in Matlab is create a look up table that computes the future value for all possible settings of the parameter (bounded between 0 and 1). This is much faster as I can then re-use this value across different participants and different measurements within participants. I could make the steps as small as I want, say 0:0.01:1 and store this lookup table. Can I use parameters from the model (they would need to be rounded to whatever precision I have in the look up table) to index the look up table or does that create a problem for fitting the model appropriately?

Many thanks
Jacquie

Can you fit a coarser grid externally and interpolate in Stan? A lookup table breaks autodiff but interpolation doesn’t have to

Ok, yes, I can interpolate in Stan. Thank you so much for your help!!
To understand this: so it’s basically because the problem would be that if say the parameter is 0.011 0.012 the value that would produce would be exactly the same if I use a look up table with spacing 0.01. Whereas if I interpolate, it will be ever so slightly different?

Yes, but what’s more important is that the value of that slope becomes an independent part of the calculation. Most of the math functions that are approximations have an error in both the value and slope under 1e-8, when the error is higher the metropolis acceptance probability goes down and it can break the adaptation algorithm