1
$\begingroup$

I have multiple subjects walking under three experimental conditions to investigate how the step lengths are affected. Each subject performed all three conditions but the number of steps recorded is different for each experiment. I understand that I have to apply repeated measures ANOVA or paired t-test as the data are sampled from the same subjects but what is the proper way of dealing with the mismatch in sample sizes?

I am running this in Python so it will be great if pointers are given on how to code it.

EDIT 1:

Added fictitious data samples. For each condition, each subject may have different number of samples.

Condition | Subj A       | Subj B        | Subj C       |
Cond. 1   |0.5, 0.5, 0.55|1.1, 1.0, 1.05 |0.7, 0.75, 0.8|
Cond. 2   |0.3, 0.35, 0.4|0.9, 1.0       |0.5, 0.6, 0.5 |
Cond. 3   |0.4, 0.35     |0.9, 0.8, 0.8  |0.6, 0.5      |
$\endgroup$

1 Answer 1

1
$\begingroup$

I guess you should think about what your variables actually are. The tests would take something like:

Condition | A | B | C |
Cond. 1   |0.5|0.3|0.4|
Cond. 2   |1.1|1.0|0.9|

where A, B, and C are the persons and Cond. x the different conditions.

Here, one step is not one replicate! You take the average step length for each person under condition 1,...,n.

Why take the average? Because you want to know "a persons step size" under a given condition. Steps as such are pseudo replicates here: It is one and the same person and one and the same condition---you just take multiple measurements to get a better approximation of what "the step size" of person X is in that situation. Now that you took several measurements, you know the (average) step size of person X. Then you can compare this step size with the step size of person X in a different set up. You repeat the same with N persons and you'll have N replicates.

In python, you can do a paired t-test using

from scipy import stats
stats.ttest_rel()

The function takes two arrays that contain the values for the two conditions. Those arrays are both of length N (that is the number of test persons) and, obviously, their values should both be in the same order (person A is the first in both arrays, person B the second, and so on). You will also have to check the assumptions of the tests you are using; there is quite a number of tutorials in which the process is described in detail.

$\endgroup$
6
  • $\begingroup$ I have added a sample of the data in Edit 1. If I take the average step length for each condition, won't the data variation be ignored? $\endgroup$
    – mjfoo21
    Commented Jul 1, 2021 at 8:59
  • $\begingroup$ The variation will be the variation within the groups (conditions), not the variation of the step sizes for each individuum. Everything depends a bit on the precise question you ask. To me, the most sensible question would be "Does average step size change with condition?" (here, you have the "average" in the question already). After all, single steps in a row are probably no independent samples... $\endgroup$ Commented Jul 1, 2021 at 9:19
  • $\begingroup$ I understand your point of getting average step size. However, under some conditions the data variance is high, even for intrasubject data. Assume I have only one subject with sample data from two conditions, say, ` [0.5, 0.55] vs [0.9, 0.6, 0.4] . The mean will be [0.525] vs [0.63] `. My concern is that the t-test may flag significance even though the variation of the second condition covers the range of the first one. $\endgroup$
    – mjfoo21
    Commented Jul 2, 2021 at 0:26
  • $\begingroup$ I guess variance in step size is rather equal, so it would probably be [0.5, 0.9] vs [0.9, 0.6, 0.4]. The first one has a higher mean, which could be just by chance. There is no significant difference between the two conditions for that person. However, if the mean of Cond. 1 being higher was just by chance, you wouldn't find a pattern (mean of Cond. 1 would be sometimes higher, sometimes lower). But if mean of Cond. 1 is higher for 95 of 100 persons, there is a pattern, even if Cond. 1 and Cond. 2 for 1 person aren't significantly different. Maybe there are more advanced methods, but... $\endgroup$ Commented Jul 2, 2021 at 8:22
  • $\begingroup$ ...for the methods you've mentioned that's all. Those test don't have an option to include multiple measurements per person per condition. You could, of course, select random measurements to have equally much, e.g. from [0.5, 0.9] vs [0.9, 0.6, 0.4] select [0.5, 0.9] vs [0.6, 0.4]. (Maybe I'm wrong, but) I think you'd have pseudo-replicates then, since each combination of person and condition would occur multiple times... $\endgroup$ Commented Jul 2, 2021 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.