How do I compute point-by-point t tests between two 101 data point vectors?
Afficher commentaires plus anciens
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
Walter Roberson
le 7 Sep 2015
Why are you not indexing AvgAngle_r by (i) ?
the cyclist
le 7 Sep 2015
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.)
John Harry
le 7 Sep 2015
the cyclist
le 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?
Réponses (1)
Star Strider
le 7 Sep 2015
0 votes
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
John Harry
le 7 Sep 2015
Star Strider
le 7 Sep 2015
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).
John Harry
le 7 Sep 2015
Star Strider
le 8 Sep 2015
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 cyclist
le 8 Sep 2015
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.
John Harry
le 8 Sep 2015
Walter Roberson
le 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
le 8 Sep 2015
Catégories
En savoir plus sur Noncentral t Distribution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!