, Number 1, pp. 1{24 Two-sample Bayesian Nonparametric...

25
Bayesian Analysis (2004) 1, Number 1, pp. 1–24 Two-sample Bayesian Nonparametric Hypothesis Testing Chris C. Holmes * and Fran¸ cois Caron and Jim E. Griffin and David A. Stephens § Abstract. In this article we describe Bayesian nonparametric procedures for two- sample hypothesis testing. Namely, given two sets of samples y (1) iid F (1) and y (2) iid F (2) , with F (1) ,F (2) unknown, we wish to evaluate the evidence for the null hypothesis H0 : F (1) F (2) versus the alternative H1 : F (1) 6= F (2) . Our method is based upon a nonparametric P´olya tree prior centered either subjectively or using an empirical procedure. We show that the P´ olya tree prior leads to an analytic expression for the marginal likelihood under the two hypotheses and hence an explicit measure of the probability of the null Pr(H0|{y (1) , y (2) }). Keywords: Bayesian nonparametrics, P´ olya tree, hypothesis testing 1 Introduction Nonparametric hypothesis testing is an important branch of statistics with wide appli- cability. For example we often wish to evaluate the evidence for systematic differences between real-valued responses under two different treatments without specifying an un- derlying distribution for the data. That is, given two sets of samples y (1) iid F (1) and y (2) iid F (2) , with F (1) ,F (2) unknown, we wish to evaluate the evidence for the competing hypotheses H 0 : F (1) F (2) versus H 1 : F (1) 6= F (2) . In this article we describe a nonparametric Bayesian procedure for this scenario. Our Bayesian method quantifies the weight of evidence in favour of H 0 in terms of an explicit probability measure Pr(H 0 |y (1,2) ), where y (1,2) denotes the pooled data y (1,2) = {y (1) , y (2) }. To perform the test we use a P´ olya tree prior (Lavine 1992; Mauldin et al. 1992; Lavine 1994) centered on some distribution G where under H 0 we have F (1,2) = F (1) = F (2) and under H 1 , F (1) 6= F (2) are modelled as independent draws from the P´ olya tree prior. In this way we frame the test as a model comparison problem and evaluate the Bayes Factor for the two competing models. The P´ olya tree is a well known nonparametric prior distribution for random probability measures F on Ω where Ω denotes the domain of Y (Ferguson 1974). Bayesian nonparametrics is a fast developing discipline, but while there has been considerable interest in nonparametric inference there has somewhat surprisingly been * Department of Statistics and Oxford-Man Institute, University of Oxford, England [email protected] Department of Statistics, University of Oxford, England [email protected] School of Mathematics, Statistics and Actuarial Science, University of Kent, England J.E.Griffin- [email protected] § Department of Mathematics and Statistics, McGill University, Canada [email protected] c 2004 International Society for Bayesian Analysis ba0001

Transcript of , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric...

Page 1: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

Bayesian Analysis (2004) 1, Number 1, pp. 1–24

Two-sample Bayesian NonparametricHypothesis Testing

Chris C. Holmes ∗ and Francois Caron † and Jim E. Griffin ‡ and David A. Stephens §

Abstract. In this article we describe Bayesian nonparametric procedures for two-sample hypothesis testing. Namely, given two sets of samples y(1) iid∼ F (1) andy(2) iid∼ F (2), with F (1), F (2) unknown, we wish to evaluate the evidence for the nullhypothesis H0 : F (1) ≡ F (2) versus the alternative H1 : F (1) 6= F (2). Our method isbased upon a nonparametric Polya tree prior centered either subjectively or usingan empirical procedure. We show that the Polya tree prior leads to an analyticexpression for the marginal likelihood under the two hypotheses and hence anexplicit measure of the probability of the null Pr(H0|y(1),y(2)).

Keywords: Bayesian nonparametrics, Polya tree, hypothesis testing

1 Introduction

Nonparametric hypothesis testing is an important branch of statistics with wide appli-cability. For example we often wish to evaluate the evidence for systematic differencesbetween real-valued responses under two different treatments without specifying an un-derlying distribution for the data. That is, given two sets of samples y(1) iid∼ F (1) andy(2) iid∼ F (2), with F (1), F (2) unknown, we wish to evaluate the evidence for the competinghypotheses

H0 : F (1) ≡ F (2) versus H1 : F (1) 6= F (2).

In this article we describe a nonparametric Bayesian procedure for this scenario. OurBayesian method quantifies the weight of evidence in favour of H0 in terms of an explicitprobability measure Pr(H0|y(1,2)), where y(1,2) denotes the pooled data y(1,2)= y(1)

,y(2).To perform the test we use a Polya tree prior (Lavine 1992; Mauldin et al. 1992; Lavine1994) centered on some distribution G where under H0 we have F (1,2) = F (1) = F (2) andunder H1, F (1) 6= F (2) are modelled as independent draws from the Polya tree prior.In this way we frame the test as a model comparison problem and evaluate the BayesFactor for the two competing models. The Polya tree is a well known nonparametricprior distribution for random probability measures F on Ω where Ω denotes the domainof Y (Ferguson 1974).

Bayesian nonparametrics is a fast developing discipline, but while there has beenconsiderable interest in nonparametric inference there has somewhat surprisingly been

∗Department of Statistics and Oxford-Man Institute, University of Oxford, [email protected]†Department of Statistics, University of Oxford, England [email protected]‡School of Mathematics, Statistics and Actuarial Science, University of Kent, England J.E.Griffin-

[email protected]§Department of Mathematics and Statistics, McGill University, Canada [email protected]

c© 2004 International Society for Bayesian Analysis ba0001

Page 2: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

2 Two-sample BNP Hypothesis Testing

little written on nonparametric hypothesis testing. Bayesian parametric hypothesis test-ing where F (1) and F (2) are of known form is well developed in the Bayesian literature,see e.g. Bernardo and Smith (2000), and most nonparametric work has concentratedon testing a parametric model versus a nonparametric alternative (the Goodness of Fitproblem). Initial work on the Goodness of Fit problem (Florens et al. 1996; Carotaand Parmigiani 1996) used a Dirichlet process prior for the alternative distribution andcompared to a parametric model. In this case, the nonparametric distributions will bealmost surely discrete, and the Bayes factor will include a penalty term for ties. Themethod can lead to misleading results if the data is absolutely continuous, and has mo-tivated the development of methods using nonparametric priors that guarantee almostsurely continuous distributions. Dirichlet process mixture models are one such class.The calculation of Bayes factors for Dirichlet process-based models is discussed by Basuand Chib (2003). Goodness of fit testing using mixtures of triangular distributions isconsidered by McVinish et al. (2009). An alternative form of prior, the Polya tree,was considered by Berger and Guglielmi (2001). Simple conditions on the prior lead toabsolutely continuous distributions. Berger and Guglielmi (2001) develop a default ap-proach and consider its properties as a conditional frequentist method. Hanson (2006)discusses the use of Savage-Dickey density ratios to calculate Bayes factors in favourof the centering distribution (see also Branscum and Hanson (2008)). Consistency is-sues are discussed by Dass and Lee (2004), Rousseau (2007), Ghosal et al. (2008) andMcVinish et al. (2009). There has been some work on testing the hypothesis that twodistributions are the same; Dunson and Peddada (2008) consider hypothesis testing ofstochastic ordering using restricted Dirichlet process mixtures, but their methods couldbe modified to allow two-sided hypotheses. They consider an interval null hypothesisand rely on Gibbs sampling for posterior computation. Pennell and Dunson (2008)develop a Mixture of Dependent Dirichlet Processes approach to testing changes in anordered sequence of distributions using a tolerance measure. Bhattacharya and Dunson(2012) develop an approach for nonparametric Bayesian testing of differences betweengroups, with the data within each group constrained to lie on a compact metric spaceor Riemannian manifold.

Recently, following work presented here (originally posted on arXiv in Holmes et al.(2009)), Ma and Wong (2011) propose to allow the two random distributions under thealternative to randomly couple on different parts of the sample space, thereby achievingborrowing of information. Moreover, Chen and Hanson (2014) propose to use Lavine’s(1992) partition for each F (j) centered at the normal distribution. Their approachenables generalization to more than two samples, but contrary to our approach requiresa truncation level to be set. They also follow Berger and Guglielmi (2001) by choosingthe parameter c that maximizes the Bayes factor in favor of the alternative.

The rest of the paper is as follows. In Section 2 we discuss the Polya tree priorand derive the marginal probability distributions that result from such a prior. InSection 3 we describe our method and algorithm for calculating Pr(H0|y(1,2)) based ona subjective partition. In Section 4 we discuss an empirical Bayes procedure where thePolya tree priors are centered on the empirical cdf of the joint data. Section 5 discussesthe sensibility of the procedures to tuning parameters. Section 6 provides a discussion

Page 3: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 3

B000 B001

B00

θ00 1− θ00

B010 B011

B01

θ01 1− θ01

B100 B101

B10

θ10 1− θ10

B110 B111

B11

θ11 1− θ11

B0

θ0 1− θ0

B1

θ1 1− θ1

Ω

θ 1− θ

Figure 1: Construction of a Polya tree distribution. Each of the θεm is independentlydrawn from Beta(αεm0, αεm1). Adapted from Ferguson (1974)

of related approaches and Section 7 concludes with a discussion of potential extensions.

2 Polya tree priors

Polya trees form a class of distributions for random probability measures F on somedomain Ω (Lavine 1992; Mauldin et al. 1992; Lavine 1994). Consider a recursive dyadic(binary) partition of Ω into disjoint measurable sets. Denote the kth level of the partitionB(k)

j , j = 0, . . . , 2k − 1, where B(k)

i ∩B(k)

j = ∅ for all i 6= j. The recursive partition is

constructed such that B(k)

j ≡ B(k+1)

2j ∪B(k+1)

2j+1 for k = 1, 2, . . . , j = 0, . . . , 2k− 1. Figure 1illustrates a bifurcating tree navigating the partition down to level three for Ω = [0, 1).It will be convenient to index the partition elements using base 2 subscript and dropthe superscript so that, for example, B000 indicates the first set in level 3, B0011 thefourth set in level 4 and so on.

To define a random measure on Ω we construct random measures on the sets Bj .It is instructive to imagine a particle cascading down through the tree such that at thejth junction the probability of turning left or right is θj and (1 − θj) respectively. Inaddition we consider θj to be a random variable with some appropriate distributionθj ∼ πj . The sample path of the particle down to level k will be recorded in a vectorεk = εk1, εk2, . . . , εkk with elements εki ∈ 0, 1, such that εki = 0 if the particle wentleft at level i, εki = 1 if it went right. Hence Bεk denotes which partition the particlebelongs to at level k. By convention, set ε0 = ∅. Given a set of θjs it is clear that theprobability of the particle falling into the set Bεk is just

P (Bεk) =

k∏i=1

(θεi−1)(1−εii)(1− θεi−1

)εii ,

which is just the product of the probabilities of falling left or right at each junction that

Page 4: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

4 Two-sample BNP Hypothesis Testing

the particle passes through. This defines a random measure on the partitioning sets.

Let Π denote the collection of sets B0, B1, B00, . . . and let A denote the collectionof parameters that determine the distribution at each junction, A = (α00, α01, α000, . . .).

Definition 2.1 Lavine (1992) A random probability measure F on Ω is said to havea Polya tree distribution, or a Polya tree prior, with parameters (Π,A), written F ∼PT (Π,A), if there exists nonnegative numbers A = (α0, α1, α00, . . .) and random vari-ables Θ = (θ, θ0, θ1, θ00, . . .) such that the following hold:

1. the random variables in Θ are mutually independent;

2. for every k = 1, 2, . . . and every εk ∈ 0, 1k,

θεk ∼ Beta(αεk0, αεk1);

3. for every k = 1, 2, . . . and every εk ∈ 0, 1k,

F (Bεk |Θ) =

k∏i=1

(θεi−1)(1−εii)(1− θεi−1

)εii . (1)

A random probability measure F ∼ PT (Π,A) is realized by sampling the θjs fromthe Beta distributions. Θ is countably infinite as the tree extends indefinitely, andhence for most practical applications the tree is specified only to a depth m. Lavine(1994) refers to this as a “partially specified” Polya tree. It is worth noting that we willnot need to make this truncation in what follows: our test will be fully specified withanalytic expressions for the marginal likelihood.1

By defining Π and A, the Polya tree can be centered on some chosen distribution Gso that E[F ] = G where F ∼ PT (Π,A). Perhaps the simplest way to achieve this is toplace the partitions in Π at the quantiles ofG and then set αεk0 = αεj1 for all k = 1, 2, . . .and all εk ∈ 0, 1k. (Lavine 1992). For Ω ≡ R this leads to B0 = (−∞, G−1(0.5)),B1 = [G−1(0.5),∞) and, at level k,

Bεk = [G−1(k∗ − 1)/2k, G−1(k∗/2k)), (2)

where k∗ is the decimal representation of the binary number εk.

It is usual to set the α’s to be constant in a level αεm0 = αεm1 = cm for someconstant cm. The setting of cm governs the underlying continuity of the resulting F ’s.For example, setting cm = cm2, c > 0, implies that F is absolutely continuous withprobability 1 while cm = c/2m defines a Dirichlet process which makes F discrete withprobability 1 (Lavine 1992; Ferguson 1974). We will follow the approach of Walker andMallick (1999) and define cm = cm2. The choice of c is discussed in Section 5.

1Note however that consistency results only hold for a truncated version of the proposed test.

Page 5: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 5

2.1 Conditioning and marginal likelihood

An attractive feature of the Polya tree prior is the ease with which we can condition ondata. Polya trees exhibit conjugacy: given a Polya tree prior F ∼ PT (Π,A) and datay drawn independently from F , then a posteriori F also has a Polya tree distribution,F |y ∼PT (Π,A∗) where A∗ is the set of updated parameters, A∗ = α∗00, α∗01, α∗000, . . .

α∗εi |y =αεi + nεi , (3)

where nεi denotes the number of observations in y that lie in the partition Bεi . Thecorresponding random variables θ∗j are therefore distributed a posteriori as

θ∗j |y = Beta(αj0 + nj0, αj1 + nj1) (4)

where nj0 and nj1 are the numbers of observations falling left and right at the junctionin the tree indicated by j. This conjugacy allows for a straightforward calculation ofthe marginal likelihood for any set of observations, as

Pr(y|Θ,Π,A) =∏j

θnj0j (1− θj)nj1 (5)

where θj |A ∼ Be(αj0, αj1) and where the product in (5) is over the set of all parti-tions, j ∈ 0, 1, 00, . . . , , though clearly for many partitions we have nj0 = nj1 = 0.Equation (5) has the form of a product of independent Binomial-Beta trials hence themarginal likelihood is,

Pr(y|Π,A) =∏j

(Γ(αj0 + αj1)

Γ(αj0)Γ(αj1)

Γ(αj0 + nj0)Γ(αj1 + nj1)

Γ(αj0 + nj0 + αj1 + nj1)

)(6)

where j ∈ 0, 1, 00, . . . , . This marginal probability will form the basis of our test forH0 which we describe in the next section.

3 A procedure for Bayesian nonparametric hypothesistesting

We are interested in providing a weight of evidence in favour of H0 given the observeddata. From Bayes theorem,

Pr(H0|y(1,2)) ∝ Pr(y(1,2)|H0)Pr(H0). (7)

Under the null hypothesis H0, y(1) and y(2) are samples from some common distributionF (1,2) with F (1,2) unknown. We specify our uncertainty in F (1,2) via a Polya tree prior,F (1,2) ∼ PT (Π,A). Under H1, we assume y(1) ∼ F (1), y(2) ∼ F (2) with F (1), F (2)

unknown. Again we adopt a Polya tree prior for F (1) and F (2) with the same priorparameterization as for F (1,2) so that

F (1), F (2), F (1,2) iid∼ PT (Π,A) (8)

Page 6: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

6 Two-sample BNP Hypothesis Testing

The logic for adopting a common prior distribution is that we regard the F s as randomdraws from some universe of distributions that we describe probabilistically through thePolya tree distribution. Π is constructed from the quantiles of some a priori centeringdistribution. Following the approach of Walker and Mallick (1999); Mallick and Walker(2003) we take common values for the αjs at each level as αj0 = αj1 = cm2 for an αparameter at level m.

The posterior odds on H0 is

Pr(H0|y(1,2))

Pr(H1|y(1),y(2))=

Pr(y(1,2)|H0)

Pr(y(1),y(2)|H1)

Pr(H0)

Pr(H1)(9)

where the first term is just the ratio of marginal likelihoods, the Bayes Factor, whichfrom (6) and conditional on our specification of Π and A, is

P (y(1,2)|H0)

P (y(1),y(2)|H1)=∏j

bj (10)

where

bj =Γ(αj0)Γ(αj1)

Γ(αj0 + αj1)

Γ(αj0 + n(1)

j0 + n(2)

j0 )Γ(αj1 + n(1)

j1 + n(2)

j1 )

Γ(αj0 + n(1)

j0 + n(2)

j0 + αj1 + n(1)

j1 + n(2)

j1 )

×Γ(αj0 + n(1)

j0 + αj1 + n(1)

j1 )

Γ(αj0 + n(1)

j0 )Γ(αj1 + n(1)

j1 )

Γ(αj0 + n(2)

j0 + αj1 + n(2)

j1 )

Γ(αj0 + n(2)

j0 )Γ(αj1 + n(2)

j1 )(11)

and the product in (10) is over all partitions, j ∈ ∅, 0, 1, 00, . . . , , n(1)

j0 and n(1)

j1 represent

the numbers of observations in y(1) falling right and left at each junction and n(2)

j0 and

n(2)

j1 are the equivalent quantities for y(2). We can see from (10) that the overall BayesFactor has the form of a product of Beta-Binomial tests at each junction in the treeto be interpreted as “does the data support one θj or two, θ(1)

j , θ(2)

j , in order tomodel the distribution of the observations going left and right at each junction?”, wherefor each j, θj ∼ Beta(αj , αj). The product in (10) is defined over the infinite set ofpartitions. However, for each branch j, bj = 1 if n(1)

j0 + n(1)

j1 = 0 or n(2)

j0 + n(2)

j1 = 0;hence to calculate (10) for the infinite partition structure we just have to multiplyterms from junctions which contain at least some data from the two sets of samples.Hence, we only need specify Π to the quantile level where partitions contain observationsfrom both samples. Note also that in the complete absence of data (that is, whenn(1)

j0 + n(2)

j0 = n(1)

j1 + n(2)

j1 = 0)

bj =Γ(αj0)Γ(αj1)

Γ(αj0 + αj1)

Γ(αj0)Γ(αj1)

Γ(αj0 + αj1)

Γ(αj0 + αj1)

Γ(αj0)Γ(αj1)

Γ(αj0 + αj1)

Γ(αj0)Γ(αj1)= 1

for all j, so the Bayes Factor is 1.

The test procedure is described in Algorithm 1.

Page 7: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 7

Algorithm 1 Bayesian nonparametric test

1. Fix the binary tree on the quantiles of some centering distribution G.

2. For level m = 1, 2, . . . , for each j set αj = cm2 for some c.

3. Add the log of the contributions of terms in (10) for each junction in the tree thathas non-zero numbers of observations in y(1,2) going both right and left.

4. Report Pr(H0|y(1,2)) as Pr(H0|y(1,2)) = 11+exp(−LOR) , where LOR denotes the log

odd ratio calculated at step 3.

3.1 Prior specification

The Bayesian procedure requires the specification of Π,A in the Polya tree. Whilethere are good guidelines for setting A the setting of Π is more problem specific, andthe results will be quite sensitive to this choice. Our current, default, guideline is tofirst standardise the joint data y(1,2) with the median and interquantile range of y(1,2)

and then set the partition on the quantiles of a standard normal density, Π = Φ(·)−1.We have found this to work well as a default in most situations, though of course thereader is encouraged to set Π according to their subjective beliefs.

In our algorithm, parameter c is treated as a fixed hyperparameter. As we demon-strate in Section 3.2, a truncated version of our test with a subjective partition is con-sistent under null and alternative hypotheses irrespective of the choice of c. However,c does have an impact on finite sample properties, that is, the finite sample posteriorprobabilities. This is always the case for Bayesian model selection/hypothesis testingbased on the marginal likelihood, which is effectively a measure of how well the priorpredicts the observed data, and not a feature restricted to our nonparametric procedure.In Section 5 we provide some guidelines on the sensitivity of the testing procedure tothe value of this parameter, and discuss empirical Bayes estimation of c.

3.2 Consistency

Conditions for the consistency of the procedure under the null hypothesis and alternativehypothesis are developed for a related test based on a truncation of the Bayes factor(9). Let n = n(1)

∅ +n(2)

∅ be the total sample size for both samples. Let l(ε) be the lengthof the vector ε. This also indicates that Bε forms part of the partition at level l(ε), andin our construction there are 2l(ε) partition elements at level l(ε). We consider the teststatistics based on the truncated Bayes factor

BFκ0=

∏j|l(j)≤κ0

bj (12)

Page 8: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

8 Two-sample BNP Hypothesis Testing

where κ0 ∈ N defines the level of truncation and can be set arbitrarily large. We alsoconsider a truncated version of the hypothesis test:

H0,κ0: ∀ε|l(ε) ≤ κ0, F (1)(Bε) = F (2)(Bε)

versus

H1,κ0: ∃ε|l(ε) ≤ κ0 and F (1)(Bε) 6= F (2)(Bε).

First, assume H0,κ0is true and let F0 denote the true distribution. To prove consis-

tency under H0,κ0, it is sufficient to show that

limn→∞

logBFκ0=∞

as n→∞ if both samples are drawn from the same distribution.

Theorem 3.1 Suppose that the limiting proportion of observations in the first sampleexists and is β∅:

β∅ = limn→∞

n(1)

∅n(1)

∅ + n(2)

∅. (13)

If 0 < β∅ < 1 then, under H0,κ0,

limn→∞

logBFκ0=∞

and the test defined by Algorithm 1, truncated at level κ0, is consistent under the null.

Proof.See Appendix.

We now consider consistency under H1,κ0for the truncated version of the test.

Theorem 3.2 Assume that 0 < β∅ < 1, and that exists Bε, l(ε) ≤ κ0, such that

F (1)(Bε)F(2)(Bε) > 0 and F (1)(Bε0)

F (1)(Bε)6= F (2)(Bε0)

F (2)(Bε). Then

limn→∞

BFκ0 = 0

and the test defined by Algorithm 1, truncated at level κ0, is consistent under the alter-native.

Proof.See Appendix.

The proofs for consistency for the non-truncated test are much more challenging,as one needs to bound terms at each level of the Polya tree. In the next section, weprovide numerical experiments on the evolution of the Bayes factor with respect to thesample size under both H0 and H1, suggesting consistency for the non-truncated test.

Page 9: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 9

3.3 Simulations

To examine the operating performance of the method we consider the following experi-ments designed to explore various canonical departures from the null.

a) Mean shift: Y (1) ∼ N (0, 1), Y (2) ∼ N (θ, 1), θ = 0, . . . , 3.

b) Variance shift: Y (1) ∼ N (0, 1), Y (2) ∼ N (0, θ2), θ = 1, . . . , 3.

c) Mixture: Y (1) ∼ N (0, 1), Y (2) ∼ 12N (θ, 1) + 1

2N (−θ, 1), θ = 0, . . . , 3.

d) Tails: Y (1) ∼ N (0, 1), Y (2) ∼ t(θ−1), θ = 10−3, . . . , 10 where t(ν) denotes thestandard Student t distribution with ν degrees of freedom.

e) Lognormal mean shift: log Y (1) ∼ N (0, 1), log Y (2) ∼ N (θ, 1), θ = 0, . . . , 3.

f) Lognormal variance shift: log Y (1) ∼ N (0, 1), log Y (2) ∼ N (0, θ2), θ = 1, . . . , 3.

The default mean distribution F (1,2)

0 = N (0, 1) was used in the Polya tree to constructthe partition Π and α = m2. Data are standardized. Comparisons are performed withn0 = n1 = 50 against the two-sample Kolmogorov-Smirnov and Wilcoxon rank test. Tocompare the models we explore the “power to detect the alternative”. As a test statisticfor the Bayesian model we simulate data under the null and then take the empirical0.95 quantile of the distribution of Bayes Factors as a threshold to declare H1. This isknown as “the Bayes, non-Bayes compromise” by Good (1992). Results, based on 1000replications, are reported in Figure 2. As a general rule we can see that the KS test ismore sensitive to changes in central location while the Bayes test is more sensitive tochanges to tails or higher moments.

The dyadic partition structure of the Polya Tree allows us to breakdown the contri-bution to the Bayes Factor by levels. That is, we can explore the contribution, in thelog of equation (10), by level. This is shown in Figure 3 as boxplots of the distributionof log BF statistics across the levels for the simulations generated for Figure 2. Thisis a strength of the Polya tree test in that it provides a qualitative and quantitativedecomposition of the contribution to the evidence against the null from differing levelsof the tree.

It is also of interest to investigate the behavior of the Bayes factor as a function ofthe sample size, both under the null and various alternatives. Under the alternative, weconsider in particular the following cases:

a) Mean shift: Y (1) ∼ N (0, 1), Y (2) ∼ N (1, 1).

b) Variance shift: Y (1) ∼ N (0, 1), Y (2) ∼ N (0, 4).

c) Tails: Y (1) ∼ N (0, 1), Y (2) ∼ t(1).

Page 10: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

10 Two-sample BNP Hypothesis Testing

0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(a) Gaussian: mean

1 1.5 2 2.5 3 3.5 4 4.5 50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(b) Gaussian: variance

0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(c) Gaussian: mixture

0 2 4 6 8 100

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(d) Gaussian: tail

0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(e) lognormal: mean

1 1.5 2 2.5 3 3.5 4 4.5 50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(f) lognormal: variance

Figure 2: Power of Bayes test with αj = m2 on simulations from Section 3.3., withx-axis measuring θ, the parameter in the alternative. Legend: K-S (dashed), Wilcoxon(dot-dashed), Bayesian test (solid).

Page 11: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 11

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(a) Gaussian: mean

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(b) Gaussian: variance

−16

−14

−12

−10

−8

−6

−4

−2

0

2

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(c) Gaussian: mixture

−25

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(d) Gaussian: tail

−20

−15

−10

−5

0

5

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(e) lognormal: mean

−10

−8

−6

−4

−2

0

2

4

6

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(f) lognormal: variance

Figure 3: Contribution to Bayes Factors from different levels of the Polya Tree underthe alternative. Gaussian distribution with varying (a) mean (b) variance (c) mixture(d) tails; log-normal distribution with varying (e) mean (f) variance, from Section 3.2.Parameters of H1 were set to the mid-points of the x-axis in Figure 2

Page 12: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

12 Two-sample BNP Hypothesis Testing

The results are reported in Figure 4 for sample size n = 10, 50, 100, 200 with 500 repli-cations, and seem to suggest that the non-truncated test is consistent under the nulland alternative.

4 A conditional procedure

The Bayesian procedure above requires the subjective specification of the partitionstructure Π. This subjective setting may make some users uneasy regarding the sensi-tivity to specification. In this section we explore an empirical procedure whereby thepartition Π is centered on the data via the empirical cdf of the joint data Π = [F (1,2)]−1.

Let Π be the partition constructed with the quantiles of the empirical distributionF (1,2) of y(1,2). Under H0, there are now no free parameters and only one degree offreedom in the random variables n(1)

j0 , n(1)

j1 , n(2)

j0 , n(2)

j1 as conditional on the partitioncentered on the empirical cdf of the joint, once one of the variables has been specifiedthe others are then known. We consider, arbitrarily, the marginal distribution of n(1)

j0 which is now a product of hypergeometric distributions (we only consider levels wheren(1,2)

j > 1)

Pr(n(1)

j0 |H0, Π,A) ∝∏j

(n(1)

j

n(1)

j0

)(n(1,2)

j − n(1)

j

n(1,2)

j0 − n(1)

j0

)/(n(1,2)

j

n(1,2)

j0

)(14)

=∏j

HG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0

)(15)

if max(0, n(1,2)

j0 + n(1)

j − n(1,2)

j ) ≤ n(1)

j0 ≤ min(n(1)

j , n(1,2)

j0 ), and zero otherwise.

Under H1, the marginal distribution of n(1)

j0 is a product of the conditional distri-bution of independent binomial variates, conditional on their sum,

Pr(n(1)

j0

∣∣H1, Π,A)∝∏j

g(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , θ(1)

j , θ(2)

j

)∑xg(x;n(1,2)

j , n(1)

j , n(1,2)

j0 , θ(1)

j , θ(2)

j

) (16)

if max(0, n(1,2)

j0 + n(1)

j − n(1,2)

j ) ≤ n(1)

j ≤ min(n(1)

j , n(1,2)

j0 ), zero otherwise, and where

g(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , θ(1)

j , θ(2)

j

)= Binomial

(n(1)

j0 ;n(1)

j , θ(1)

j

)× . . .

Binomial(n(1,2)

j0 − n(1)

j0 ;n(1,2)

j − n(1)

j , θ(2)

j

)and

θ(1)

j |A ∼ Beta(αj0, αj1) θ(2)

j |A ∼ Beta(αj0, αj1).

Now, consider the odds ratio ωj =θ(1)

j (1− θ(2)

j )

θ(2)

j (1− θ(1)

j )and let

EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj)

=g(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , θ(1)

j , θ(2)

j )∑xg(x;n(1,2)

j , n(1)

j , n(1,2)

j0 , θ(1)

j , θ(2)

j ).

Page 13: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 13

0 50 100 150 200 250−2

0

2

4

6

8

10

12

Sample size n

Log

Bay

es F

acto

r

(a) Null

0 50 100 150 200 250−50

−40

−30

−20

−10

0

10

Sample size n

Log

Bay

es F

acto

r

(b) Alternative: Mean

0 50 100 150 200 250−35

−30

−25

−20

−15

−10

−5

0

5

Sample size n

Log

Bay

es F

acto

r

(c) Alternative: Variance

0 50 100 150 200 250−25

−20

−15

−10

−5

0

5

Sample size n

Log

Bay

es F

acto

r

(d) Alternative: Tails

Figure 4: Mean Bayes factor and 90% confidence interval with respect to the samplesize n under (a) the null and (b-c) two Gaussian distributions with different (b) means,(c) variances and (d) a Gaussian and a student t.

Page 14: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

14 Two-sample BNP Hypothesis Testing

Then it can been seen that EHG(x;N,m, n, ω) is the extended hypergeometric distri-bution (Harkness 1965) whose pdf is proportional to

HG(x;N,m, n)ωx, a ≤ x ≤ b,

where a = max(0, n + m − N), b = min(m,n). Note there are C++ and R routinesto evaluate the pdf. The extended hypergeometric distribution models a biased urnsampling scheme whereby there is a different likelihood of drawing one type of ball overanother at each draw. The Bayes factor is now given by

BF =∏j

HG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0

)∫ ∞0

EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj)p(ωj)dωj

(17)

where the marginal likelihood in the denominator can be evaluated using importancesampling or one-dimensional quadrature.

The conditional Bayes two-sample test can then be given in a similar way to Algo-rithm 1 but now using (17) for the contribution at each junction. Conditions for theconsistency of the procedure under the null hypothesis are developed for a related testbased on a truncation of the Bayes factor (17) although we have been unable to showconsistency under the alternative.

Theorem 4.1 Consider the Bayes factor (17) truncated at level κ0

BFκ0 =∏

j : l(j)≤κ0

HG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0

)∫ ∞0

EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj)p(ωj)dωj

. (18)

Suppose that β∅ is as defined in Equation (13). If 0 < β∅ < 1 then, under H0,κ0,

limn→∞

logBFκ0 =∞

and the test is consistent under the null.

Proof.See Appendix

We repeated the simulations from Section 3.3 with α = m2. The results are shownin Figures 5 and 6. We observe similar behaviour to the test with subjective partitionbut importantly we see that the problem in detecting the difference between normaland t-distribution is corrected. Note that no standardisation of the data is required forthis test.

5 Sensitivity to the parameter c

The parameter c acts as a precision parameter in the Polya tree and consequently canhave an effect on the hypothesis testing procedures previously described. In principle,

Page 15: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 15

0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(a) Gaussian: mean

1 1.5 2 2.5 3 3.5 4 4.5 50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(b) Gaussian: variance

0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(c) Gaussian: mixture

0 2 4 6 8 100

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(d) Gaussian: tail

0 0.5 1 1.5 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(e) lognormal: mean

1 1.5 2 2.5 3 3.5 4 4.5 50

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

θ

Pow

er

Polya TreeKolmogorov−SmirnovWilcoxon

(f) lognormal: variance

Figure 5: As in Figure 2 but now using conditional Bayes Test with αj = m2.

Page 16: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

16 Two-sample BNP Hypothesis Testing

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(a) Gaussian: mean

−16

−14

−12

−10

−8

−6

−4

−2

0

2

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(b) Gaussian: variance

−10

−8

−6

−4

−2

0

2

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(c) Gaussian: mixture

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(d) Gaussian: tail

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(e) lognormal: mean

−25

−20

−15

−10

−5

0

1 2 3 4 5 6 7 8 9 10

Level

Con

trib

utio

n to

the

log

post

erio

r

(f) lognormal: variance

Figure 6: Contribution to the Bayes Factor for different levels of the conditional Polyatree prior for Gaussian distribution with varying (a) mean (b) variance (c) mixture (d)tails; log-normal distribution with varying (e) mean (f) variance.

Page 17: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 17

the parameter can be chosen subjectively as with precision parameters in other models(such as the linear model). Its effect is perhaps most easily understood through theprior variance of P (Bεk) which has the form (Hanson 2006)

Var [P (Bεk)] = 4−k

k∏j=1

2cj2 + 2

2cj2 + 1− 1

.The prior variance tends to zero as c→∞ and so the nonparametric prior places masson distributions which more closely resemble the centering distribution as c increases.Another consequence of this is that, under H1, c determines the a priori expectedsquared Euclidean distance between F (1)(Bεk) and F (2)(Bεk), where F (1) and F (2) arepresumed independently drawn from PT (Π,A); this distance diminishes as c increases:

E[(F (1)(Bεk)− F (2)(Bεk))2] = Var[F (1)(Bεk)

]+ Var

[F (2)(Bεk)

]= 4−k+

12

k∏j=1

2cj2 + 2

2cj2 + 1− 1

.

The value of c can be chosen to control the rate at which the variances decreases.We have found values of c between 1 and 10 work well in practice. Figures 7 and 8 showresults for different values of c. As with any Bayesian testing procedure, we recommendchecking the sensitivity of their results to the chosen value of the hyperparameter c.

An alternative approach to the choice of c in hypothesis testing is given by Bergerand Guglielmi (2001) in the context of testing a parametric model against a nonpara-metric alternative. They argue that the minimum of the Bayes factor in favour of theparametric model is useful since the parametric model can be considered satisfactoryif the “minimum is not too small”. It is the Bayes factor calculated using the empir-ical Bayes (Type II maximum likelihood) estimate of c. We suggest taking a similarapproach if c cannot be subjectively chosen. In the test with subjective partition, theempirical Bayes estimates c are calculated under H0 and under H1. Using these values,the Bayes factor can be interpreted as a likelihood ratio statistic for the comparison ofthe two hypotheses. In the conditional test, the empirical Bayes estimate is calculatedonly under H1 (since the marginal likelihood under H0 does not depend on c). Figures 7and 8 provide results for mean and variance shifts with c estimated over a fixed gridusing this procedure.

We also performed experiments to test the sensitivity of the procedure to the parti-tion. Experiments (not reported here) with a partition centered on a standard Studentt distribution showed little difference compared to a partition centered on a standardGaussian distribution.

Page 18: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

18 Two-sample BNP Hypothesis Testing

0 0.5 1 1.5 20

0.2

0.4

0.6

0.8

1

θ

Pow

er

c estimatedc=.1c=1c=10

(a) Gaussian: mean

1 2 3 4 50

0.2

0.4

0.6

0.8

1

θ

Pow

er

c estimatedc=.1c=1c=10

(b) Gaussian: variance

Figure 7: Subjective test with empirical Bayes estimation of the parameter c for (a)mean shift (b) variance shift. Point estimates of c are obtained by maximizing boththe marginal likelihood under the null and alternative over the grid of values 10i fori = −2,−1, . . . , 3.

0 0.5 1 1.5 20

0.2

0.4

0.6

0.8

1

θ

Pow

er

c estimatedc=.1c=1c=10

(a) Gaussian: mean

1 2 3 4 50

0.2

0.4

0.6

0.8

1

θ

Pow

er

c estimatedc=.1c=1c=10

(b) Gaussian: variance

Figure 8: Conditional test with empirical Bayes estimation of the parameter c for (a)mean shift (b) variance shift. Point estimate of c is obtained by maximizing the marginallikelihood under the alternative over the grid of values 10i for i = −2,−1, . . . , 3.

Page 19: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 19

6 Discussion and related work

There have been several other approaches to testing the difference between two distri-butions using Polya tree based approaches. Ma and Wong (2011) propose the CouplingOptional Polya tree (co-opt) prior which extends their previous work on Optional Polyatree priors (Wong and Ma 2010). The Optional Polya tree defines a prior for a singledistribution. A prior is defined on the sequence of partitions used to construct thePolya tree. This allows the partition to be concentrated on areas of the sample spacewhich have the largest difference from the base measure (which is the uniform in theircase). The co-opt prior is suitable for two distributions with a partition defined for eachdistribution. The prior allows coupling of two partitions so that if a set A (which ismember of the partition at level m) is coupled then all subsequent partitions of A willbe the same for the two distributions. This allows the posterior to concentrate thesecouplings on parts of the support of the two distributions where they are similar and soallows the borrowing of strength between the two distributions. The prior is conjugateand can be used to both test for differences between two distributions and to infer wherethese differences occur in the posterior. The prior is particularly suited to multivariateproblems due to its ability to efficiently learn the partition of the data. The posterior isavailable in closed form but can be computationally expensive to calculate in practicewith computational time scaling exponentially with sample size.

Chen and Hanson (2014) propose a method for comparing k-samples of data whichmay be censored. They test the null hypothesis that the distribution of each sample isthe same against the alternative that the samples arise from at least two different distri-butions. Under the null hypothesis, the common distribution is given a Polya tree priorwhereas, under the alternative hypothesis, each distribution is given an independentPolya tree prior. All Polya tree priors are centered over a normal distribution whoseparameters are estimated using maximum likelihood to define an empirical Bayes pro-cedure. Different partitions are used for the Polya tree distributions under the null andthe alternative hypotheses and so the partition must be truncated in order to computethe Bayes factor, contrary to our simpler approach which involves no truncation.

7 Conclusions

We have described a Bayesian nonparametric hypothesis test for real valued data whichprovides an explicit measure of Pr(H0|y(1,2)). The test is based on a fully specified Polyatree prior for which we are able to derive an explicit form for the Bayes Factor.

Conditioning on a particular partition can lead to a predictive distribution that ex-hibits jumps at the partition boundary points. This is a well-known phenomenon ofPolya tree priors and some interesting directions to mitigate its effects can be foundin Hanson and Johnson (2002); Paddock et al. (2003); Hanson (2006). We do not con-sider these approaches here as mixing over partitions would lose the analytic tractabilityof our approach, but it is an interesting area for future study and is considered by Chenand Hanson (2014).

Page 20: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

20 Two-sample BNP Hypothesis Testing

Acknowledgements

This research was partly supported by the Oxford-Man Institute (OMI) through a visitby FC to the OMI. FC thanks Pierre Del Moral for helpful discussions on the proofsof consistency and acknowledges the support of the European Commission under theMarie Curie Intra-European Fellowship Programme. DS acknowledges the support ofa Discovery Grant from the Natural Sciences and Engineering Council of Canada. Theauthors thank reviewers of earlier versions of this article for helpful comments.

ReferencesBasu, S. and Chib, S. (2003). “Marginal likelihood and Bayes factors for Dirichlet

process mixture models.” Journal of the American Statistical Association, 98: 224–235.

Berger, J. O. and Guglielmi, A. (2001). “Testing of a parametric model versus nonpara-metric alternatives.” Journal of the American Statistical Association, 96: 174–184.

Bernardo, J. M. and Smith, A. F. M. (2000). Bayesian theory . Chichester: John Wiley.

Bhattacharya, A. and Dunson, D. B. (2012). “Nonparametric Bayes Classification andHypothesis Testing on Manifolds.” Journal of multivariate analysis, 111: 1–19.

Branscum, A. J. and Hanson, T. J. (2008). “Bayesian nonparametric meta-analysisusing Polya tree mixture models.” Biometrics, 64: 825–833.

Carota, C. and Parmigiani, G. (1996). “On Bayes Factors for Nonparametric Alterna-tives.” In Bernardo, J. M., Berger, J. O., Dawid, A. P., and Smith, A. F. M. (eds.),Bayesian Statistics 5, 508–511. London: Oxford University Press.

Chen, Y. and Hanson, T. E. (2014). “Bayesian nonparametric k-sample tests for cen-sored and uncensored data.” Computational Statistics & Data Analysis, 71: 335–340.

Dass, S. C. and Lee, J. (2004). “A note on the consistency of Bayes factors for testingpoint null versus non-parametric alternatives.” Journal of Statistical Planning andInference, 119: 143–152.

Dunson, D. B. and Peddada, S. D. (2008). “Bayesian nonparametric inference onstochastic ordering.” Biometrika, 95: 859–874.

Ferguson, T. S. (1974). “Prior distributions on spaces of probability measures.” TheAnnals of Statistics, 2: 615–629.

Florens, J. P., Richard, J. F., and Rolin, J. M. (1996). “Bayesian Encompassing Specifi-cation Tests of a Parametric Model Against a Nonparametric Alternative.” TechnicalReport 96.08, Institut de Statistique, Universite Catholique de Louvain.

Ghosal, S., Lember, J., and Van der Vaart, A. (2008). “Nonparametric Bayesian modelselection and averaging.” Electronic Journal of Statistics, 2: 63–89.

Page 21: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 21

Good, I. J. (1992). “The Bayes/non-Bayes compromise: a brief review.” Journal of theAmerican Statistical Association, 87: 597–606.

Hanson, T. E. (2006). “Inference for mixtures of finite Polya tree models.” Journal ofthe American Statistical Association, 101: 1548–1565.

Hanson, T. E. and Johnson, W. O. (2002). “Modeling regression error with a mixtureof Polya trees.” Journal of the American Statistical Association, 97: 1020–1033.

Harkness, W. L. (1965). “Properties of the extended hypergeometric distribution.” TheAnnals of Mathematical Statistics, 36: 938–945.

Holmes, C. C., Caron, F., Griffin, J. E., and Stephens, D. A. (2009). “Two-sampleBayesian nonparametric hypothesis testing.” Technical report, arXiv:0910.5060[stat.ME].

Kass, R. and Raftery, A. (1995). “Bayes factors.” Journal of the American StatisticalAssociation, 90: 773–795.

Lavine, M. (1992). “Some aspects of Polya tree distributions for statistical modelling.”The Annals of Statistics, 20: 1222–1235.

— (1994). “More aspects of Polya tree distributions for statistical modelling.” TheAnnals of Statistics, 22: 1161–1176.

Ma, L. and Wong, W. H. (2011). “Coupling optional Polya trees and the two sampleproblem.” Journal of the American Statistical Association, 106(496): 1553–1565.

Mallick, B. K. and Walker, S. G. (2003). “A Bayesian semiparametric transformationmodel incorporating frailties.” Journal of Statistical Planning and Inference, 112:159–174.

Mauldin, R. D., Sudderth, W. D., and Williams, S. C. (1992). “Polya trees and randomdistributions.” The Annals of Statistics, 20: 1203–1221.

McVinish, R., Rousseau, J., and Mengersen, K. (2009). “Bayesian Goodness of Fit Test-ing with Mixtures of Triangular Distributions.” Scandinavian Journal of Statistics,36: 337–354.

Paddock, S. M., Ruggeri, F., Lavine, M., and West, M. (2003). “Randomized Polyatree models for nonparametric Bayesian inference.” Statistica Sinica, 13: 443–460.

Pennell, M. L. and Dunson, D. B. (2008). “Nonparametric Bayes Testing of Changes ina Response Distribution with an Ordinal Predictor.” Biometrics, 64: 413–423.

Rousseau, J. (2007). “Approximating Interval hypothesis : p-values and Bayes factors.”In Bernardo, J. M., Berger, J. O., Dawid, A. P., and Smith, A. F. M. (eds.), BayesianStatistics 8. Oxford University Press.

Walker, S. G. and Mallick, B. K. (1999). “A Bayesian semiparametric accelerated failuretime model.” Biometrics, 55: 477–483.

Page 22: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

22 Two-sample BNP Hypothesis Testing

Wilks, S. (1938). “The large-sample distribution of the likelihood ratio for testingcomposite hypotheses.” The Annals of Mathematical Statistics, 9: 60–62.

Wong, W. H. and Ma, L. (2010). “Optional Polya tree and Bayesian inference.” TheAnnals of Statistics, 38(3): 1433–1459.

Appendix: Proofs

Proof of Theorem 1

Clearly the log Bayes factor is

logBFκ0=

∑j|l(j)≤κ0

log b(n)j .

Stirling’s approximation of the Gamma function allows us to write

b(n)j 'Γ(αj0)Γ(αj1)

Γ(αj0 + αj1)

1√2π

(p(1,2)

j0

)αj0−1/2 (p(1,2)

j1

)αj1−1/2(p(1)

j0

)αj0−1/2 (p(1)

j1

)αj1−1/2 (p(2)

j0

)αj0−1/2 (p(2)

j1

)αj1−1/2×

√n(1)

j n(2)

j

n(1,2)

j

×(p(1,2)

j0

)n(1,2)j0

(p(1,2)

j1

)n(1,2)j1(

p(1)

j0

)n(1)j0(p(1)

j1

)n(1)j1(p(2)

j0

)n(2)j0(p(2)

j1

)n(2)j1

(19)

where

p(k)j0 =

n(k)j0

n(k)j0 + n

(k)j1

p(k)j1 = 1− p(k)j0 .

We have, under the null,√n(1)

j n(2)

j

n(1,2)

j

'√n√F0(Bj)β∅(1− β∅). (20)

The term

Lj =

(p(1,2)

j0

)n(1,2)j0

(p(1,2)

j1

)n(1,2)j1(

p(1)

j0

)n(1)j0(p(1)

j1

)n(1)j1(p(2)

j0

)n(2)j0(p(2)

j1

)n(2)j1

(21)

is a likelihood ratio for testing composite hypotheses

Hj0 : p(1)

j0 = p(2)

j0 = p(1,2)

j0 vs Hj1 :(p(1)

j0 , p(2)

j0

)∈ [0, 1]2

with n(1)

j0 ∼ Binomial(n(1)

j , p(1)

j0

)and n(2)

j0 ∼ Binomial(n(2)

j , p(2)

j0

). Clearly p(1,2)

j0 and(p(1)

j0 , p(2)

j0

)are the maximum likelihood estimators under Hj0 and Hj1 respectively. It

follows that, under Hj0, −2 logLj asymptotically follows a χ2 distribution (Wilks 1938).

Finally, if β∅(1− β∅) > 0 and using Equation (20), then Theorem 1 follows.

Page 23: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 23

Proof of Theorem 2

If F (1)(Bj) = 0 or F (2)(Bj) = 0, then we have trivially log(bj) = 0. We assume that

F (1)(Bj)F(2)(Bj) > 0 (22)

0 < β∅ < 1. (23)

If p(1)

j0 = p(2)

j0 then, from the previous section, log(bj) goes to∞ in o(log(n)). We consider

now the case p(1)

j0 6= p(2)

j0 .

Let β(n)j = n(1)

j /n(1,2)

j ,

βj = limn→∞

β(n)j =

β∅F(1)(Bj)

F (1,2)(Bj)

with F (1,2)(Bj) = β∅F(1)(Bj) + (1− β∅)F (2)(Bj). Under assumptions (22) and (23), we

have 0 < βj < 1. Let Lj be defined as in Equation (21). We have

logLj = ηj − n(1,2)

j ζj

whereηj = n(1,2)

j Hp(1,2)j0

(p(1,2)

j0

)− n(1)

j Hp(1)j0

(p(1)

j0

)− n(2)

j Hp(2)j0

(p(2)

j0

),

ζj = β(n)j H1

(p(1)

j0

)+(

1− β(n)j

)H1

(p(2)

j0

)−H1

(p(1,2)

j0

),

p(k)j0 = lim

n→∞p(k)j0 , k = 1, 2, 1, 2

and the function Hp : x ∈ (0, 1)→ R+ is defined for p ∈ (0, 1) by

Hp(x) = x log

(x

p

)+ (1− x) log

(1− x1− p

).

Consider first the term ζj . We have

p(1,2)

j0 = βjp(1)

j0 + (1− βj)p(2)

j0

and n −→∞, therefore

ζj −→ βjH1

(p(1)

j0

)+ (1− βj)H1

(p(2)

j0

)−H1

(p(1,2)

j0

).

As the function Hp is convex, it follows that ζj tends to a positive constant if p(1)

j0 6= p(2)

j0 .

Hence n(1,2)

j ζj tends to ∞ in o (n).

Consider now ηj which is approximately equal to

Yj =n(1,2)

j

2p(1,2)

j0

(1− p(1,2)

j0

) (p(1,2)

j0 − p(1,2)

j0

)2 − n(1)

j

2p(1)

j0

(1− p(1)

j0

) (p(1)

j0 − p(1)

j0

)2−

n(2)

j

2p(2)

j0

(1− p(2)

j0

) (p(2)

j0 − p(2)

j0

)2.

Page 24: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

24 Two-sample BNP Hypothesis Testing

Then

Yj =−n(1,2)

j β(n)j

(1− β(n)

j

)2p(1,2)

j0

(1− p(1,2)

j0

) [p(1)

j0 − p(2)

j0 −(p(1)

j0 − p(2)

j0

)]2+n(1,2)

j β(n)j

(1− ρ(1)

j

)2p(1,2)

j0

(1− p(1,2)

j0

) (p(1)

j0 − p(1)

j0

)2+n(1,2)

j

(1− β(n)

j

) (1− ρ(2)

j

)2p(1,2)

j0

(1− p(1,2)

j0

) (p(2)

j0 − p(2)

j0

)2where

ρ(k)j =

p(1,2)

j0

(1− p(1,2)

j0

)p(k)j0

(1− p(k)j0

) .We have asymptotically

Yj ' nF (1,2)(Bj)

(−βj (1− βj)

2p(1,2)

j0

(1− p(1,2)

j0

) [p(1)

j0 − p(2)

j0 −(p(1)

j0 − p(2)

j0

)]2+

βj(1− ρ(1)

j

)2p(1,2)

j0

(1− p(1,2)

j0

) (p(1)

j0 − p(1)

j0

)2+

(1− βj)(1− ρ(2)

j

)2p(1,2)

j0

(1− p(1,2)

j0

) (p(2)

j0 − p(2)

j0

)2).

We have a quadratic form

Yj ' −nF (1,2)(Bj)βj (1− βj)

2p(1,2)

j0

(1− p(1,2)

j0

) [ (p(1)

j0 − p(1)

j0

) (p(2)

j0 − p(2)

j0

) ]A

[ (p(1)

j0 − p(1)

j0

)(p(2)

j0 − p(2)

j0

) ]with square matrix

A =

ρ(1)

j − βj1− βj

−1

−1ρ(2)

j − 1 + βj

βj

and so asymptotically

√n

[ (p(1)

j0 − p(1)

j0

)(p(2)

j0 − p(2)

j0

) ] ∼ N02,

p(1)

j0

(1− p(1)

j0

)βjF (1,2)(Bj)

0

0p(2)

j0

(1− p(2)

j0

)(1− βj)F (1,2)(Bj)

which is independent of the sample size, and it follows that Yj asymptotically followsa scaled χ2 distribution and logLj goes to −∞ in o(n). To conclude, we have that inEquation (19) √

n(1)

j n(2)

j

n(1,2)

j

'√n√F (1,2)(Bj)βj(1− βj).

It follows that

Page 25: , Number 1, pp. 1{24 Two-sample Bayesian Nonparametric ...caron/Publications/Holmes_etal_Polyatree_v14… · A random probability measure F˘PT( ;A) is realized by sampling the js

C.C. Holmes et al. 25

• If F (1)(Bj)F(2)(Bj) = 0, log(bj) = 0.

• If F (1)(Bj)F(2)(Bj) > 0

– If p(1)

j0 6= p(2)

j0 , the log-contribution log(bj) goes to −∞ at a rate of o(n).

– If p(1)

j0 = p(2)

j0 , the log-contribution log(bj) goes to +∞ at a rate of o(log n).

Proof of Theorem 3

The condition β∅(1− β∅) implies that βj(1− βj) > 0 for all j. Let

b(n)j =

HG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0

)∫ ∞0

exp u(ωj) dωj(24)

where u(ωj) = log EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj)

+ log p(ωj). Then

logBFκ0 =∑

j|l(j)≤κ0

log b(n)j .

Under the conditions βj(1 − βj) > 0, the maximum likelihood estimate ωj of the pa-rameter ωj in the extended hypergeometric distribution converges in probability to thetrue parameter (Harkness 1965, p. 944). We can therefore use a Laplace approxima-tion (Kass and Raftery 1995) of the denominator in (24), we obtain for n(1)

j0 large

b(n)j '

HG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0

)√

2π|Σj |1/2 EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj)p (ωj)

where ωj = argmaxωju(ωj) and Σ−1j = −D2uj(ωj), where D2uj(ωj) is the Hessianmatrix of second derivatives. The ratio

rj =HG

(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0

)EHG

(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj) =

EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , 1)

EHG(n(1)

j0 ;n(1,2)

j , n(1)

j , n(1,2)

j0 , ωj)

is a likelihood ratio for testing the composite hypotheses

Hj0 : ωj = 1 vs Hj1 : ωj > 0,

hence −2 log rj is asymptotically χ2-distributed (Wilks 1938). And as |Σj | → 0 as

n→∞, then b(n)j →∞ for all j as n→∞.