Estimation of effectve size in stan code


#1

Hi all,

I would like to estimate the correlation length (or effective size) of the a model’s residuals within the transformed_parameters block.

Any idea how to do this efficiently without [rewriting] an autocorrelation function in stan ?

Thanks

Pascal


#2

Unfortunately we don’t have a built-in autocorrelation function in Stan so you would have to write the code. My hunch is that this has probably come up before though, so you may be able to search for an example where someone has already efficiently coded it up in a Stan program. It’s something we should probably consider adding to the language though.


#3

Thanks Jonah ! I’ll sneak around…

I +1 to your suggestion of adding it to Stan ;-)


#4

I recommend opening an issue on GitHub with a feature request!

Jonah


#5

There’s already a PR, https://github.com/stan-dev/stan/pull/2477 and
associated discussion here
Analysis API


#6

Do you need the result as part of the log density? If not, then it’s much more efficient to do these kinds of transforms in the generated quantities block.


#7

That’s for analysis code on the outside. The question is about calculating the autocorrelation of residuals within the model itself.


#8

Yes, I would like to use it in a regularization prior.


#9

We’ve been talking for a long time about adding the FFT code with derivatives to make it possible to do efficient autocorrelations, but we’re still hung up on how to represent imaginary numbers. If we only exposed an autorcorrelation function, that problem would go away.