  Given a set of incomplete observations, we study the nonparametric problem of
testing whether data are Missing Completely At Random (MCAR). Our first
contribution is to characterise precisely the set of alternatives that can be
distinguished from the MCAR null hypothesis. This reveals interesting and novel
links to the theory of Fr\'echet classes (in particular, compatible
distributions) and linear programming, that allow us to propose MCAR tests that
are consistent against all detectable alternatives. We define an
incompatibility index as a natural measure of ease of detectability, establish
its key properties, and show how it can be computed exactly in some cases and
bounded in others. Moreover, we prove that our tests can attain the minimax
separation rate according to this measure, up to logarithmic factors. Our
methodology does not require any complete cases to be effective, and is
available in the R package MCARtest.
