Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccf only return half cross-correlation coefficient and thus sensitive to input order #8590

Open
langchen2022 opened this issue Dec 21, 2022 · 2 comments

Comments

@langchen2022
Copy link

Describe the bug

I use ccf to calculate cross-correlation coefficient between two time-series arrays, but found that only half correlation was given (if I'm using it correctly). Then the maximum coefficient is sensitive to the order of the two input arrays, as the peak correlation coefficient may not be capture in one order.

Code Sample, a copy-pastable example if possible

I have a matrix called "all wav", and I want to calculate the cross-correlation coefficient for two of them. Here are what I got in different order:
image

Expected Output

Here is what I got directly with numpy.correlate:
image

Output of import statsmodels.api as sm; sm.show_versions()

statsmodels

Installed: 0.13.5

Required Dependencies

cython: Not installed
numpy: 1.22.4
scipy: 1.9.1
pandas: 1.4.4
dateutil: 2.8.2
patsy: 0.5.3

@josef-pkt
Copy link
Member

I think we can add a keyword option to return the two-sided ccf/ccovf.

When we started this part, then we only looked at causal filters with one-sided correlation (coming from time series analysis in econometrics).
Some of those functions were or are just wrappers around scipy.signal functions that translated those to tsa in econometrics.

@langchen2022
Copy link
Author

Now I can see why it's set up this way.
I wanted to use ccf instead of scipy.signal.correlate because I'm more interested in the normalized coefficient and I don't have to calculate myself :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants