difficulty interpreting outputs of movcorr
4 views (last 30 days)
Show older comments
im using movcorr from the file exchange to calculate moving correlation between two time series.
I have 2 time series, interpolated onto the same dt, which contain 1534 datapoints. I have used movcorr to calculate a moving correlation with a 100 point window. When I do this, both r and p contain 1534 points, so surely the window is not being applied correctly as I expected an output of 1 correlation coefficient every 100 points?
I have tried to look at the documentation on the file exchange but I am having difficulty intepreting this output.
k = 100;
[r, p] = movcorr(data_1_interp,data_2_interp,k);
0 Comments
Accepted Answer
Ronit
on 28 Aug 2024
Hello CG,
The function movcorr calculates the correlation coefficient for each point in the time series using a sliding window of specified length (in your case, 100 points). This means that each point in the output arrays r and p represents the correlation coefficient calculated over a window centred at that point, hence why you get a result for each of the 1534 points.
If you expected an output of one correlation coefficient every 100 points, you might consider modifying your approach. Here a suggestion:
After computing r and p, you can take every 100th value to get a reduced set of correlation coefficients.
downsampled_r = r(1:100:end);
downsampled_p = p(1:100:end);
I hope it helps with your query!
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!