autocorr vs autocorrplot
See original GitHub issueThis issue is actually more of a question, it is quite possible that we can resolve this without actual code changes. arviz
maintains autocorr
code in stats.diagnostics._autocorr
and plots.autocorrplot
(both are inherited from the pymc3
codebase). Both here and in pymc3
the way the autocorrelation is computed differs, in particular plots.autocorrplot
uses np.correlate(y, y, mode=2)
whereas stats.diagnostics.autocorr
uses fftconvolve(y, y[::-1])
. Is there a reason why plots.autocorrplot
does not simply use stats.diagnostics.autocorr
under the hood?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Question about autocorrelation_plot result vs autocorr result
You are using both functions correctly, but... Autocorrelation_plot uses a different way of calculating autocorrelations then autocorr() ...
Read more >How to interpret autocorrelation plot in MCMC - Cross Validated
First of all: if memory and computational time for handling the MCMC output are not limiting, thinning is never "optimal".
Read more >The BCHOICE Procedure - ODS Graphics - SAS Help Center
ODS Graph Name Plot Description Statement and Option
ADPanel Autocorrelation function and density panel PLOTS=(AUTOCORR DENSI...
AutocorrPanel Autocorrelation function panel PLOTS=AUTOCORR
AutocorrPlot Autocorrelation function plot PLOTS(UNPACK)=AUTOCO......
Read more >arviz.plots.autocorrplot — ArviZ 0.12.1 documentation
Source code for arviz.plots.autocorrplot. """Autocorrelation plot of data. ... """Bar plot of the autocorrelation function for a sequence of data.
Read more >Plots — PyMC3 3.11.5 documentation
plots module are available through pymc3.<function> or pymc3.plots.<function> , but for their API documentation please refer to the ArviZ documentation ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ooh, maybe the opposite of historical reasons. I believe I was porting this to use
xarray
, and wanted to avoidplt.acorr
, which used to be used: it does not add much to the code complexity, but allows a lot more flexibility in signature and styling. I did not even noticeaz.diagnostics._autocorr
!Checking out benchmarks and actual values, it looks like the two functions are not identical, but are quite close where there is actual autocorrelation, and that
az.diagnostics._autocorr
is much faster for large inputs, and modestly slower for small ones. I attached the code below. Tryingnp.correlate
on 1e6 points scares my computer.@junpenglao yes it is from pymc3. I noticed that it gives the same results as pystan. Thanks for providing background on the implementation and theory. I think it makes sense to use this method to compute autocorrelation in
az.plots.autocorrplot
as well. I will provide a pull request for that tomorrow.