Who’s Afraid of the Wallenius Distribution? Linda M. Haines Abstract Abstract This paper is about the use of the Wallenius noncentral hypergeometric distribution for analysing contingency tables with two or more groups and two categories and with row margins and sample size, that is both margins, fixed. The parameters of the distribution are taken to be weights which are positive and sum to one and are thus defined on a regular simplex. The approach to analysis is presented for likelihood-based and Bayesian inference and is illustrated by example, with datasets taken from the literature and, in one case, used to generate semi-synthetic data. The analysis of two-by-two contingency tables using the univariate Wallenius distribution is shown to be straightforward, with the parameter a single weight which translates immediately to the requisite odds and the odds ratio. The analysis of contingency tables with more than two groups based on the multivariate Wallenius distribution was however found to be more nuanced than that of the two-group tables. Specifically, some numerical subtleties were required in order to implement the necessary calculations. In particular, optimisation with respect to the weights was performed by transforming the weights to yield an unconstrained optimisation problem and likelihoods which are extremely small were scaled by an appropriate multiplying factor without compromising the elements of inference. Furthermore, a novel Markov chain Monte Carlo algorithm for Bayesian inference, termed the sphere walk Metropolis, was constructed. The proposal is implemented in Cartesian coordinates on the reference simplex and the Metropolis filter in barycentric coordinates on the regular simplex, with the transition between barycentric and Cartesian coordinates effected seamlessly. Keywords: Wallenius distribution, contingency tables, fixed margins, preference weights, sphere walk Metropolis algorithm 1. Introduction Two-by-two contingency tables are used extensively to summarize and analyse data collected in many areas of research and, more specifically, in science, medicine and sociology. At the same time, statisticians continue to debate how the tables should be ‘correctly’ analysed. Controversies surrounding this issue, in particular relating to sufficiency, ancillarity and conditionality are presented in the excellent review paper of 7 . The work of 23 on a non-null alternative to Fisher’s exact test is however not mentioned in the review and in fact is rarely cited in the literature relating to that test. 23 focussed on 2\times 2 contingency tables with both margins fixed and derived the distribution of the random variable defined, generically, as the number of successes in the the first group of the table. To do so, he introduced an intuitively appealing parameter, that of the odds of a success in the first group. The distribution was later extended by 5 to contingency tables with several groups and two categories, generically success and failure. The odds parameter in the two-group setting was replaced by a vector of weights which are positive and sum to one and taken over the groups. The two distributions are referred to collectively as Wallenius noncentral hypergeometric distributions, with the term univariate associated with 2\times 2 contingency tables and the term multivariate with tables comprising several groups. Further research into the distributions was impeded by the fact that the integrals embedded in the probability mass functions were exceedingly challenging to evaluate. However, in 2008 Fog released the R package, BiasedUrn , which provides great numerical stability for the necessary calculations and which remains widely used ( 11 ; 12 ) . The derivation of the univariate Wallenius distribution is rooted in a sampling mechanism which can be framed as an urn model and, in turn, as a scheme for biased sampling. The bias in the scheme is specified by fixing a value of the odds parameter which is in some sense meaningful. The scheme has been widely cited in the literature on gene set analysis and is embedded in the R package goseq ( 25 ; 13 ) . In addition, it has been implemented in a miscellany of other areas of interest, including wildlife movement ( 10 ) , portfolio analysis ( 3 ) and configuration networks ( 4 ) . In contrast, scant attention has been given to the usefulness of the results of 23 and 5 in the analysis of data which has been collected and summarized in contingency tables comprising two or more groups and two categories. 6 herself suggested that the Wallenius distribution be used to model such data, with the attendant weights treated as unknown parameters and estimated and interpreted accordingly. However it would seem that few examples which use this approach have been reported. In particular, 14 invoked the univariate Wallenius distribution to assess the effectiveness of a ‘leaky’ vaccine on individuals who were or were not vaccinated for measles. More recently, 1 demonstrated the use of the multivariate Wallenius distribution to analyse two sets of contingency tables which were extracted from survey data. The authors used preference weights across the groups of the tables as the unknown parameters and based their analysis on Bayesian inference. The aim of the present study is to demonstrate that data from contingency tables with two or more groups, two categories and both margins fixed can be analysed in a straightforward manner within the framework of Efron’s statistical triangle, that is within the realms of frequentist, Fisherian and Bayesian inference ( 9 ) , by invoking the Wallenius distribution. The genetic study reported by Wallenius in his 1963 thesis is reintroduced here as a motivating example for the study. Specifically, 215 rabbit neonates born on a small island off the coast of San Fransisco were captured, blood typed as homozygote or heterozygote, and released. Three months later the surviving rabbits were recaptured and blood typed again. The results, according to blood type, are summarized in the 2\times 2 contingency table displayed in Table 1. The question posed by the geneticists was as to whether or not survival of a neonate rabbit depends on phenotype or, more informally, whether or not nature is in some sense biased. The table can be construed as being driven by nature and assumed to have two fixed margins. Fisher’s exact test yielded a two-sided p-value of 0.0235 and the null hypothesis that survival is independent of phenotype was therefore rejected. It will be shown later in the text that an analysis of the table based on the univariate Wallenius distribution provides a far more quantitative assessment of the data. The paper is structured as follows. The univariate and multivariate Wallenius distributions are introduced in Section 2 and analyses of 2\times 2 contingency tables using the univariate Wallenius distribution are presented in Section 3. Numerical methods for facilitating the calculation of the probability mass functions and a novel MCMC approach to simulating data from the posterior distribution of the parameters in the multivariate case are introduced in Section 4. Section 5 is devoted to the analysis of data for single and multiple 3\times 2 contingency tables extracted as semi-synthetic data from the complete dataset of 1 . Analyses based on the Wallenius distribution for three real world datasets are then delineated in Section 6 and a discussion of the main results is given in Section 7. 2. Preliminaries 2.1 Univariate Setting Consider an urn containing m_{1} red balls each of weight w_{1}>0 and m_{2} white balls each of weight w_{2}>0 . Suppose that n balls are drawn one at a time without replacement from the urn and that the probability of a ball being selected at a given draw is equal to the weight of the balls of the same colour in the urn over the weight of all the balls in the urn. The sampling is therefore biased unless w_{1}=w_{2} . The setting can be taken to represent a 2\times 2 contingency table with the two margins, the totals m_{1} and m_{2} and the sample size n , fixed and x the realisation of the random variable X , the number of red balls drawn from the urn. The table is summarized in Table 2. 23 used this setting as the basis for deriving the probability mass function (pmf) of X in terms of the odds of a red ball being drawn. The odds parameter \beta=\displaystyle\frac{w_{1}}{w_{2}} embedded in the expression so obtained is invariant to scale and in the present study the pmf is taken to be \mbox{Prob}(X=x|w)=\binom{m_{1}}{x}\binom{m_{2}}{n-x}\int_{0}^{1}(1-t^{\frac{w}{d}})^{x}(1-t^{\frac{1-w}{d}})^{{n-x}}\;dt (1) where w represents the weight of a red ball and 1-w that of a white ball and d=w(m_{1}-x)+(1-w)\big(m_{2}-(n-x)\big) . The constraints of the hypergeometric distribution \max(0,n-m_{1})\leq x\leq\min(n,m_{1}) necessarily hold. The realisation x is said to follow a univariate Wallenius noncentral hypergeometric distribution, denoted here as x\sim{\mbox{W}}(m_{1},m_{2},n,w) . As a counterpoint to the biased sampling scheme, suppose that data for a complete 2\times 2 contingency table have been collected. Then the weight w can be interpreted as an unknown parameter with attendant likelihood L(w|x;m_{1},m_{2},n) . The weight w is chosen here as the unknown parameter rather than the odds parameter \beta since functions of w have a compact representation on the interval [0,1] and, in addition, the weight itself is straightforward to interpret. The odds of a drawing a red ball and the odds ratio can be immediately recovered from w . The pmf of the univariate Wallenius distribution ( 1 ) can be evaluated by recursion and is available numerically, together with a suite of attendant functions, in the R package BiasedUrn and in 16 . 2.2 Multivariate Setting Consider now the multivariate counterpart of the biased sampling scheme introduced in the previous section, with balls of more than two colours in the urn. Specifically, suppose that there are m_{i} balls in the urn of colour i and weight w_{i} , i=1,\ldots,c , where c denotes the number of colours and the total number of balls is given by M=\sum_{i=1}^{c}m_{i} . Suppose further that a fixed number of balls, n2 , requires further attention. 4.1.1 Weight transformation Optimisation of functions, such as the likelihood L(\mbox{\boldmath$w$}|\mbox{\boldmath$m$},n,\mbox{\boldmath$x$}) , with respect to the weights w is necessarily constrained. However, the weights can be transformed to ‘working parameters’ so that the optimisation is then unconstrained. Here, an approach taken from that for the construction of approximate optimal designs is invoked, with the transformation expressed as w_{j}=\frac{z_{j}^{2}}{\sum_{i=1}^{c}z_{i}^{2}}\mbox{~and inversely as ~}z_{j}=\sqrt{w_{j}}\mbox{~~where ~}z_{j},\in{\mathbb{R}}\mbox{~and~}j=1,\ldots,c, and embedded into routines for optimization, such as optim in base R ( 2 , p. 130) . Note that an alternative transformation of weights based on hyperspherical coordinates is also available but was not used in the present study. 4.1.2 Cartesian and Barycentric Coordinates Weights expressed in barycentric coordinates are intuitively meaningful. For example, surfaces and regions on the two- and three-dimensional simplexes, that is the triangle and the tetrahedron, can be represented graphically. But certain operations, such as the moving of a weight within a simplex, is not valid. For example, the two-dimensional simplex in barycentric coordinates has zero volume in three-dimensions. In such cases however, it is possible to move seamlessly between barycentric and Cartesian coordinates and, thereby, to avoid any such complications. This approach can be implemented by invoking functions available in the R package geometry . As an aside, it is worth noting that the geometry of the two-dimensional simplex is not widely documented ( 19 ) and that for simplexes of higher dimension less so. 4.1.3 Multiplying Constants The probabilities relating to the multivariate Wallenius distribution with multiple tables tend to be extremely small, that is of the order of 10^{-100} to 10^{-300} , as noted earlier in Section 3.2.1. Such probabilities can, however, be multiplied by a constant which is approximately the inverse of the order of the probabilities, a strategy which has no impact on many of the calculations embedded in the likelihood and Bayesian settings. Specifically, a multiplying constant does not affect the maximization of the likelihood. In addition, the construction of pure likelihood intervals, intervals based on Wilk’s likelihood ratio statistic and the implementation of an MCMC algorithm depend on ratios of likelihoods and remain unaffected. This approach is used in the present study and logarithms of the likelihoods and of the associated probabilities are not introduced. These techniques, that of transforming weights to yield an unconstrained optimization problem, that of interchanging barycentric and Cartesian coordinates and that of multiplying the likelihood by a suitable constant, are used extensively in the examples both here and in the next section. 4.2 A Markov Chain Monte Carlo Algorithm A Markov chain Monte Carlo (MCMC) algorithm was developed in the present study in order to accommodate the modelling of the multivariate Wallenius distribution within the Bayesian framework. The algorithm is used in the examples which follow in the next two sections and is presented generically here. Specifically, consider the posterior distribution of the unknown weight parameters w expressed as [\mbox{\boldmath$w$}|\mbox{\boldmath$x$}]\propto\pi(\mbox{\boldmath$w$})L(\mbox{\boldmath$x$}|\mbox{\boldmath$w$}) , where L(\mbox{\boldmath$x$}|\mbox{\boldmath$w$}) is the likelihood of w with \mbox{\boldmath$x$}\sim W(\mbox{\boldmath$m$},n,\mbox{\boldmath$w$}) , \pi(\mbox{\boldmath$w$}) represents the pdf of a Dirichlet prior and, for compactness, the right hand term in the proportionality is denoted by g(\mbox{\boldmath$w$}) . In essence, the MCMC introduced here is a Metropolis algorithm with the proposal performed in Cartesian coordinates and the Metropolis filter in barycentric coordinates. The construction of the proposal distribution embedded in the algorithm is not entirely straightforward. The weights are elements of the subset of a hyperplane in R^{n} which has zero volume. As a consequence, weights taken from the simplex S^{n-1}\subset R^{n-1} in barycentric coordinates cannot be sampled ( 21 ) . To accommodate this, a reference simplex in R^{n-1} defined in Cartesian coordinates and based on a bijective transformation between barycentric and Cartesian coordinates, is introduced. The proposal distribution is then implemented on the reference simplex and, since that simplex is a convex polytope in R^{n-1} , can be taken to be a random walk ( 22 ) . A sphere walk is adopted here, with the candidate point a uniformly distributed random point on a hypersphere of radius r centred at the current point. If the candidate point lies in the reference simplex, it is taken as the new point; otherwise the walk remains at the current point. The attendant membership oracle is straightforward to implement in that a candidate point expressed in Cartesian coordinates either complies or does not comply with the usual weight constraints. The candidate point so generated is transferred to the regular simplex and expressed in barycentric coordinates. The Metropolis filter now follows immediately and is executed in barycentric coordinates. Note that the proposal distribution is symmetric and does not appear in the ratio which defines the filter. To complete the implementation of the algorithm, the radius of the hypersphere r used in the proposal distribution is tuned by means of a pilot study so that the acceptance rate of the filter is between 23% and 30%. The radius is then held fixed during further iterations. The algorithm, termed the sphere walk Metropolis (SWM), is presented succinctly in Table 7 and was programmed in the present study in R. The reference simplex with vertices specified by the n vectors of length n-1 given by (1,0,\ldots 0),\ldots,(0,\ldots,1),(0,\ldots,0) , together with the attendant bijective transform, was implemented using the functions bary2cart and cart2bary in the R package geometry . An alternative random walk proposal, termed a ball walk, in which candidate points in Cartesian coordinates are selected uniformly inside the ball was also investigated. Technical details relating to the SWM algorithm itself and to the choice of proposal distribution are given in the examples of the next section. 5. The Wallenius Distribution with Three Groups In order to fix ideas with respect to the fitting of the multivariate Wallenius distribution to data, 3\times 2 contingency tables were taken as semi-synthetic data from the journal preference dataset of 1 . Specifically, data from the three categories of journal with the smallest number of zero responses, that is Methodology, Applied Statistics and Computation in that order, were extracted from the 174 responses. There were no individuals for which all three counts were zero. The row marginal totals were again assumed to be those of the complete dataset and are given by \mbox{\boldmath$m$}=(45,34,9) but the samples sizes n=\sum_{i=1}^{3}x_{i} , while taken to be fixed for each individual 3\times 2 contingency table, ranged from 6 to 20. The three counts of preferred journals in a given 3\times 2 table with fixed margins are denoted \mbox{\boldmath$x$}=(x_{1},x_{2},x_{3}) but, since \sum_{i=1}^{3}x_{i}=n , only two are realisations of random variables. Here the counts x_{1} and x_{2} are taken to be realisations of the random variables X_{1} and X_{2} , the number of Methodological and Applied Statistics journals preferred. Finally, x is distributed as W(\mbox{\boldmath$m$},n,\mbox{\boldmath$w$}) , with the weights \mbox{\boldmath$w$}=(w_{1},w_{2},w_{3}) conformable with x , that is with the order of the categories of journal. In addition, the constraints on the counts 0\leq x_{1},x_{2}\leq n and 0\leq x_{3}=n-x_{1}-x_{2}\leq\min(n,9) necessarily hold. The two main reasons for introducing the three-group Wallenius distribution are that the weights and attendant surfaces can be represented in two dimensions as ternary plots and that the MCMC algorithm introduced in the previous section can be validated by simulation. 5.1 A Single \mathbf{3\times 2} Table 5.1.1 Likelihood Lens Consider first modelling the data for a single individual based on the three-group Wallenius distribution. The 174 vectors of counts taken from the 3\times 2 contingency tables of interest clearly reflect the inherent imbalance in the data. Data for two individuals, one broadly representative of the overall responses and one somewhat atypical, were therefore selected for analysis. The row numbers of the individuals in the complete dataset and the attendant counts, with the counts for individual 20 deemed typical and those for individual 108 atypical, are presented in Table 8. The MLEs of the preference weights were obtained by invoking unconstrained optimisation and are also included in that table. The likelihood surfaces relating to the two 3\times 2 contingency tables of interest, denoted L(\mbox{\boldmath$w$}|\mbox{\boldmath$x$}) , were simulated to a high degree of accuracy by taking a random sample of 1,000,000 uniform variables from the Dirichlet distribution, D (1,1,1) , over the simplex and the 95\%,50\% and 5\% confidence regions based on Wilk’s likelihood ratio statistic extracted from the simulations ( 20 ) . Plots of the likelihood surfaces so obtained, together with bivariate box plots delineating the specified confidence regions, are displayed in Figure 2. As an aside, the present setting involves two unknown weight parameters and, as a consequence, the confidence and pure likelihood regions coincide. Confidence intervals for weights, such as those in the present study, are not straightforward to construct and are, arguably, difficult to interpret ( 17 ) . As a consequence, parametric bootstraps were conducted in order to assess the accuracy of the MLEs of the individual weights. Specifically, both margins of the 3\times 2 contingency tables are fixed and only x_{1} and x_{2} , are realisations of random variables. The bootstrap replications thus comprise compositions of the integer n into 3 parts, with the constraint x_{3}\leq 9 then applied. For the two examples of interest here, the number of bootstrap samples is small and ideal parametric bootstraps were conducted. The numbers of bootstrap samples, denoted \tilde{C}(n) , and the values of the bootstrap standard errors for the MLEs of the weights, denoted \widehat{\mathrm{se}}_{\mathrm{boot}} , are presented in Table 8. It is immediately clear from these latter values, and from the confidence regions displayed in Figure 2, that the estimates of the attendant MLEs cannot be construed as being precise. 5.1.2 A Bayesian Lens Consider now a Bayesian framework for modelling data from a single 3\times 2 contingency table based on the three-group Wallenius distribution. The posterior distribution of the weights, with a Dirichlet distribution as the prior, cannot be found explicitly. Recourse must therefore be made to simulating the posterior distribution over the simplex in barycentric coordinates ( 20 ) or to sampling the posterior distribution using an MCMC algorithm. Both approaches are introduced here, with simulation used as a benchmark for the sphere walk Metropolis (SWM) presented in Section 4.2. To fix ideas, consider again individuals 20 and 108 from the journal preference data, with counts x of (8,6,1) and (7,4,7). Two priors, the flat prior, D (1,1,1) , and an informative prior, D (2,3,2) , which reflects a sense that the Applied Statistics category should be more highly rated and aligns well with the likelihoods, were selected for analysis. The posterior distributions were first approximated by generating 1,000,000 uniform random variates over the 2-dimensional simplex, as for the simulation of the likelihood, and consistent results were obtained. The means and standard deviations of the posterior distributions of the weights for the two priors are given in Table 9 and the MLEs of the weights for the two individuals are included in the legend of the table. It is clear from a comparison of the posterior means with the corresponding MLEs that the priors have a clear impact on the form of the likelihood. The posterior distribution of the weights was also sampled using the SWM algorithm. Three chains of length 100,000 were generated after a burn-in of 10,000 for each setting and mixing was found to be extremely fast. The trace plots and a multivariate potential scale reduction factor, \hat{\mathrm{R}} , of 1 indicated convergence of the chains. The means and standard deviations so generated were found to be in excellent agreement with those obtained using simulation and the algorithm was thereby validated, albeit for the present example. The 95% and 68% credible intervals for the weights were also obtained and proved to be extremely wide in all cases. On balance therefore, the results within the Bayesian framework, together with those for the likelihood approach, underscore the fact that using the Wallenius distribution to model data for a single 3\times 2 contingency table can be fragile and that the analysis of such data should be treated with caution. The performance of the ball walk Metropolis was, in essence, the same as that for the sphere walk Metropolis but required a larger tuning radius and thus yielded more points outside the reference simplex. The SWM algorithm was therefore used in the remainder of the present study. Other proposal distributions were also considered. In particular, an independence sampler was tested with the Dirichlet distribution D (1,1,1) as the prior. The sampler gave excellent results for the data for individual 20, for which the posterior distribution is diffuse, with an acceptance rate of 0.275, but performed extremely badly for the more focused data for individual 108, with an acceptance rate of 0.066. A Hit-and-Run proposal over the reference simplex with a Metropolis filter was also implemented and gave results similar to those of the independence sampler. It is worth noting that 21 developed a Hit-and-Run sampler which yields points which are uniformly distributed on regions of the simplex defined by linear constraints. The approach could be used as a proposal, together with a Metropolis filter, in the present context to yield samples from a posterior distribution which is restricted to such a region. However this strategy was not investigated further. 5.2 Multiple \mathbf{3\times 2} Contingency Tables Consider now the 174 responses to the categories Methodology, Applied Statistics and Computation, in that order. Interest here focusses on fitting the multivariate Wallenius distribution with a weight parameter, w , common to all individuals. The analysis is straightforward and follows closely that of the single 3\times 2 contingency tables. 5.2.1 A Likelihood Lens The likelihood is given by L(\mbox{\boldmath$w$}|\mbox{\boldmath$x$}_{1},\ldots,\mbox{\boldmath$x$}_{174},\mbox{\boldmath$n$})=\prod_{i=1}^{174}L(\mbox{\boldmath$w$}|\mbox{\boldmath$x$}_{i},n_{i}) , where \mbox{\boldmath$x$}_{i}=(x_{i1},\ldots,x_{i174}) , with values of the order of 10^{-300} over a range of weights. As a consequence, the individual likelihoods embedded in the product term were multiplied by a factor of 50 to provide stability in further calculations. The likelihood was found to be unimodal from a contour plot and the MLE of the weights was obtained as \widehat{\mbox{\boldmath$w$}}=(0.346,0.228,0.426) . The 95%, 50% and 5% confidence regions of the weights, magnified over a subset of the simplex, are shown as bivariate box plots in Figure 3(a). A nonparametric bootstrap comprising 5000 replications of \widehat{\mbox{\boldmath$w$}} was also conducted and yielded the bootstrap standard errors \widehat{\mathrm{se}}_{\mathrm{boot}} =(0.013, 0.011, 0.017) and the 95% central percentile intervals (0.321,0.371), (0.208,0.249), (0.391, 0.459) of the weights. It is immediately clear that mean values of the rating preferences with a weight common to all 174 individuals are far more precise than those of the single 3\times 2 contingency tables. 5.2.2 A Bayesian Lens The flat Dirichlet distribution D (1,1,1) was adopted here as a prior and the SWM algorithm of Section 4.2 was used to sample from the posterior distribution. The factor \hat{\mathrm{R}} over three chains of 100,000 samples each was 1 and the trace plots indicated good convergence. A plot of 10,000 samples taken from the start of one of the the Markov chains at the point (0.6,0.3,0.1) is shown in Figure 3(b) and illustrates the fast convergence of the chain. The means, standard deviations, and 95% credible intervals of the weights were found to be very close to the likelihood-based means, \widehat{\mathrm{se}}_{\mathrm{boot}} and 95% percentiles and the credible regions were found to be very similar to those of confidence regions. As a consequence, details of the analysis within the Bayesian context are not recorded here. The probabilities that Computation was preferred to Methodology and Methodology to Applied Statistics were elicited from the SWM samples and are very close to one and exactly one, respectively, thus indicating a clear order of preference for the three categories of journal. The choice of a subjective prior for the present setting is not straightforward. More specifically, a good alignment of a Dirichlet prior distribution with the likelihood is not easy to find. For example, the prior D (2,3,2) , indicating that Applied Statistics is underrated, is too diffuse and has little impact on the posterior distribution, while the more focussed prior D (4,6,4) , with a mean of (0.286,0.428,0.286) is totally misaligned with respect to the likelihood. The issue of finding a suitable prior to accommodate a sense that the estimated preferences do not fully reflect an opinion clearly requires considerable thought and is not pursued further here. 6. Real World Examples 6.1 A Randomised Clinical Trial 9 present data for the first six months of a randomized clinical trial relating to the survival of cancer patients under two treatment arms, A and B, in Table 9.4 of their book. The authors use the complete dataset of 47 patients from which the data of the table were extracted to illustrate the use of the log-rank statistic to test the null hypothesis that the hazard rates are the same for arm A and arm B. Arguments underpinning the log-rank test are developed as follows. The data for each month are framed as 2\times 2 contingency tables, as shown in Table 9.5 of 9 . Two key assumptions relating to the tables are then made. Specifically, both the margins of each table are taken to be fixed and, based on “aggressive” conditioning arguments, the tables are assumed to be independent. The hypergeometric distribution then forms the basis for evaluating the expected means and variances used to compute the log-rank statistic, Z . Finally, assuming that the statistic Z is distributed as N(0,1) under the null hypothesis, the significance level of Z can be found and interpreted. It is immediately clear that the setting of the log-rank test, and the assumptions therein, can be mapped onto that for modelling multiple independent 2\times 2 contingency tables using the univariate Wallenius distribution. The six month data in Table 9.4 of 9 were analysed here using a likelihood framework based on the Wallenius distribution. The random variable in each of the six 2\times 2 contingency tables was taken to be the number dying in arm A, as in 9 , and a common preference weight w over the six months was then assigned to arm A. The likelihood function, denoted L(w|x_{1},\ldots,x_{6}) , was found to be unimodal and the MLE of the weight, \hat{w} , was given by 0.610 , with a 95% confidence interval based on Wilk’s likelihood ratio of (0.457,0.749) . In other words, the odds of dying in arm A at the end of the sixth month was estimated to be 1.564 and the odds ratio to be 2.446. A plot of the likelihood L(w|x_{1},\ldots,x_{6}) against the weights w\in(0,1) , together with the MLE and the 95% confidence limits, is shown in Figure 4(a). A direct, quantitative approach to comparing the hazard rates for the two arms of the trial can now be invoked. Thus, the probability that a patient dying under arm B at the end of month 6 is less than or equal to 0.5 is given by Prob (w\leq 0.5) and was found by simulation to be 0.083, thereby providing mild support for treatment B. The result is in accord with the log-rank statistic based on the six contingency 2\times 2 tables in that the value of the statistic Z was found to be 1.40 with a significance level of 0.081. 6.2 Categories of Journals An analysis of the complete dataset of responses for the five categories of journals, Methodology, Probability, Applied Statistics, Computation and Economics, based on the multivariate Wallenius distribution is now reported. Following 1 , the vector of preference weights is taken to be common to all individuals. The likelihood of the preference weights w is given by L(\mbox{\boldmath$w$}|x_{1},\ldots,x_{174},\mbox{\boldmath$n$})=\prod_{i=1}^{174}L(\mbox{\boldmath$w$}|x_{i},n_{i}) and has values over a range of weights of the order of 10^{-300} . As a consequence, the individual likelihoods embedded in the product term were multiplied by a factor of 750 which yielded likelihood values of the order of 10^{4} and provided numerical stability in further calculations. The MLE of w , denoted \widehat{\mbox{\boldmath$w$}} , was then obtained and a nonparametric bootstrap of 2000 replications of \widehat{\mbox{\boldmath$w$}} was conducted, yielding bootstrap standard errors \widehat{\mathrm{se}}_{\mathrm{boot}} and the 0.25 and 0.975 percentiles points The results are summarized in Table 10. The complete dataset for the five categories of journals was also analysed within the Bayesian framework. An objective Bayes setting with the flat prior D (1,1,1,1,1) was adopted and the posterior distribution was sampled using the SWM algorithm. The radius r of the sphere in the sphere walk proposal was tuned to a value of 0.01675 in order to yield acceptance rates of 24 to 30% and three chains of length 100,000 after a burn-in of 10,000, were so generated. The factor \hat{\mathrm{R}} was equal to 1 and the trace plots indicated good convergence. The means and standard deviations coincided to within \pm 0.001 with those of the likelihood-based means and \widehat{\mathrm{se}}_{\mathrm{boot}} reported in Table 10 and are not presented here. The trace plots associated with the five categories of journal are shown in Figure 5 and, in essence, illustrate the key features of the objective Bayes analysis. The categories are clearly ordered by decreasing preference as Computation, Methodology, Applied Statistics, Economics and Probability. Furthermore, the probability of preferring a category to that immediately lower in the ordering is exactly one, except for that of preferring Computation to Methodology which is 0.99977. The posterior distributions of the five weights, together with the mean and the 95% and 68% credible intervals, highlight the intrinsic variability between the categories but are not shown here for compactness. The choice of a subjective prior for the present setting is not straightforward and was not pursued further. 1 present an analysis of the dataset for the categories of journal based on objective Bayes. The authors deemed an MCMC approach to sampling the posterior distribution of the weights to be infeasible because of the intractability of the likelihood function and instead used approximate Bayesian computation (ABC). The results of 1 are broadly the same as those presented here in terms of the order of the categories of journal according to preference. However the means do not coincide exactly with those of the present study and the distributions of the weights are far more diffuse. In fact, it is intriguing to note that the means obtained from the paired comparisons of the categories and reported in Section 3.2.2 are close to those given here. 6.3 Selective Predation 15 reported an experiment conducted in order to investigate whether or not the survival of eight types of fly was dependant on the number of their bristles. The data are presented in Table 4 of his paper. 15 observed that, since the dead flies were not replaced, the data could be framed as an 8\times 2 contingency table with fixed margins and, being unaware of Wallenius’s PhD work, developed a model for ‘measures of selectivity’ associated with each type of fly, together with a simple formula for calculating the measures. Later, 6 recognised that the data for the survival of the flies can be modelled using a multivariate Wallenius distribution and noted that the MLEs of the weights agreed well with the estimated measures of Manly’s findings. The analysis of the data based on the Wallenius distribution was conducted here within both the likelihood and the objective Bayes frameworks. The vector of eight weights w=(w_{1},\ldots,w_{8}) was associated with the numbers of flies dying, in accord with the study of 15 . The MLE of the weights and the attendant bootstrap standard errors and the 0.025 and 0.975 percentile points obtained from 2000 bootstrap samples, were computed. In addition, a flat Dirichlet prior for the weights was introduced and the resultant posterior distribution sampled using the SWM algorithm of the present study. The results of the likelihood-based and the Bayesian analysis were similar and, for compactness, are not reported here. Rather, the mean and the 95% credible intervals of the weights obtained from the Bayesian analysis are displayed in an error bar plot in Figure 4(b). It is particularly interesting to observe that the means associated with the weights were very close to those reported as normalized measures of selectivity by 15 and that the only new information presented here is the 95% confidence intervals for the likelihood approach and the results for objective Bayes inference. 7. Conclusions The results, and more particularly the examples, in this paper are introduced in order to demonstrate the ease with which the Wallenius noncentral hypergeometric distribution can be fitted to contingency tables with two or more groups, two categories and both margins fixed. Likelihood-based and Bayesian analyses are presented and rely strictly on the calculation of likelihoods and not log-likelihoods. For 2\times 2 contingency tables, a weight parameter associated with a success in the first group rather than the odds of a success in that group was adopted. The single parameter permits the approximation of integrals by simulation and is easy to represent and interpret. In addition, inference for the weight parameter can immediately be translated into that for the odds of a success in the first group and to that for the odds ratio. For c\times 2 contingency tables with more than two groups, that is c>2 , some further numerical subtleties were required. The parameter is now a vector of weights which are positive and sum to one. Problems with respect to optimisation of the functions such as the likelihood with respect to the weights can however be overcome by introducing a suitable transformation of the weights to yield an unconstrained optimisation routine. In addition, the likelihoods are generally small but can be scaled to obviate computational underflow without changing the elements of inference since the latter are most generally based on ratios of the likelihood. The MCMC algorithm, termed the sphere walk Metropolis algorithm, which is introduced for sampling from the requisite posterior distributions within the Bayesian framework, is novel and merits some attention. The algorithm is rooted in the fact that transformations between barycentric coordinates defined on the regular simplex and Cartesian coordinates defined on the reference simplex can be seamlessly implemented. Thus, the proposal for the chain is implemented on the reference simplex, which is a convex polytope, by a sphere walk and the Metropolis filter is computed on the regular simplex. In terms of application, the derivation and use of the Wallenius distribution rests on the assumption that both margins of a contingency table with two categories are fixed, that is both the row marginal totals and the size of the sample taken are fixed. The row margins are, in general, taken to be fixed and the issue of fixing both margins reduces to making the assumption that the sample size is fixed, a problem which is only occasionally discussed in the literature. For 2\times 2 contingency tables, the assumption of fixed margins is valid if the table was constructed by design or by termination of a process. Otherwise, recourse is made to taking the row counts to be generated from two independent binomials with the attendant likelihood conditional on the sample size ( 7 ) . The latter approach is much discussed in the literature in that it relies on notions of sufficiency, ancillarity and conditioning and on the handling of nuisance parameters. It is tempting therefore to adopt the notion that, once data are collected, the contingency table is a given and, as stated by 23 in the introduction to his thesis, the researcher must now quantify the “degree of bias” exhibited in that table. In other words, the tables are now data-driven. This notion is encapsulated in the question asked by the geneticists in relation to the 2\times 2 contingency table displayed in Table 1 and used as a motivating example by 23 , which simply states “Is Nature Biased?”. If this approach is taken, then the assumption of a fixed sample size is subsumed in the modelling process of the data. For contingency tables with two categories and more than two groups, the notion of “degree of bias” can immediately be translated to preference weightings across the groups, as noted by 6 and explored in detail in the landmark paper of 1 . Here the process relates, in essence, to decision making and offers an interesting approach within that context. To conclude, there is a fundamental difference between the Wallenius noncentral hypergeometric distribution and Fisher’s noncentral hypergeometric distribution. The difference is immediately apparent in the context of biased sampling. But the difference within the context of the analysis of contingency tables with two categories is not transparent. A small paper to fully explore this difference is therefore in progress.