`NaN` in Statistical Hypothesis Testing

Easy to ignore whatever values you don’t want to use: EqualVarianceTTest(filter(!isnan, A), B).

If your observations in A and B are paired and you want to ignore corresponding elements from both (not only remove A[2] that is NaN but also remove B[2]), then it’s most convenient to put these arrays into a single columnar table. In Julia, it’s effectively free, and you retain the same familiar array interface:

using StructArrays
# best to keep both A and B together from the beginning, if they are paired
data = StructArray(; A, B)

data = filter(x -> !any(isnan, x), data)
EqualVarianceTest(data.A, data.B)
4 Likes