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

18 views (last 30 days)
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 Comments
John Harry
John Harry on 7 Sep 2015
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.
the cyclist
the cyclist on 8 Sep 2015
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?

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 7 Sep 2015
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 Comments
Walter Roberson
Walter Roberson on 8 Sep 2015
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.
John Harry
John Harry on 8 Sep 2015
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!