How do I compute point-by-point t tests between two 101 data point vectors?

I have two data vectors with 101 data points each. I want to run a t-test between the first elements of both vectors, between the 2nd elements, and so on. Here is a loop I wrote to run the 101 t-tests:
for i = 1:101
[h(i),pr(i)] = ttest(AvgAngle_r,AvgAngle_ASDr(i),'Alpha',0.05);
end
I get 101 h and p values, but I want to make sure that this is accurate, considering I do not have any standard deviations.
Thanks!

4 commentaires

Why are you not indexing AvgAngle_r by (i) ?
More importantly, why do you want to take a t test of two individual points? What is the meaning in that? (I'm pretty sure that test will always give NaN as a result.)
I am not indexing AvgAngle_r because when I do, all 101 outputs return as NaN. I was hoping that only indexing the second variable served as an index for both, since that returns 101 h and p values.
I'm still trying to understand your data. Is each value of AvgAngle_r [e.g. AvgAngle_r(17)] itself an average over multiple measurement? I guess the name suggests that.
If you have the data for those multiple measurements, then it seems to me that that is what you want to compare with the t test. (The MATLAB ttest function works on the raw underlying data, not the averages.) That comparison will tell you whether the two average values are significantly different, or just what you would expect from random variation.
If you don't have those data at hand, then you can probably still do the comparison if you have the average, the standard deviation, and the number of measurements that were used to calculate the averages. You'll just have to do the calculation yourself, based on the formula. You can see it here: https://en.wikipedia.org/wiki/Student%27s_t-test#Calculations. I think you'll want the "independent two-sample t-test".
But, as Walter commented, all the autocorrelation in the individual stride probably busts all the assumptions underlying the test.
You are presumably at an academic institution. Might you have a consulting statistician available to you?

Connectez-vous pour commenter.

Réponses (1)

You cannot test two populations with any test point-by-point. A point has a mean equal to the value of that point, and a variance (and standard deviation) of zero. By definition, they are statistically different from each other unless they are exactly equal.
If you are testing individual values of ‘AvgAngle_ASDr(i)’ against the population described by the 101 values of ‘AvgAngle_r’, your code is technically correct. However it’s not obvious to me that this is superior to doing testing the two populations.
With a population of 101 in each variable, the ztest and the normal distribution will also be appropriate.

8 commentaires

Thanks for your reply.
The two data files are joint angle data between two individuals normalized to one stride (0-100%). The purpose of the point-by-point tests are to determine differences throughout the 101 points rather than simply comparing the entire vectors (are the differences occurring between 0-20%, 30-50%, etc.,). Is there a way to do a test of this kind using matlab's t test functions?
Would it be a better option to obtain the standard deviations that correspond to each element in the respective vectors and code the t-test the old fashioned without using the in-built function?
Thanks again.
My pleasure.
I’m not certain I’ve ever known of the t-test being used the way you want to. I’m also not certain it’s valid, considering the assumptions of the t-test, since it implies infinite support (defined from -Inf to +Inf).
A more valid approach might be to calculate the distribution on the differences between the two, then calculate the probabilities of the difference.
No promises that even this is valid. Review the literature on gait analysis and see what the accepted procedure is. This is important not only because you would be doing your study using accepted techniques, but that it would also be more likely for your study to be published (if that is your objective).
Our purpose for using this type of analysis is exactly that, it's a way of examining gait in a way that has never done before. Hopefully we can add something to the lit that is not there. As long as the h and p values I get correspond to the correct comparison (1v1, 2v2, etc.,) I have what I need. I am just unsure if it's correct.
Thank you again.
Well, ‘never been done before’ means that you also have to prove its validity with your data.
A parametric test such as the t-test may not be appropriate. Consider using the Wilcoxon rank-sum (the ranksum function) or some other non-parametric test instead.
My pleasure.
The appropriate statistical test to apply is determined by the hypothesis you are trying to test. Typically, the t test answers the question, "Is the mean response of these two groups different, under the assumption that the individual variability is normally distributed?"
Usually, one should know before collecting data how you plan to analyze it. (But, maybe it is too late for that.) I would suggest that you specify more precisely the research question you are trying to answer, and that will guide the statistical test to apply.
Thanks for your reply.
We hypothesized that differences will be observed between the two individuals across the gait cycle (somewhere along the 101 data points) with intentions to determine a pattern of differences is specific phases of the cycle. We don't know who will be larger than the other, so a two-tailed test would be appropriate. The issue for me is that I do not have a method in matlab to use the dependent t-tests correctly for our purposes, assuming the code above is not correct.
Do the 101 values correspond to percent of stride in increments of 1%? If so then the adjacent values are going to be correlated for any one measured stride and there is an implicit hypothesis that for any one person all of their measured angles are are periodic with period one stride, which I suspect is not justifiable under the range of motions to be studied.
Yes, each of the 101 values represents a % of stride in 1% increments. Are there any statistical approaches that you (or anyone else reading) think would be appropriate? I have the corresponding stdev values for the 101 data points as well, if that helps.
Thanks, everyone.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by