  Categorical variables are of uttermost importance in biomedical research.
When two of them are considered, it is often the case that one wants to test
whether or not they are statistically dependent. We show weaknesses of
classical methods -- such as Pearson's and the G-test -- and we propose testing
strategies based on distances that lack those drawbacks. We first develop this
theory for classical two-dimensional contingency tables, within the context of
distance covariance, an association measure that characterises general
statistical independence of two variables. We then apply the same fundamental
ideas to one-dimensional tables, namely to the testing for goodness of fit to a
discrete distribution, for which we resort to an analogous statistic called
energy distance. We prove that our methodology has desirable theoretical
properties, and we show how we can calibrate the null distribution of our test
statistics without resorting to any resampling technique. We illustrate all
this in simulations, as well as with some real data examples, demonstrating the
adequate performance of our approach for biostatistical practice.
