Running Statistics - xcorr and mad

Hello,
I apologize as this question may have more to do with stats then matlab but hoping I can get some help.
I have two columns of data that are about 1600 by 1, they are knee joint angles. Lets just say one is varible a and one is varible b. They are angles from the same knee from the same trial but using two different methods. I want to compare the methods.
1. First, I want to run a crosscorretional to examine the wavefroms. So my code reads, [r lag]=xcorr(a,b,'coeff'); this gives me the normalized r value and the lag at each data point.
If I want to run the cross correlation to examine the relationship between a and b did I do this correctly, is that what the code is doing?
Also, this is more of a stat question (trying to improve my understanding): How do you determine significance for cross correlation and can you provide example of the code in matlab?
2. I also want to get the absolute mean difference of the two methods. I was having trouble finding the code for doing the absolute mean diff on two sets of data; I have mad(a,b) in my code right now.
Is this the correct function to calculate abs mean diff, and is that the correct way to do it (a,b). Is it giving me the average mean diff between data set a and data set b?
Also how do I get significance for abs mean diff, and if possible could someone provide example of how the code would look?
3. I also want to do a bland-altman plot in matlab of a and b. I know how to make it from stratch and can write the code for it if nesscary, but was wondering if matlab has a built in function I was missing to create a bland-altman plot and what the code would look like if it does?
I know time is very vaulable and anyone that takes time to anwser and help me learn, I sincererly appeciate it!!
Thank you!

8 Comments

If you mean test of agreement by comparing methods, I don't get why you are using cross-correlation. As you also mentioned, Bland-Altman plot would work for you (here).
The cross corr is more to examine the relationship; This way if the mean diff is mimial and the agreement is say moderate I can tell if the patterns of the angles over time follow the same wavefrom. If they do, in some cases moderate agreement may be okay, if they are not following the same pattern then the moderate agreement is not acceptable just provides more insight is all; I am just trying to make sure my code is correct and trying to figure out how to test for sigificance. Thank you for the link to the bland-altman;
From your use of the term "waveform", it sounds like the 1600 values of a and b are taken at successive time points. If that is right, can you post a plot with two lines: a versus t, and b versus t, so we can see what the data look like? Or, if that doesn't make sense, maybe just a post a scattergram of a versus b?
Ive J
Ive J on 7 Feb 2021
Edited: Ive J on 7 Feb 2021
I still don't get the applicability of cross-correlation to your question. Even if it's for relationship, why just don't use a regression line or simple Pearson correlation? Just out of curiosity, how does measuring the relative lag of these two time series data help you to understand their agreement? Having said that, keep in mind that correlation or association does not do exactly what an agreement test does like Bland-Altman, take a look here.
Here is a picutre of a vs time and b vs time on the same plot (hopefuly this is what you were asking for) .
I am looking for help on how to determine signifacnce for the cross correlation, and is it possible to run mad between to varibles in matlab? would anova also be helpful?
Yes, that is one of the pictures I had in mind. It seems obvious that when a goes up (down), b does the same. If you want a significance level to support that statement, you can just use 'corr' command as Ive J suggested.
Obviously the blue line is above the orange one, so the two measures are not numerically equal, even though they show the same pattern. You could document that with a simple 'regress' command (predicting a from b, or vice versa), as Ive J also suggested.
To get the mean absolute difference, which you asked about earlier, I would think you would simply compute
mad = mean(abs(a-b));
Maybe you have other questions as well, but it really seems to me that the above picture nicely captures all of the information in your dataset.
Hi everyone,
I aplogize about all the questions;
Wanted to thank you all for the help, the discussion has also been very helpful. I do think the graph is a nice representation the only issue is I have x,y,and z angles per knee (R/L), per 10 subjects, per 6 trials a subject; So I may do a graph of one subject with normalized time but will be too much to do for all subjects;
As for the cross correlation the lag isnt really important to me, it is the R vaule. A pearson correlation is like .99 but it's not very helpful as it's showing the linear realtionship. That is way I wanted to use the corsscorrelation as it will examine the wavefrom (frequecncy, amplitiude). I am just trying to figure out how do I get sig for the cross correlation coefficeint, does matlab have a function for it (like it does for regular correlatio e.g. [r p]=corrcoef(data)), or would code could I write to find it;
Would doing a one tailed t-test for the mean diffs (diff compared to zero) be acceptable to find sig for the abs mean diff;
Also how to you take a 1600 by 1 and add another 1600 by one to the end of it?
Thank you all!!

Sign in to comment.

Answers (0)

Tags

Asked:

on 6 Feb 2021

Commented:

on 12 Feb 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!