b

DiscoverSearch
About
My stuff
Nearest Neighbor Dirichlet Mixtures
2020·arXiv
Abstract
Abstract

There is a rich literature on Bayesian methods for density estimation, which characterize the unknown density as a mixture of kernels. Such methods have advantages in terms of providing uncertainty quantification in estimation, while being adaptive to a rich variety of densities. However, relative to frequentist locally adaptive kernel methods, Bayesian approaches can be slow and unstable to implement in relying on Markov chain Monte Carlo algorithms. To maintain most of the strengths of Bayesian approaches without the computational disadvantages, we propose a class of nearest neighbor-Dirichlet mixtures. The approach starts by grouping the data into neighborhoods based on standard algorithms. Within each neighborhood, the density is characterized via a Bayesian parametric model, such as a Gaussian with unknown parameters. Assigning a Dirichlet prior to the weights on these local kernels, we obtain a pseudo-posterior for the weights and kernel parameters. A simple and embarrassingly parallel Monte Carlo algorithm is proposed to sample from the resulting pseudo-posterior for the unknown density. Desirable asymptotic properties are shown, and the methods are evaluated in simulation studies and applied to a motivating data set in the context of classification.

image

Bayesian nonparametric methods provide a useful alternative to black box machine learning algorithms, having potential advantages in terms of characterizing uncertainty in inferences and predictions. However, computation can be slow and unwieldy to implement. Hence, it is important to develop simpler and faster Bayesian nonparametric approaches, and hybrid methods that borrow the best of both worlds. For example, if one could use the Bayesian machinery for uncertainty quantification and reduction of mean square errors through shrinkage, while incorporating algorithmic aspects of machine learning approaches, one may be able to engineer a highly effective hybrid. The focus of this article is on proposing such an approach for density estimation, motivated by the successes and limitations of nearest neighbor algorithms and Bayesian mixture models.

Nearest neighbor algorithms are popular due to a combination of simplicity and performance. Given a set of n observations  X (n) = (X1, . . . , Xn) in Rp, the density at x is estimated as ˆfknn(x) = k/(nVpRpk), where kis the number of neighbors of  x in X (n), Rk = Rk(x) isthe distance of x from its kth nearest neighbor in  X (n) and Vpis the volume of the p-dimensional unit ball (Loftsgaarden and Quesenberry, 1965; Mack and Rosenblatt, 1979). Refer to Biau and Devroye (2015) for an overview of related estimators and corresponding theory.

Nearest neighbor density estimators are a type of locally adaptive kernel density estimators. The literature on such methods identifies two broad classes: balloon estimators and sample smoothing estimators; see Scott (2015); Terrell and Scott (1992) for an overview. Balloon estimators characterize the density at a query point x using a bandwidth function h(x); classical examples include the naive k-nearest neighbor density estimator (Loftsgaarden and Quesenberry, 1965) and its modification in Mack and Rosenblatt (1979). More elaborate balloon estimators face challenges in terms of choice of h(x) and obtaining estimators that do not integrate to 1. Sample smoothing estimators make use of n different bandwidths  h(Xi), one for each sample point  Xi, to estimate the density at a query point x globally. By construction, sample smoothing estimators are bona fide density functions integrating to 1. To fit either the balloon or the sample smoothing estimator, one may compute an initial pilot density estimator employing a constant bandwidth and then use this pilot to estimate the bandwidth function (Breiman et al., 1977; Abramson, 1982). Another example of a locally adaptive density estimator is the local likelihood density estimator (Loader, 1996, 2006; Hjort and Jones, 1996), which fits a polynomial model in the neighborhood of a query point x to estimate the density at x, estimating the parameters of the local polynomial by maximizing a penalized local log-likelihood function. The above methods produce a point estimate of the density without uncertainty quantification (UQ).

Alternatively, there is a Bayesian literature on locally adaptive kernel methods, which

express the unknown density as:

image

which is a mixture of m components, with the hth having probability weight  πhand kernel parameters  θh; by allowing the location and bandwidth to vary across components, local adaptivity is obtained. A Bayesian specification is completed with prior  P0for the kernel parameters and  Q0for the weights. In practice, it is common to rely on an over-fitted mixture model (Rousseau and Mengersen, 2011), which chooses m as a pre-specified finite upper bound on the number of components, and lets

image

By choosing  αclose to zero, this prior favors effective deletion of redundant components. Also, augmenting with component index  ci ∈ {1, . . . , m}, for i = 1, . . . , n, a simple Gibbs sampler can be used for posterior computation, alternating between sampling (i)  ci from amultinomial conditional posterior, for  i = 1, . . . , n; (ii) θh | − ∼ P0(θh) �i:ci=h K(Xi; θh);and (iii)  π | − ∼Dirichlet(α + n1, . . . , α + nm), with nh = �ni=1 I(ci = h) for h = 1, . . . , m.

Relative to frequentist locally adaptive methods, Bayesian approaches are appealing in automatically providing a characterization of uncertainty in estimation, while having excellent practical performance for a broad variety of density shapes and dimensions. However, implementation typically relies on Markov chain Monte Carlo (MCMC), with the Gibbs sampler sketched above providing an example of a common algorithm used in practice. Unfortunately, current MCMC algorithms for posterior sampling in mixture models tend to face issues with slow mixing, meaning the sampler can take a very large number of iterations to adequately explore different posterior modes and obtain sufficiently accurate posterior summaries.

MCMC inefficiency has motivated a literature on faster approaches, including sequential approximations (Wang and Dunson, 2011; Zhang et al., 2014) and variational Bayes (Blei and Jordan, 2006). These methods are order dependent, tend to converge to local modes, and/or lack theory support. Newton and Zhang (1999); Newton (2002) instead rely on predictive recursion. Such estimators are fast to compute and have theory support, but are also order dependent and do not provide a characterization of uncertainty. Alternatively, one can use a Polya tree as a conjugate prior (Lavine, 1992, 1994), and there is a rich literature on related multiscale and recursive partitioning approaches, such as the optional Polya tree (Wong and Ma, 2010). However, Polya trees have disadvantages in terms of sensitivity to a base partition and a tendency to favor spiky/erratic densities. These disadvantages are

inherited by most of the computationally fast modifications.

This article develops an alternative to current locally adaptive density estimators, obtaining the practical advantages of Bayesian approaches in terms of uncertainty quantification and a tendency to have relatively good performance for a wide variety of true densities, but without the computational disadvantage due to the use of MCMC. This is accomplished with a Nearest Neighbor-Dirichlet Mixture (NN-DM) model. The basic idea is to rely on fast nearest neighbor search algorithms to group the data into local neighborhoods, and then condition on these neighborhoods in defining a Bayesian mixture model-based approach. Section 2 outlines the NN-DM approach and describes implementation details for Gaussian kernels. Section 3 provides some theory support for NN-DM. Section 4 contains simulation experiments comparing NN-DM with a rich variety of competitors in univariate and multivariate examples, including an assessment of UQ performance. Section 5 contains a real data application, and Section 6 a discussion.

2.1 Nearest Neighbor Dirichlet Mixture Framework

Let  d(x1, x2) denote a distance metric between data points  x1, x2 ∈ X . For X = Rp, theEuclidean distance is typically chosen. For each  i ∈ {1, 2, . . . , n}, let Xi[j]denote the jth nearest neighbor to  Xiin the data  X (n) = (X1, . . . , Xn), such that  d(Xi, Xi[1]) ≤ . . . ≤d(Xi, Xi[n]), with ties broken by increasing order of indices. The indices on the k nearest neighbors to  Xiare denoted as  Ni = {j : d(Xi, Xj) ≤ d(Xi, Xi[k])}, where by convention we define  Xi[1] = Xi. Denote the set of data points in the i-th neighborhood by  Si = {Xj :j ∈ Ni}. In implementing the proposed method, we typically let the number of neighbors k vary as a function of n. When necessary we use the notation  knto express this dependence. However, we routinely drop the n subscript for notational simplicity.

Fixing  x ∈ X, we model the density of the data within the i-th neighborhood using

image

where  θiare parameters specific to neighborhood i that are given a global prior distribution P0. To combine the  fi(x)s into a single global f(x), similarly to equations (1)-(2), we let

image

The key difference relative to standard Bayesian mixture model (1) is that in (4) we include one component for each data sample and assume that only the data in the k-nearest neighborhood of sample i will inform about  θi. In contrast, (1) lacks any sample dependence, and we infer allocation of samples to mixture components in a posterior inference phase.

Given the restriction that only data in the i-th neighborhood  Siinform about  θi, thepseudo-posterior distribution of  θigiven data  Si and prior P0 is

image

This pseudo-posterior is in a simple analytic form if  P0is conjugate to  K(x; θ). The prior P0can involve unknown parameters and borrows information across neighborhoods; this reduces the large variance problem common to nearest neighbor estimators.

Since the neighborhoods are overlapping, the conditional posterior for  π under (4) isnot exactly Dirichlet. However, one can define the number of unique points in the i-th neighborhood  Sisimilar in spirit to the number of points in the h-th cluster in mixture models of the form (1). By convention, we define the point  Xithat generated its neighborhood  Sito be a member of that neighborhood. For any other data point  Xjto be a unique member of the neighborhood generated by  Xi for j ̸= i, we require  Xj ∈ Si but Xj /∈ Su for allu = 1, . . . , n such that u /∈ {j, i}. That is, Xjlies in the neighborhood generated by  Xi butdoes not lie in the neighborhood of any other  Xu. In Section 3.2, we show that the number of unique points defined as above approaches 1 as  n → ∞. This motivates the following Dirichlet pseudo-posterior update for the neighborhood weights  π:

image

This distribution is equivalent to the conditional posterior on the kernel weights in the Dirichlet mixture of equations (1)-(2), but we use n components and fix the effective number of samples allocated to each component at one. The Dirichlet distribution in (6) is centered on (1/n, . . . , 1/n) with concentration parameter  α+ 1. In practice,  αis typically chosen to be close to zero, as motivated in Section 1, and we let  k = knincrease slowly with the sample size.

Based on equations (3)-(6), our nearest neighbor-Dirichlet mixture produces a pseudo-posterior distribution for the unknown density f(x) through simple distributions for the parameters characterizing the density within each neighborhood and for the weights. To generate independent Monte Carlo samples from the pseudo-posterior for f, one can simply draw samples from (5) and (6) independently and plug these samples into the expression for f(x) in (4). Although this is not exactly a coherent fully Bayesian posterior distribution, we claim that it can be used as a practical alternative to such a posterior in practice. This claim is backed up by theoretical arguments, simulation studies and a real data application in the sequel.

2.2 Illustration with Gaussian Kernels

Suppose we have independent and identically distributed (iid) observations  X (n) from thedensity  f, where Xi ∈ Rp for i = 1, . . . , n and fis an unknown density function with respect to the Lebesgue measure on  Rp for p ≥ 1. Let Rp×p+denote the set of all real-valued  p × ppositive definite matrices. Fix  x ∈ Rp. We will illustrate the method for a general  p ≥ 1 andnote key changes for the special case p = 1. We proceed by setting  K(x; θ) to be the multivariate Gaussian density  φp(x; η, Σ) = (2π)−p/2|Σ|−1/2 exp {−(x − η)TΣ−1(x − η)/2}, whereθ = (η, Σ), η ∈ Rp and Σ ∈ Rp×p+ . We first compute the neighborhoods  Ni corresponding to  Xias in Section 2.1 and place a normal-inverse Wishart prior on  θi = (ηi, Σi), given by (ηi, Σi) ∼ NIWp(µ0, ν0, γ0, Ψ0) independently for  i = 1, . . . , n. That is, ηi | Σi ∼ N(µ0, Σi/ν0)and Σi ∼ IWp(γ0, Ψ0) with µ0 ∈ Rp, ν0 > 0, γ0 > p − 1 and Ψ0 ∈ Rp×p+ ; for details about parametrization see Section J of the Appendix.

For p = 1, we have a univariate Gaussian density  φ(x; ηi, σ2i ) in neighborhood i with normal-inverse gamma priors (ηi, σ2i ) ∼ NIG(µ0, ν0, γ0/2, γ0δ20/2) independently for i = 1, . . . , n, with µ0 ∈ R and ν0, γ0, δ20 > 0. That is, ηi | σ2i ∼ N(µ0, σ2i /ν0) and σ2i ∼IG(γ0/2, γ0δ20/2). When p= 1, the IWp(γ0, Ψ0) density simplifies to an IG(γ0/2, γ0δ20/2)density with  δ20 = Ψ0/γ0.

Monte Carlo samples from the pseudo-posterior of f(x) given the data  X (n) can beobtained using Algorithm 1. The corresponding steps for the univariate case are provided in Section I of the Appendix. Although the pseudo-posterior distribution of f(x) lacks an analytic form, we can obtain a simple form for its pseudo-posterior mean by integrating over the pseudo-posterior distribution of (θi)ni=1 and π.Recall the definitions of  µi andΨifrom Step 2 of Algorithm 1 and define Λi = {νn(γn − p + 1)}−1(νn + 1) Ψi. Then thepseudo-posterior mean of f(x) is given by

image

Here  tγ(x; µ, Λ) = [Γ{(γ + p)/2}/Γ(γ/2)] (γπ)−p/2 |Λ|−1/2[1 + (x − µ)T(γΛ)−1(x − µ)]−(γ+p)/2for  x ∈ Rp is the p-dimensional Student’s t-density with degrees of freedom  γ >0, location µ ∈ Rp and scale matrix Λ  ∈ Rp×p+ .For the univariate case, we have  γn and νn as in

image

Algorithm 1. The pseudo-posterior mean of f(x) is given by

image

where  µi = ν−1n (ν0µ0 + k ¯Xi), ¯Xi = k−1 �j∈Ni Xj, λi = δi{(νn + 1)/νn}1/2, δ2i = γ−1n {γ0δ20 +�j∈Ni(Xj− ¯Xi)2+kν0ν−1n (µ0− ¯Xi)2}. Here tγn(·) represents the univariate Student’s t-density with  γndegrees of freedom.

2.3 Hyperparameter Choice

The hyperparameters in the prior for the neighborhood-specific parameters need to be chosen carefully – we found results to be sensitive to  γ0 and Ψ0. If non-informative values are chosen for these key hyperparameters, we tend to inherit typical problems of nearest neighbor estimators including lack of smoothness and high variance. Suppose Σ  ∼ IWp(γ0, Ψ0) andfor  i, j = 1, . . . , p, let Σij and Ψ0, ijdenote the i, jth entry of Σ and Ψ0, respectively. Then Σjj ∼ IG(γ∗/2, Ψ0, jj/2) where γ∗ = γ0 − p+ 1. Thus borrowing from the univariate case, we set Ψ0, jj = γ∗δ20 and Ψ0, ij = 0 for all  i ̸= j, which implies that Ψ0 = (γ∗δ20) Ip and weuse leave-one-out cross-validation to select the optimum  δ20. With pdimensional data, we recommend fixing  γ0 = pwhich implies a multivariate Cauchy prior predictive density. We choose the leave-one-out log-likelihood as the criterion function for cross-validation, which is closely related to minimizing the Kullback-Leibler divergence between the true and estimated density (Hall, 1987; Bowman, 1984). The explicit expression for the pseudo-posterior mean in equations (7) and (8) makes cross-validation computationally efficient. The description of a fast implementation is provided in Section H of the Appendix.

The proposed method has substantially faster runtime if one bypasses cross-validation and uses a default choice of hyperparameters. In particular, we found the default values µ0 = 0p, ν0 = 0.001, γ0 = p and Ψ0 = Ipto work well across a number of simulation cases, especially when the true density is smooth. Although using cross-validation to estimate  δ20can lead to improved performance when the underlying density is spiky, cross-validation provides little to no gains for smooth true densities. Furthermore, with low sample size and increasing number of dimensions, we found this gap to diminish rapidly.

The other key tuning parameter for NN-DM is the number of nearest neighbors  k = kn.The pseudo-posterior mean in (7) reduces to a single  tγn−p+1 kernel if kn = n. In contrast, kn= 1 provides a sample smoothing kernel density estimate with a specific bandwidth function (Terrell and Scott, 1992). Therefore, the choice of k can impact the smoothness of the density estimate. To assess the sensitivity of the NN-DM estimate to the choice of k, we investigate how the out-of-sample log-likelihood of a test set changes with respect to k in Section 4.7. These simulations suggest that the proposed method is quite robust to the exact choice of k. In practice with finite samples and small dimensions, we recommend a default choice of  kn = ⌊n1/3⌋ + 1 and kn= 10 for univariate and multivariate cases, respectively. These values led to good performance across a wide variety of simulation cases as described in Section 4.

3.1 Asymptotic Properties

There is a rich literature on asymptotic properties of the posterior measure for an unknown density under Bayesian models, providing a frequentist justification for Bayesian density estimation; refer, for example to Ghosal et al. (1999), Ghosal et al. (2007). Unfortunately, the tools developed in this literature rely critically on the mathematical properties of fully Bayes posteriors, providing theoretical guarantees for a computationally intractable exact posterior distribution under a Bayesian model. Our focus is instead on providing frequentist asymptotic guarantees for our computationally efficient NN-DM approach, with this task made much more complex by the dependence across neighborhoods induced by the use of a nearest neighbor procedure.

We first focus on proving pointwise consistency of the pseudo-posterior of f(x) induced by (3)-(6) for each  x ∈ [0, 1]p, using Gaussian kernels as in Section 2.2. We separately study the mean and variance of the NN-DM pseudo-posterior distribution, first showing that the pseudo-posterior mean in (7) is pointwise consistent and then that the pseudo-posterior variance vanishes asymptotically. The key idea behind our proof is to show that the pseudo-posterior mean is asymptotically close to a kernel density estimator with suitably chosen bandwidth for fixed  p and kn → ∞at a desired rate. The proof then follows from standard arguments leading to consistency of kernel density estimators. The NN-DM pseudo-posterior mean mimics a kernel density estimator only in the asymptotic regime; in finite sample simulation studies (refer to Section 4), NN-DM has much better performance. The detailed proofs of all results in this section are in the Appendix.

Consider independent and identically distributed data  X (n) from a fixed unknown density f0with respect to the Lebesgue measure on  Rp equipped with the Euclidean metric, inducing the measure  Pf0 on B(Rp). We use E{f(x) | X (n)}, var{f(x) | X (n)} and pr{f(x) ∈ B | X (n)}to denote the mean of f(x), variance of f(x) and probability of the event  {f(x) ∈ B} forB ∈ B(Rp), respectively, under the pseudo-posterior distribution of f(x) implied by equations (3)-(6). We make the following regularity assumptions on  f0:

image

Assumption 3.2 (Bounded gradient). f0is continuous on [0, 1]p with ||∇f0(x)||2 ≤ L forall  x ∈ [0, 1]p and some finite L > 0.

Assumption 3.3 (Bounded sup-norm). || log(f0)||∞ < ∞.

Our asymptotic analysis relies on analyzing the behaviour of the pseudo-posterior updates within each nearest neighborhood. We leverage on key results from Biau and Devroye (2015); Evans et al. (2002) which are based on the assumption that the true density has compact support as in Assumption 3.1. Assumption 3.2 ensures that the kernel density estimator has finite expectation. Versions of this assumption are common in the kernel density literature; for example, refer to Tsybakov (2004). Assumptions 3.1 and 3.3 imply the existence of 0  < a1, a2 < ∞such that 0  < a1 < f0(x) < a2 < ∞ for all x ∈ [0, 1]p, which isreferred to as a positive density condition by Evans (2008); Evans et al. (2002). This is used to establish consistency of the proposed method, justify the choice of the pseudo-posterior distribution of the weights, and obtain our tuning algorithm for the Dirichlet prior concentration parameter  α. These assumptions are standard in the literature studying frequentist asymptotic properties of nearest neighbor and Bayesian density estimators.

For i = 1, . . . , n, recall the definitions of  µi and Λi from (7):

image

where  νn = ν0 + kn, γn = γ0 + kn, and ¯Xi, Ψiare as in Algorithm 1. Define the bandwidth

matrix  Hn = h2nIp where

image

We have suppressed the dependence of  µi and Λi on nfor notational convenience. It is immediate that  h2n → 0 if kn → ∞ as n → ∞. Fix x ∈ [0, 1]p. To prove consistency of the pseudo-posterior mean, we first show that ˆfn(x) and fK(x) = (1/n) �ni=1 tγn−p+1(x; Xi, Hn)are asymptotically close, that is we show that  EPf0( | ˆfn(x) − fK(x)| ) → 0 as n → ∞. Toobtain this result, we approximate  µi by Xi and Λi by Hnusing successive applications of the mean value theorem. Finally, we exploit the convergence of  fK(x) to the true value  f0(x)to obtain the consistency of ˆfn(x). The proof of convergence of  fK(x) to f0(x) is provided in Section G of the Appendix. The precise statement regarding the consistency of the pseudo-posterior mean is given in the following theorem. Let  a ∧ bdenote the minimum of a and b.

image

that  kn → ∞ as n → ∞, and ν0 = o{n−2/pk(2/p)+1n }. Then, ˆfn(x) → f0(x) in Pf0-probability as  n → ∞.

We now look at the pseudo-posterior variance of f(x). We let

image

Rn = Γ{(γn − p + 2)/2}Γ{(γn − p + 1)/2}

For  i = 1, . . . , n, let Bi = DnΛi and define

image

As  n → ∞, we have Dn → 1/2. Analogous steps to the ones used in the proof of Theorem 3.4 can be used to imply that �fvar(x) → f0(x) in Pf0-probability. Also, as  n → ∞, k(p−1)/2n Rn →(4π)−1/2 using Stirling’s approximation. We now provide an upper bound on the pseudo-posterior variance of f(x) which shows convergence of the pseudo-posterior variance to 0.

Theorem 3.5. Let Hnbe the bandwidth matrix defined in (9). Let  Rn, Dn be as in (10) and�fvar be as in (11). Under Assumptions 3.1-3.3 with  x, kn and ν0as in Theorem 3.4, we have

image

Refer to Sections B and C in the Appendix for proofs of Theorems 4 and 5, respectively. Pointwise pseudo-posterior consistency follows directly from Theorems 3.4 and 3.5 as shown below.

Theorem 3.6. Let f0satisfy Assumptions 3.1-3.3 with  x, kn and ν0as in Theorem 3.4. Fix ǫ > 0and define the  ǫ-ball around  f0(x) by Uǫ = {y∗ : |y∗ − f0(x)| ≤ ǫ}. Let pr{f(x) ∈ Ucǫ |X (n)}denote the probability of the set  Ucǫ under the pseudo-posterior distribution of f(x) as induced by equations (3)-(6). Then pr{f(x) ∈ Ucǫ | X (n)} → 0 in Pf0-probability as  n → ∞.

Proof. Fix ǫ >0 and consider the  ǫ-ball Uǫ = {y∗ : |y∗ − f0(x)| ≤ ǫ}. Then by Chebychev’s inequality, we have pr{f(x) ∈ Ucǫ | X (n)} ≤ [{ ˆfn(x) − f0(x)}2 + var{f(x) | X (n)}]/ǫ2 −→ 0 inPf0-probability as  n → ∞, using Theorems 3.4 and 3.5.

Our next result focuses on the limiting distribution of g(x), corresponding to a simplified form of the NN-DM which sets the weights  πto their pseudo-posterior mean,

image

where we focus on the univariate case with Gaussian kernels. From Section I of the Appendix, the pseudo-posterior distribution of (ηi, σ2i ) for i = 1, . . . , nis given by NIG(µi, νn,γn/2, γnδ2i /2), where µi, νn, γnare as before and

image

We show that the limiting distribution of g(x) is a Gaussian distribution with appropriate centering and scaling. This allows interpretation of 100(1  −β)% pseudo-credible intervals as 100(1−β)% frequentist confidence intervals on average for large n. Use of simplified versions of the original estimator to derive asymptotic distribution results is standard in the Bayesian nonparametric literature; refer to Chapter 12 of Ghosal and Van der Vaart (2017). Let  f (l)0denote the l-th derivative of  f0 for l ≥ 1.

Theorem 3.7. For a fixed  x ∈ [0, 1], let g(x)denote the simplified NN-DM estimator in (13). Suppose  f0satisfies Assumptions 3.1-3.3 and also satisfies  |f (4)0 (x)| ≤ C0 for all x ∈ [0, 1]for some finite  C0 > 0. Let kn satisfy kn = o(n2/7) such that n−2/9kn → ∞, and h2n be as in(9) satisfying  h2n → 0, as n → ∞. For t ∈ R, define

image

image

For a proof of Theorem 3.7, we refer the reader to Section D of the Appendix.

3.2 Pseudo-Posterior Distribution of Weights

We investigate the rationale behind the pseudo-posterior update of the weight vector  π,which has a symmetric prior distribution  π ∼Dirichlet(α, . . . , α) as motivated in Section 1. As discussed in Section 1, the conditional update for the weights  πin a finite Bayesian mixture model with m components given the cluster allocation indices  {c1, . . . , cn}is obtained by Dirichlet(α + n1, . . . , α + nm), where αis the prior concentration parameter and  nh =�ni=1 I(ci = h) is the number of data points allocated to the h-th cluster. This is not true in our case as the  kn-nearest neighborhoods have considerable overlap between them. Instead, we consider the number of unique data points in each of these neighborhoods.

Define the  kn-nearest neighborhood of  Xito be the set  Si = {Xj : d(Xi, Xj) ≤ d(Xi, Xi[kn])}where  Xi[kn] is the kn-th nearest neighbor of  Xiin the data  X (n), following the notation in Section 2.1. We assume  d(·, ·) is the Euclidean metric from here on, and let  Ri = d(Xi, Xi[kn]) =||Xi − Xi[kn]||2denote the distance of  Xi from its kn-th nearest neighbor in  X (n).

Let  Nidenote the number of unique members in  Sias defined in Section 2.1. Then, we can express  Ni as

image

where I(A) is the indicator function of the set  A. Under X1, . . . , Xniid∼ f0, we have

image

by symmetry. Furthermore,  Niare identically distributed for i = 1, . . . , n. We now state a result which provides a motivation for our choice of the pseudo-posterior update of  π. Fortwo sequences of real numbers (an) and (bn), we write  an ∼ bn if |an/bn| → c0 as n → ∞ forsome constant  c0 > 0.

Theorem 3.8. Suppose X1, . . . , Xniid∼ f0 with f0satisfying Assumptions 3.1-3.3. Furthermore, suppose that  kn ∼ ni0−ǫ for some ǫ ∈ (0, i0), where i0is as defined in Theorem 3.4.

image

Proof of Theorem 3.8 is in Section E of the Appendix. The above theorem suggests we asymptotically have only one unique member per neighborhood  Si, namely the point  Xi thatitself generated this neighborhood. This result motivates our choice of the pseudo-posterior update of the weight vector  π.We illustrate uncertainty quantification of the proposed method in finite samples in Section 4.4 with this choice of pseudo-posterior update of the weight vector  π.

3.3 Choice of Dirichlet Prior Parameter

Although Theorem 3.6 implies consistency of the pseudo-posterior for fixed  x and any α,the choice of  αimpacts frequentist coverage of the pseudo-posterior credible intervals as it directly influences the pseudo-posterior variance of f(x) through Theorem 3.5. We now describe a data-dependent method to choose  αusing Bernstein-von Mises results for linear functionals of Bayesian density estimators in the univariate setup (Rivoirard and Rousseau, 2012). The key idea we adopt is to consider a linear functional  P( ˜f) of the density ˜f such as its mean, obtain its Bernstein-von Mises limit distribution using the result in Rivoirard and Rousseau (2012), and equate the variance of this limit distribution with the pseudo-posterior variance of P(f) when f has the NN-DM formulation.

Let ˜p and f0satisfy conditions in Rivoirard and Rousseau (2012). Define the linear functional  P( ˜f) = � ˜p(u) ˜f(u) dufor a generic density ˜f on R. Suppose X1, . . . , Xn areindependent and identically distributed data from a density  f0supported on [0, 1]. Define q(u) = ˜p(u)−� ˜p(v)f0(v) dv and let Fnbe the empirical distribution function of  X1, . . . , Xn.Then under a suitable prior distribution on ˜f, Rivoirard and Rousseau (2012) show that the posterior distribution of  n1/2{P( ˜f) − P(Fn)}is asymptotically Gaussian with mean 0 and variance Ω0 =�q2(x)f0(x) dx, where P(Fn) = n−1 �ni=1 ˜p(Xi).

As a specific example, consider the case when ˜p(u) = u, corresponding to the linear functional given by  P( ˜f) =�u ˜f(u) du. Following Rivoirard and Rousseau (2012), the limiting variance of the posterior distribution of  n1/2{P( ˜f) − P(Fn)}under a suitable prior on ˜f is given by Ω0 =�(u − mf0)2f0(u) du = σ2f0 where mf0 =�uf0(u) duis the population mean and  σ2f0 is the population variance of the density  f0. This provides the asymptotic variance of  P( ˜f) = �u ˜f(u) dufor an appropriate Bayesian density estimator ˜f. Our strategy for finding a value of  αinvolves equating the pseudo-posterior variance of  n1/2P(f) with σ2f0when f has the NN-DM formulation, as  n → ∞. This is done to ensure that  n1/2P(f) hasthe same limiting variance as  n1/2P( ˜f), where fis the proposed estimator and ˜f is a valid Bayesian density estimator according to Rivoirard and Rousseau (2012). When f has the NN-DM formulation with Gaussian kernels,  P(f) =�uf(u) du = �ni=1 πiηi, following from Section 2.2, with the variance of  n1/2P(f) provided below.

Theorem 3.9. Suppose f0satisfies Assumptions 3.1-3.3 with p = 1. Let f have the NNDM formulation, and  kn, ν0be chosen as in Theorem 3.4. Let Θ =�uf(u) du = �ni=1 πiηias in Section 2.2. For  γn > 2, define vi = {(νn + 1)(γn − 2)}−1γnλ2i for i = 1, . . . , n,¯v = (1/n) �ni=1 vi, ¯µ = (1/n) �ni=1 µi and S2µ = (1/n) �ni=1(µi − ¯µ)2. Then

image

The proof of Theorem 3.9 and derivation of (17) are in Section F of the Appendix. Due to the lack of a multivariate analogue of the result discussed in Rivoirard and Rousseau

(2012), a choice of  αwhen data are multivariate is not immediate. We observe that the univariate choice of  αmay be written as  α ≈ h2n/(σ2f0νn) when nis large with  h2n in (9). Tothat end, let  Hn = h2nIp be the multivariate bandwidth matrix as defined in Section 3.1 and Σf0be the unknown population covariance matrix of  f0. Then, one may potentially extend the findings of (17) to a multivariate extension given by

image

It is immediate that the choice of  αin the multivariate case as in (18) reduces to the choice in (17) for  p = 1. Once δ20 is estimated according to Section 2.3 and the underlying population variance is estimated, one can use (17) or its multivariate analogue (18) to select an appropriate value of  α.

4.1 Preliminaries

In this section, we compare the performance of the proposed density estimator with several other standard density estimators through several numerical experiments. We evaluate performance based on the expected  L1distance (Devroye and Gyorfi, 1985). For the pair (f0, ˆf), where f0is the true data generating density and ˆf is an estimator, the expected L1distance is defined as  L1(f0, ˆf) = EPf0{�|f0(x) − ˆf(x)| dx}. Given a sample size n, we compute an estimate ˆL1(f0, ˆf) of L1(f0, ˆf) in two steps. First, we sample  X1, . . . , Xn ∼ f0and obtain ˆf based on this sample, and then further sample  ntindependent test points Xn+1, . . . , Xn+nt ∼ f0and compute

image

In the second step, to approximate the expectation with respect to  Pf0, the first step is repeated R times. Letting ˆLrdenote the estimate for the rth replicate, we compute the final estimate as ˆL1(f0, ˆf) = (1/R) �Rr=1 ˆLr. Then, it follows that ˆL1(f0, ˆf) → L1(f0, ˆf) asnt, R −→ ∞, by the law of large numbers. In our experiments, we set  nt = 500 and R = 20.We let 0p and 1pdenote the vector with all entries equal to 0 and the vector with all entries equal to 1 in  Rp, respectively, for  p ≥ 1.

All simulations were carried out using the R programming language (R Core Team, 2018). For Dirichlet process mixture models, we collect 2, 000 Markov chain Monte Carlo (MCMC) samples after discarding a burn-in of 3, 000 samples using the dirichletprocess package (J. Ross and Markwick, 2019). The default implementation of the Dirichlet process mixture model in p dimensions in the dirichletprocess package uses multivariate Gaussian kernels and has the base measure as NIWp(0p, p, p, Ip) with the Dirichlet concentration parameter having the Gamma(2, 4) prior (West, 1992). For the nearest neighbor-Dirichlet mixture, 1, 000 Monte Carlo samples are taken. For the kernel density estimator, we select the bandwidth by the default plug-in method hpi for univariate cases and Hpi for multivariate cases (Sheather and Jones, 1991; Wand and Jones, 1994) using the package ks (Duong, 2020). We additionally consider the k-nearest neighbor estimator studied in Mack and Rosenblatt (1979), setting the number of neighbors  k = n1/2, and the variational Bayes (VB) approximation to Dirichlet process mixture models (Blei and Jordan, 2006). We also compare with the optional Polya tree (OPT) (Wong and Ma, 2010) using the package PTT. For univariate cases, we consider the recursive predictive density estimator (RD) from Hahn et al. (2018), Polya tree mixtures (PTM) using the package DPpackage (Jara et al., 2011), and the sample smoothing kernel density estimator (A-KDE) using the package quantreg. Lastly, we also compare with the local likelihood density estimator (LLDE) using the package locfit for both univariate and multivariate cases. Dirichlet process mixture model hyperparameter values are kept the same in both the MCMC and variational Bayes implementations, with the number of components of the variational family set to 10 for all cases. We denote the nearest neighbor-Dirichlet mixture, Dirichlet process mixture (DPM) implemented with MCMC, kernel density estimator, variational Bayes approximation to the DPM, and k-nearest neigh-

image

Figure 1: Box plots of ˆL1(f0, ˆf) for the 10 different choices of the true density  f0and different estimators ˆf for univariate data. The box plots for KDE and RD exclude the heavy-tailed cases CA, IE, and SP.

bor density estimator by NN-DM, DP-MC, KDE, DP-VB and KNN, respectively, in tables and figures.

4.2 Univariate Cases

We set  n = 200, 500 with kn = ⌊n1/3⌋+1 where ⌊n0⌋denotes the greatest integer less than or equal to  n0. We consider 10 choices of  f0 from the R package benchden (Mildenberger and Weinert, 2012); the specific choices are Cauchy (CA), claw (CW), double exponential (DE), Gaussian (GS), inverse exponential (IE), lognormal (LN), logistic (LO), skewed bimodal (SB), symmetric Pareto (SP), and sawtooth (ST) with default choices of the corresponding parameters. The prior hyperparameter choices for the proposed method are  µ0 = 0, ν0 = 0.001, γ0 = 1;δ20 is chosen via the cross-validation method of Section 2.3. Detailed numerical results are deferred to Table 3 in the Appendix. Instead, in Figure 1, we provide a visual summary of the performance of each method under consideration by forming a box plot of the estimated L1errors of the methods across all the data generating densities. Methods with lower median as indicated by the solid line of the box plot, and smaller overall spread are preferable as they provide higher accuracy and also maintain such accuracy across a collection of true density cases. Results of KNN are omitted in Figure 1 due to much higher values compared to other methods. For the KDE and RD estimator, the plot and the table exclude the results for the heavy-tailed densities CA, IE and SP due to very high  L1 errors.

Overall, a major advantage of the proposed method is its versatility among the considered methods. The Bayesian nonparametric methods DP-MC, DP-VB, PTM, OPT, and RD are often close to NN-DM in terms of their performance when the true densities are smooth and do not display locally spiky behavior. However, the NN-DM performs better than other methods in densities where such local behavior is present and performs very close to the best estimator for either the smooth heavy-tailed or thin-tailed densities. The KDE and RD perform well when data are generated from a smooth underlying density. However, there are some cases where the error for KDE and RD is very high. For instance, when n = 500 and f0is the standard Cauchy (CA) density, the estimated  L1error for the KDE is 38501.85 and the algorithm for the RD estimate did not converge. Both the KDE and RD also perform poorly in very spiky multi-modal densities such as the ST. Compared to the LLDE and the A-KDE, the NN-DM displays similar performance in heavy-tailed and smooth densities when n = 200, with the NN-DM performing better for the spiky densities. However, when n = 500, the NN-DM shows significant improvements over the LLDE and the A-KDE for spiky densities such as the CW and the ST.

In Figure 2, we show the performance of the NN-DM estimator ˆfn(with hyperparameters chosen as described earlier) relative to the posterior mean under a DP-MC with default or hand-tuned hyperparameters, when 500 data points are generated from the sawtooth (ST) density. The Dirichlet process mixture with default hyperparameters is unable to detect the multiple spikes, merging adjacent modes to form larger clusters, perhaps due to inadequate mixing of the Markov chain Monte Carlo sampler or to the Gaussian kernels used in the mixture. As a result, we had to hand-tune the hyperparameters for the Dirichlet process mixture to obtain comparable performance with the NN-DM (without hand-tuning). We obtained the best results when changing the hyperparameters of the base measure of the DPMC to NIG(0, 0.01, 1, 1) while keeping the prior on  αthe same as before. This illustrates the deficiency of the DP-MC in estimating densities with spiky local behavior unless we hand-tune the hyperparameters, which requires knowledge of the true density. We also compare the performance of the two methods with a smoother test density in Figure 3, where the data are generated from a skewed bimodal (SB) distribution. Both the estimates are comparable, but the nearest neighbor-Dirichlet mixture provides better uncertainty quantification. Similar results are obtained for n = 1000, and hence are omitted.

4.3 Multivariate Cases

For the multivariate cases, we consider n = 200 and 1000. The number of neighbors is set to k = 10 and the dimension p is chosen from {2, 3, 4, 6}. Recall the definition of  φp(x; µ, Σ)from Section 2.2 and let Φ(x) be the cumulative distribution function of the standard Gaussian density. Let  S0 = ρ 1p1Tp + (1 − ρ) Ip with ρ = 0.8. Let x = (x1, . . . , xp)T. We consider the following cases.

(1)  Mixture of Gaussians (MG): f0(x) = 0.4 φp(x; m1, S0) + 0.6 φp(x; m2, S0), where m1 =−2 × 1p, m2 = 2 × 1p.

image

Figure 2: Plot comparing density estimates for the NN-DM and DP-MC for n = 500 samples generated from the sawtooth (ST) density. Shaded regions correspond to 95% (pseudo) posterior credible intervals. The true density is displayed using dotted lines. The top panel shows the performance of DP-MC with default hyperparameters on the left and with hand-tuned hyperparameters on the right. The bottom panel shows the performance of the NNDM.

image

Figure 3: Similar to Figure 2, with data of sample size n = 500 generated from the skewed bimodal (SB) density. Left panel shows the NN-DM fit and the right panel shows the DP-MC fit.

(2)  Skew normal (SN): f0(x) = 2φp(x; m0, S0)Φ{sT0W −1(x − m0)} (Azzalini, 2005), where Wis the diagonal matrix with diagonal entries  W 2ii = S0, ii for i = 1, . . . , p. We choose  m0 = 0pand the skewness parameter vector  s0 = 0.5 × 1p.(3)  Multivariate t-distribution (T): f0(x) = td0(x; m∗, S0) is the density of the p-dimensional multivariate Student’s t-distribution as in Section 2.2. We set  d0 = 10 and m∗ = 1p.(4) Mixture of multivariate skew t-distributions (MST): We consider a two component mixture of multivariate skew t-distribution (Azzalini, 2005) given by  f0(x) = 0.25 td0(x; m1, S0, s0)+0.75 td0(x; m2, S0, s0). Here, td(· ; µ, S, s) is the skew t-density with parameters  d, µ, S, s, withd0, s0defined as before and  m1, m2the same as in the first case. (5)  Multivariate Cauchy (MVC): f0(x) ∝ {1 + (x − µ∗)TS−10 (x − µ∗)} where µ∗ = 0p.(6)  Multivariate Gamma (MVG): f0(x) ∝ cΦ(F1(x1), . . . , Fp(xp) | S0) �pj=1 fj(xj; γj1, γj2)where  fj and Fjdenote the density and distribution function of the univariate gamma distribution with shape parameter  γj1and rate parameter  γj2, respectively, for j = 1, . . . , p and cΦ(· |Γ) is as described in Song (2000). This is a Gaussian copula based construction of the multivariate gamma distribution. We set  γj1 = γj2 = 1 for j = 1, . . . , p.

The hyperparameters for the nearest neighbor-Dirichlet mixture are chosen as  µ0 =0p, ν0 = 0.001, γ0 = p and Ψ0 = {(γ0 − p + 1)δ20}Ip = δ20 Ip, where the optimal  δ20 is chosen via cross-validation as described in Section 2.3. Default hyperparameters as described in Section 4.1 are chosen for the MCMC and VB implementations of the DPM.

Similar to the univariate case, we defer the numerical results to Table 4 in the Appendix and in Figure 4 display a visual summary consisting of box plot of  L1errors over the densities considered. The proposed method is very robust against a wide selection of true distributions, with its  L1error scaling nicely with the dimension. The KDE shows a noticeably sharp decline in performance - when the dimension is changed from 2 to 6, the average increase in  L1error is by factors of about 5 and 7 for sample sizes 200 and 1000, respectively. This is possibly due to lack of adaptive density estimation in higher dimensions using a single bandwidth matrix, since data in  Rp become increasingly sparse with increasing p. As in the univariate case, we had to exclude the MVC density for the KDE due to the algorithm not converging. The performances of NN-DM, DP-MC, and DP-VB are quite competitive across densities, with NN-DM faring better than the DP-VB when estimating densities such as the MVC and the MVG. Furthermore, the NN-DM is hit the least significantly by the curse of dimensionality out of the three. This is particularly prominent when n = 200 and p = 6 for the DP-MC when the true density is either MG or MST, and for the DP-VB when the true density is MVC. It is also important to keep in mind that the NN-DM provides similar results compared to the DP-MC while being at least an order of magnitude faster, as illustrated in Section 4.6. The performance of the OPT is hit quite significantly as the number of dimensions increases, along with the algorithm not converging for p = 6. The

image

Figure 4: Box plots of ˆL1(f0, ˆf) for the 6 different choices of the true density  f0and different estimators ˆf for multivariate data. The box plots for KDE and LLDE exclude the MVC density. The box plots for p = 6 exclude results from OPT.

LLDE provides competitive results with the NN-DM in lower dimensions. However, in higher dimensions, the LLDE often does not converge, indicating lack of stability of the algorithm. We reported the average of the replicates for which the algorithm did converge. The results suggest that the performance of the LLDE is also affected quite drastically with increasing dimensions. When compared across all data generating cases considering the variation in densities, dimensions and sample sizes, the proposed method is seen to be more versatile than its competitors.

4.4 Accuracy of Uncertainty Quantification

In this section, we assess frequentist coverage of 95% pseudo-posterior credible intervals for the NN-DM and compare with coverage based on the 95% posterior credible intervals obtained from DP-MC and DP-VB. Ghosal and Van der Vaart (2017) recommend investigating the frequentist coverage of Bayesian credible intervals. We do not include frequentist coverage for Polya tree mixtures (PTMs) and the optional Polya tree (OPT) due to the lack of available code. We consider the cases  p ∈ {1, 2}in our experiments with sample size n = 500. For each choice of density  f0, we fix nt= 200 test points  Xt = {Xt1, . . . , Xtnt}generated from the density  f0. With these fixed test points, we generate n = 500 data points in our sample for  Rcov= 200 times and check the coverage of posterior/pseudo-posterior credible intervals obtained from the three methods. We implement the DP-MC with base measure NIWp(0p, 0.01, p, Ip) and a Gamma(2, 4) prior on the concentration parameter as in West (1992). These choices of hyperparameters were seen to give better frequentist coverage results than using the default values used in Sections 4.2 and 4.3. Same choices of hyperparameters are maintained for DP-VB. For the NN-DM we take k = 8 in the univariate case, k = 5 in the bivariate case,  αas in Section 3.3 and other hyperparameters chosen as before. In Table 1 and in Table 2, we report the average coverage probability and average length of the (pseudo) credible intervals across all the points in the test data  Xtfor the univariate and bivariate cases, respectively.

For univariate densities, both the DP-MC and DP-VB display severe under-coverage. In most of the cases, the DP-VB and NN-DM have similar width of (pseudo) credible intervals but the DP-VB displays dramatically lower coverage than the NN-DM. The under-coverage displayed by the DP-MC may be due to MCMC mixing issues. The NN-DM shows near nominal coverage in the smooth Gaussian (GS) and lognormal (LN) densities, while also attaining near nominal coverage in the skewed bimodal (SB), claw (CW) and sawtooth (ST) densities which are multi-modal. The shortcomings of DP-MC and DP-VB are especially noticeable when dealing with spiky densities such as the claw or sawtooth. For bivariate cases considered in Table 2 we see a similar trend; the NN-DM method provides uniformly better uncertainty quantification across all the densities considered. It is clear that in terms

image

Table 1: Comparison of the frequentist coverage of 95% (pseudo) posterior credible intervals of the nearest neighbor-Dirichlet mixture and the MCMC and variational implementations of the Dirichlet process mixture for univariate data. Average length of the intervals are also provided for each case within parentheses. Number of replications and sample size are Rcov = 200 and ncov= 500, respectively.

image

Table 2: Comparison of the frequentist coverage of 95% (pseudo) posterior credible intervals of the nearest neighbor-Dirichlet mixture and the MCMC and variational implementations of the Dirichlet process mixture for bivariate data. Average length of the intervals are also provided for each case within parentheses. Number of replications and sample size are Rcov = 200 and ncov= 500, respectively.

of frequentist uncertainty quantification, the NN-DM displays vastly superior coverage to the DP-MC and the DP-VB without inflating the interval width.

4.5 Comparison for high dimensional data

In addition to the above experiments, we performed a simulation experiment for high-dimensional data. Specifically, we set p = 50 and consider the same set of true densities in Section 4.3. We compared results from the proposed NN-DM method and the DP-VB. Due to severe computational time, we did not consider the DP-MC in this scenario. We

image

Figure 5: Out-of-sample log-likelihood of NN-DM and DP-VB on a test set of 500 points for 6 different multivariate densities considered in Section 4.3, for n = 1000 and p = 50.

also tried optional Polya trees (Wong and Ma, 2010) using the PTT package; however, the current implementation of the method breaks down in this high-dimensional setup. Due to numerical instability in computing the  L1error in higher dimensions, we evaluate the methods in terms of their out-of-sample log-likelihood (OOSLL) instead (Gneiting and Raftery, 2007), on a test set of 500 data points. We report the average OOSLL over 30 replications in Figure 5. The results indicate that both methods perform very similarly in terms of out-of-sample fit to the data, with the NN-DM outperforming the DP-VB when the true density is MVC. We also observed that for this experiment, the NN-DM methods with default choice of hyperparameters and with cross-validated choice of Ψ0have almost identical performance. For the NN-DM, we set k = 12 after carrying out a sensitivity analysis on k by considering k = 5, 7, 10, 15, and 20. The best results for the NN-DM were obtained for  k ∈ {7, 10, 12}with negligible difference in out-of-sample log-likelihoods between these three choices, with k = 12 performing the best.

4.6 Runtime Comparison

The results in the previous subsection suggest that the DP-VB has dramatic under-coverage with respect to the nominal frequentist coverage. Hence, the VB approach is not useful for uncertainty quantification. For this reason, we focus our comparison of runtimes on the NN-DM and the DP-MC, noting that VB algorithms are faster than either of these approaches.

With n data points in p dimensions, the initial nearest neighbor allocation into n neighborhoods can be carried out in O(n log n) steps (Vaidya, 1986; Ma and Li, 2019). Once the neighborhoods are determined with  knpoints in each neighborhood, obtaining the neighborhood specific empirical means and covariance matrices has  O(nknp + nknp2) = O(nknp2)complexity. Obtaining the pseudo-posterior mean (7) then requires inversion of  n such p × pmatrices to evaluate the multivariate t-density, with a runtime of  O(np3). Therefore, the total runtime to obtain the pseudo-posterior mean is of the order  O(nknp2 + np3). When weare interested in uncertainty quantification, we require Monte Carlo samples of the NN-DM, which are independently drawn from its pseudo-posterior. This involves sampling the Dirichlet weights, the neighborhood specific unknown mean and covariance matrix parameters of the Gaussian kernel, and evaluating a Gaussian density for each neighborhood, as outlined in Algorithm 1. To obtain M Monte Carlo samples, the combined complexity of this step is thus  O(Mn + Mnp3) = O(Mnp3). Overall the runtime complexity to obtain NN-DM samples is therefore  O(Mnp3+nknp2+np3). For high dimensional scenarios, this runtime can be greatly improved by using a low rank matrix factorization of both the neighborhood specific empirical covariance matrix and the sampled covariance matrix parameter to make matrix inversion more efficient (Golub and van Loan, 1996). We now provide a detailed simulation study of runtimes of the proposed method.

In our experiments, we focus on p = 1 and p = 4. The runtime for NN-DM consists of the time to estimate  δ20 by cross-validation as in Section 2.3 and then drawing samples from its pseudo-posterior. For both dimensions, the sample size is varied from n = 200 to n = 1500 in increments of 100. Data are generated from the standard Gaussian density (GS) for p = 1 and from a mixture of skew t-distributions with the parameters as described for the case MST in Section 4.3 for p = 4. For p = 1, we evaluate the two methods at 500 test points, while for p = 4 we evaluate the methods at 200 test points. The hyperparameters are kept the same as in Sections 4.2 and 4.3. We took 1000 Monte Carlo samples for the NN-DM and 2500 MCMC samples for the DP-MC with a burn-in of 1500 samples. The simulations were carried out on an i7-8700K processor with 16 gigabytes of memory.

In the top panel of Figure 6, we plot the average of the logarithm of the run times of each approach for 10 independent replications. The corresponding average  L1error of the two methods is also included in the bottom panel of Figure 6. The NN-DM is at least an order of magnitude faster than DP-MC. The time saved becomes more pronounced in the multivariate case, where for sample size 1500 the NN-DM is  ∼15 times faster. The gain in computing time does not come at the cost of accuracy as can be seen from the right panel; the proposed method maintains the same order of  L1error as the DP-MC in the univariate case and often outperforms the DP-MC in the multivariate case. We did not implement the Monte Carlo sampler for the proposed algorithm in parallel, but such a modification would substantially improve runtime. Bypassing cross-validation and choosing default hyperparameters instead as outlined in Section 2.3, NN-DM took 7.7 seconds and 28.4 seconds when p = 1 and p = 4, respectively, with sample size n = 1500. In the same

image

Figure 6: Runtime comparison of DP-MC and NN-DM in univariate case and for 4-dimensional data. Top panel shows runtimes in log scale whereas bottom panel shows corresponding  L1error. Sample size n is varied from 200 to 1500 in increments of 100.

scenario, DP-MC took 291.3 seconds and 1504.4 seconds for p = 1 and p = 4, respectively. Thus the NN-DM with default hyperparameters is about 38 times faster when p = 1 and about 53 times faster when p = 4.

4.7 Sensitivity to the choice of k

In this subsection, we investigate the role of  kn = kin finite samples for the proposed method. We consider n = 200 samples from the SP density in the univariate case and the MG density in the bivariate case. In each case, we fix a test set of  nt= 500 points, and evaluate the out-of-sample log-likelihood (OOSLL) of the test points for 20 different integer values of k ranging from 2 to 50. Finally, we report results averaged from 10 independent replicates of this setup. We note that for each considered value of k, the parameter  δ20 wasestimated using leave-one-out cross-validation. Figure 7 shows how the OOSLL averaged over replicates changes as a function of k for each density considered. The original OOSLL values of the test data points were scaled by the number of test points  nt= 500 for better representability.

For the univariate SP density, the optimal value of k which maximizes the average OOSLL is �k= 9. This is close to the choice of k = 6 as taken in Section 4.2. For the bivariate MG density, we observe that the choice of k maximizing the OOSLL is �k= 12, which is also close to the choice of k = 10 as taken in Section 4.3. For both the univariate and the bivariate

image

Figure 7: Average out-of-sample log-likelihood of 500 test points for the NN-DM as a function of k for one-dimensional and two-dimensional data. Number of samples and number of replications are n = 200 and R = 10, respectively.

case, the out-of-sample log-likelihood of the test set shows little variation with changing k. This indicates that the estimates obtained from the proposed method are quite robust to the particular choice of k.

We apply the proposed density estimator to binary classification. Consider data D = {(Xi, Yi) : i = 1, . . . , n}, where Xi ∈ Rp are p-dimensional feature vectors and  Yi ∈ {0, 1}are binary class labels. To predict the probability that  y0= 1 for a test point  x0, we use

Bayes rule:

image

where ˜fj(x0) is the feature density at  x0 in class j and pr(y0 = j) is the marginal probability of class j, for j = 0, 1. Based on  nttest data, we let  �pr(y0 = 1) = (1/nt) �nti=1 Yi, with�pr(y0 = 0) = 1 − �pr(y0= 1), and use either the NN-DM pseudo-posterior mean ˆfn(·), theDP-MC posterior mean ˆfDP(·), or the DP-VB posterior mean ˆfVB(·) for estimating the within class densities. We omit the kernel density estimator as to the best of our knowledge, no routine R implementation is available for data having more than 6 dimensions. We compare the resulting classification performances in terms of sensitivity, specificity and probabilistic calibration.

The high time resolution universe survey data (Keith et al., 2010) contain information on sampled pulsar stars. Pulsar stars are a type of neutron stars and their radio emissions are detectable from the Earth. These stars have gained considerable interest from the scientific community due to their several applications (Lorimer and Kramer, 2012). The data are

image

Figure 8: Sensitivity and specificity of the NN-DM, DP-MC, and DP-VB for the universe survey data.

publicly available from the University of California at Irvine machine learning repository. Stars are classified into pulsar and non-pulsar groups according to 8 attributes (Lyon, 2016). There are a total of 17898 instances of stars, among which 1639 are classified as pulsar stars. We create a test data set of 200 stars, among which 23 are pulsar stars. The training size is then varied from 300 to 1800 in increments of 300, each time adding 300 training points by randomly sampling from the entire data leaving out the initial test set. In Figure 8, we plot the sensitivity and specificity of the three methods in consideration. All the methods exhibit similar sensitivity across various training sizes; the DP-MC has marginally better specificity for training sizes 1200 and 1500, while the NN-DM has better specificity for training sizes 300 and 600. Both the NN-DM and the DP-MC exhibit higher specificity and sensitivity than the DP-VB across all training sample sizes considered. We also compare the methods using the Brier score, a proper scoring rule (Gneiting and Raftery,

2007) for probabilistic classification. Suppose for  nttest points and the ith Monte Carlo sample,  pidenotes the sampled  nt ×1 probability vector for a generic method. We compute the normalized Brier score for the ith sample as (1/nt) ||pi − Yt||22, where Ytis the vector of class labels in the test set. Then with T samples of  pi, i = 1, . . . , T, we compute the mean Brier score for the three methods considered. The mean Brier score for each training size is shown in the right panel of Figure 9, which naturally shows a declining trend with increasing training size. There is little to choose between the three classifiers in terms of mean Brier score; the proposed method fairs equally well in terms of calibration of estimated test set probabilities with the MCMC implementation of the Dirichlet process. In the left panel of Figure 9, the receiver operating characteristic curve of the methods is shown for 1800 training samples. The area under the curve (AUC) for the NN-DM, the DP-MC and the DP-VB are 0.96, 0.95 and 0.96, respectively. For 1800 training samples, the computation time for the proposed method is about 13 minutes while for the DP-MC it is approximately 5 hours.

image

Figure 9: Left plot shows the receiver operating characteristic curve of the NN-DM, DP-MC, and DP-VB with 1800 training samples. Area under the curve is abbreviated as AUC. Right plot shows normalized Brier scores for the methods with varying training sample size.

image

Figure 10: Left and right plot show the out-of-sample log-likelihoods of NN-DM, DP-MC, and DP-VB for the two different star types.

Hence, the proposed method is much faster, even without exploiting parallel computation. We also fitted the proposed method using the training set of all 17698 points; DP-MC was too slow in this case. The sensitivity and specificity of the proposed method increased to 0.99 and 0.91, respectively. We additionally evaluated the methods in terms of the out-of-sample log-likelihood. The results are displayed in Figure 10. While the methods perform comparably in terms of their classification performance, NN-DM achieves a better fit overall, especially for the significantly less prevalent pulsar star type.

The proposed nearest neighbor-Dirichlet mixture provides a useful alternative to Bayesian density estimation based on Dirichlet mixtures with much faster computational speed and stability in avoiding MCMC. MCMC can have very poor performance in mixture models and other multimodal cases, due to difficulty in mixing, and hence can lead to posterior inferences that are unreliable. There is a recent literature attempting to scale up MCMCbased analyses in model-based clustering contexts including for Dirichlet process mixtures; refer, for example to Song et al. (2020) and Ni et al. (2020). However, these approaches are complex to implement and are primarily focused on the problem of clustering, while we are instead focused on flexible modeling of unknown densities.

The main conceptual disadvantage of the proposed approach is the lack of a coherent Bayesian posterior updating rule. However, we have shown that nonetheless the resulting pseudo-posterior can have appealing behavior in terms of frequentist asymptotic properties, finite sample performance, and accuracy in uncertainty quantification. In addition, it is important to keep in mind that Bayesian kernel mixtures have key disadvantages that are difficult to remove within a fully coherent Bayesian modeling framework. These include a strong sensitivity to the choice of kernel and prior on the weights on these kernels; refer, for example to Miller and Dunson (2019).

There are several important next steps. The first is to develop fast and robust algorithms for using the nearest neighbor-Dirichlet mixture not just for density estimation but also as a component of more complex hierarchical models. For example, one may want to model the residual density in regression nonparametrically or treat a random effects distribution as unknown. In such settings, one can potentially update other parameters within a Bayesian model using Markov chain Monte Carlo, while using algorithms related to those proposed in this article to update the nonparametric part conditionally on these other parameters.

R package NNDM available at https://github.com/shounakchattopadhyay/NN-DM was used for the numerical experiments. This research was partially supported by grants R01ES027498 and R01ES028804 of the United States National Institutes of Health and grant N00014-16-1-2147 of the Office of Naval Research.

We first introduce some notation with accompanying technical details which will be used hereafter. We define the Frobenius norm of the  p × p matrix Awith real-valued entries by ||A||F = {tr(ATA)}1/2 and denote its determinant by |A|. We observe that, for a vector v ∈ Rp, one has ||vvT||F = ||v||22 where ||a||2 = (aTa)1/2is the Euclidean norm of a. For two symmetric  p × p matrices A and B, we say that  A ≥ B if A − Bis positive semi-definite, that is  xT(A − B)x ≥ 0 for all x ∈ Rp, x ̸= 0p where 0p = (0, . . . , 0)T ∈ Rp. For a symmetric matrix  A∗, let the eigenvalues of  A∗be denoted by  e1(A∗), . . . , ep(A∗), arranged such that e1(A∗) ≥ . . . ≥ ep(A∗). If A ≥ B, then it follows by the min-max theorem (Teschl, 2009) that, for each  j = 1, . . . , p, we have ej(A) ≥ ej(B). In particular, we have  |A| ≥ |B| and||A||F ≥ ||B||F.

Now consider independent and identically distributed data  X1, . . . , Xn ∼ f0supported on the interval [0, 1]p and satisfying Assumptions 3.1-3.3 as mentioned in Section 3.1. Let  X (n) =(X1, . . . , Xn) and suppose  f0induces the measure  Pf0on the Borel  σ-field on Rp, denoted by B(Rp). We form the k-nearest neighborhood of  Xiusing the Euclidean norm for i = 1, . . . , n. For a generic  Xi, let Qi be its k-th nearest neighbor in  X −i = (X1, . . . , Xi−1, Xi+1, . . . , Xn)and let  Ribe the distance between  Xi and Qi, given by Ri = ||Xi−Qi||2. Define the ball  Bi ={y ∈ [0, 1]p : 0 < ||y−Xi||2 < Ri}and the probability  G(Xi, Ri) =�Bi f0(u) duof the ball  Bi.Let  Y (i)1 = Xi and Y (i)2 , . . . , Y (i)k−1 denote the sample points which fall in  Bi. Then, we define the neighborhood specific empirical mean and covariance matrix as ¯Xi = k−1{�k−1j=1 Y (i)j +Qi}and  Si = k−1{�k−1j=1(Y (i)j − ¯Xi)(Y (i)j − ¯Xi)T+(Qi− ¯Xi)(Qi− ¯Xi)T}, respectively. Note that the random vector (Y (i)2 , . . . , Y (i)k−1, Qi) is identically distributed for  i = 1, . . . , n since X1, . . . , Xnare independent and identically distributed. Thus we only consider the case i = 1 from here on. For sake of brevity, denote by  Yu = Y (1)u for u = 2, . . . , k − 1 and by Q = Q1. We alsolet k depend on n and express this dependence as  knwhen required. However, we routinely drop this dependence for notational simplicity.

Conditional on  X1 = x1 ∈ [0, 1]p and R1 = r1 >0, following Mack and Rosenblatt (1979) the conditional joint density of  Y2, . . . , Yk−1 and Q is

image

where  G′(x1, r1) = ∂G(x1, r1)/∂r1 and I(A) denotes the indicator function of the event  A ∈B(Rp). Thus conditional on  X1 and R1, the random variables  Y2, . . . , Yk−1are independent and identically distributed, and independent of Q. Also, Mack and Rosenblatt (1979) states that under Assumptions 3.1-3.3 which imply  f0is bounded and continuous on [0, 1]p, wehave

image

as  n → ∞ and r1 → 0, where Cp = [Γ{(p + 2)/2}]−1πp/2 is the volume of the unit ball in  Rp. Let the function  ρ(x1, r1) = rκ11 where κ1is a non-negative integer. This function can be identified with  φ(·) in equation (11) of Mack and Rosenblatt (1979). In the following propositions we will require the expected values of  ρ(x1, r1) for different choices of  κ1. To thatend, we shall repeatedly make use of the equation (12) from Mack and Rosenblatt (1979) adapted to our setting:

image

Suppose  X1, . . . , Xnare independent and identically distributed random variables generated from the density  f0supported on [0, 1]p satisfying Assumptions 3.1-3.3. For i = 1, . . . , n, recall the definitions of  µi = µi and Λi = Λifrom equation (7):

image

We want to show that ˆfn(x) = (1/n) �ni=1 tγn−p+1(x; µi, Λi) → f0(x) in Pf0-probability as n → ∞ for any x ∈ [0, 1]p, where ˆfn(x) is as described in (7). We first prove two propositions involving successive mean value theorem type approximations to ˆfn(x), which will imply the final result. We now state the two propositions, with accompanying proofs, before stating the final theorem.

image

Proof. Since the (Λi)ni=1 are identically distributed and (µi)ni=1 are identically distributed, we have  EPf0( | ˆfn(x) − fA(x)| ) ≤ EPf0{ |tγn−p+1(x; µ1, Λ1) − tγn−p+1(x; X1, Λ1)| }. The mul-tivariate mean value theorem now implies that

image

image

If we let  Hn = H = {νn(γn − p + 1)}−1(νn + 1)Ψ0 = h2Ip where h2 = h2n = {νn(γn − p +1)}−1{(νn +1)(γ0−p+1)} δ20 following the choice of Ψ0from Section 2.3, then it is clear that Λ1 ≥ H. Therefore, we have  ||Λ−1/21 (X1 − µ1)||2 ≤ ||H−1/2||F ||X1 − µ1||2.Straightforward calculations show that  ||H−1/2 ||F = h−1p1/2 and ||X1 − µ1||2 ≤ R1 + {ν−1n (1 + ||µ0||2 )ν0}where  R1 = ||X1 −X1[k]||2. Using Theorem 2.4 from Biau and Devroye (2015) for  p ≥ 2 and(22) for p = 1, one gets

image

for an appropriate constant  dp >0. Thus, we have  EPf0(R1) ≤ {EPf0(R21)}1/2 ≤ dp(k/n)1/p

for sufficiently large n. This implies that

image

We also have  |Λ1|−1/2 ≤ |H|−1/2 = h−p. Finally, simple calculations yield that

image

where  L1,n,p >0 satisfies  L1,n,p → (2π)−p/2e−1/2 as n → ∞. Plugging all these back in (23), we obtain a finite constant  L2,n,p >0 such that

image

which goes to 0 as  n → ∞, completing the proof.

We now provide the second mean value theorem type approximation which approximates the random bandwidth matrix Λi in fA(x) by H = Hn for each i = 1, . . . , n.

Proposition B.2. Fix x ∈ [0, 1]p. Let fK(x) = (1/n) �ni=1 tγn−p+1(x; Xi, H). Also, let k = o(ni2) with i2 = 4/(p + 2)2 and ν0 = o{n−2/pk(2/p)+1}. Then, we have  EPf0( |fA(x) −fK(x)| ) → 0 as n → ∞.

Proof. Using the identically distributed properties of (Λi)ni=1 and (Xi)ni=1, we obtain  EPf0( |fA(x)−fK(x)| ) ≤ EPf0( |tγn−p+1(x; X1, Λ1)−tγn−p+1(x; X1, H)|). Using the multivariate mean value

theorem, we obtain that

image

where  M1 = [∂{tγn−p+1(x; X1, Σ)}/∂Σ]Σ0for some Σ0, with Σ0in the convex hull of Λ1 andH. Since Λ1 ≥ H, we immediately have Σ0 ≥ Has well. Using the definitions of Λ1 and H,we have

image

||Λ1 − H||F ≤ (νn + 1)νn(γn − p + 1)

Since  || �j∈N1(Xj − ¯X1)(Xj − ¯X1)T||F ≤ �j∈N1 ||(Xj − ¯X1)(Xj − ¯X1)T||F = �j∈N1 ||Xj −¯X1||22 ≤ �j∈N1 R21 = kR21, we get for sufficiently large n the following:

image

using (24) and  ν0 = o�n−2/pk(2/p)+1�. Taking partial derivatives of log{tγn−p+1(x; X1, Σ)}with respect to Σ evaluated at Σ0and taking Frobenius norm of both sides, we obtain

image

for sufficiently large n. We now observe that

image

where  cp,β = (πβ)−p/2{Γ(β/2)}−1Γ{(β + p)/2} for p ≥ 1, β >0. Note that  cp,β → (2π)−p/2

as  β → ∞ for any p ≥1. This immediately implies that  ||M1||F ≤ h−(p+2)cp,γn−p+1(γn + 1)for sufficiently large n. Plugging all these back in equation (27), we obtain for sufficiently large  n, a finite L3,n,p >0 such that

image

which goes to 0 as  n → ∞, proving the proposition.

We now prove Theorem 3.4.

image

triangle inequality. Using Propositions B.1 and B.2, we obtain that  EPf0( | ˆfn(x)−fK(x)| ) →0 as  n → ∞. From Section G of the Appendix, we obtain  fK(x) → f0(x) in Pf0-probability. This immediately implies that given the conditions on  k, ν0and for any  x ∈ [0, 1]p, we haveˆfn(x) → f0(x) in Pf0-probability.

Proof. Fix x ∈ [0, 1]p. For i = 1, . . . , n, let zi = φp(x ; ηi, Σi) and suppose  z(n) = (z1, . . . , zn)T.Then, we have  f(x) = �ni=1 πizi = z(n)Tπ(n) where π(n) = (π1, . . . , πn)T ∼Dirichlet(α +1, . . . , α+ 1) given  X (n). We begin with the identity

image

For i = 1, . . . , n, we have

image

where

image

where the first equality is obtained using  E(πi | X (n)) = 1/n for each i = 1, . . . , n and thelast equality is obtained using equation (32). For  i = 1, . . . , n, since |Λi| ≥ |Hn|, we have

image

We now analyze the second term on the right hand side of (31). Recall that  π(n) isconditionally independent of  z(n) given the data  X (n) following from the nearest neighborDirichlet mixture framework as discussed in Section 2.1. Let Σπdenote the pseudo-posterior covariance matrix of  π(n). Given X (n), since π(n) ∼Dirichlet(α+1, . . . , α+1), standard results yield that Σπ = Vn{(1−Cn)In+CnJn}, where Vn = (n−1)/[n2{n(α+1)+1}], Cn = −1/(n−1),In is the n × nidentity matrix, and  Jn = 1n1Tn where 1n = (1, . . . , 1)T ∈ Rn. Then, we have

image

Using the expression for Σπalong with equation (34), we obtain,

image

where ¯z = (1/n) �ni=1 zi. We now have

image

where the last inequality is obtained using equation (32). Using  |Bi| ≥ Dpn|H| for i = 1, . . . , nas before, we have

image

Combining equations (33) and (36) and putting the results back in equation (31), we have the inequality. If we let  n → ∞we immediately obtain that var{f(x) | X (n)} → 0 inPf0-probability.

Proof. We have iid data  X (n) = (X1, . . . , Xn)iid∼ f0satisfying Assumptions 3.1-3.3 for p = 1. The simplified NN-DM density estimator is given by

image

where (ηi, σ2i ) | X (n) ∼ NIG(µi, νn, γn/2, γnδ2i /2). The pseudo-posterior distribution of g(x) given  X (n) is induced through the pseudo-posterior distributions of (ηi, σ2i )ni=1. The pseudo- posterior mean is of the form ˆfn(x) = (1/n) �ni=1 tγn {(x − µi)/λi} /λi, where λi = {(νn +1)/νn}1/2δi. Let hn = (νnγn)−1/2(νn + 1)1/2(γ0δ20)1/2. Then

image

for  kn = o(n2/7) and kn → ∞ as n → ∞from Section B of the Appendix, where

image

We want to investigate the asymptotic distribution of  g(x) as n → ∞. For that, let us start with the asymptotic distribution of  fK(x), which can be expressed as  fK(x) =n−1 �ni=1 uin, where uin = h−1n tγn{(x − Xi)/hn}. Using Lyapunov’s central limit theorem and denoting convergence in distribution under  f0 by d0, we have

image

for some  r > 2, where ρin = E|uin − E(uin)|r and τ 2in = E{uin − E(uin)}2 for i = 1, . . . , n.By standard calculations, we have

image

For r = 3,

image

It is straightforward to see that �trγn(u)du/�tγn(u)du = O(1) for any  r ≥ 1. So, theLyapunov’s condition is satisfied as the ratio in this case satisfies  O{(nhn)−1/6} and nhn →∞. Additionally,  |τ 2in − {f0(x)/hn}�φ2(u) du| →0. So by a combination of Lyapunov’s central limit theorem and Slutsky’s theorem, we have

image

since�φ2(u) du = (2π1/2)−1. From the calculations in Section G of the Appendix, we can expand the Taylor series to two more terms to obtain

image

since  E{g(x) | X (n)} = ˆfn(x). The pseudo-posterior variance of g(x) is given by

image

with  ud = Γ{(d + 1)/2}/{(dπ)1/2Γ(d/2)}being the normalizing constant of the Student’s t-density with degrees of freedom d > 0. Using Stirling’s approximation, ∆n → 0 as n → ∞.This immediately implies

image

where

image

Using the techniques of Section B of the Appendix, it can be shown that  EPf0{vg(x)} → f0(x)as  n → ∞. Therefore, we have

image

as  n → ∞. A simple application of Chebychev’s inequality implies (nhn)1/2|g(x)− ˆfn(x)| → 0in  Pf0-probability as  n → ∞.Combining this with (37) and (40) and using Slutsky’s theorem, we obtain the desired result. This result means that pseudo-credible intervals can be considered frequentist confidence intervals on average asymptotically.

E.1 A property of the  kn-nearest neighbor distance

Suppose  X1, . . . , Xniid∼ f0 with f0a density on  Rp satisfying Assumptions 3.1-3.3. Denote the induced probability measure  Pf0 by P0for sake of convenience. We define the smoothed k-nearest neighborhood of  Xi as Bi = {x ∈ Rp : ||Xi−x|| ≤ Ri}, where Ri = ||Xi−Xi[kn]||2 isthe Euclidean distance between  Xi and the kn-nearest neighbor of  Xiamongst the data points X1, . . . , Xi−1, Xi+1, . . . , Xn for i = 1, . . . , n. It is immediate that  R1, . . . , Rnare identically distributed from symmetry. Suppose  rn = (kn/n)1/p and define the quasi-neighborhood ˜Bi(r) = {x ∈ Rp : ||Xi − x|| ≤ r}, where the random variables  Rihave been replaced by

image

The positive density condition on  f0obtained from Assumptions 3.1 and 3.3 (Evans et al., 2002; Evans, 2008) ensures the existence of  A > 1 and ρ >0 such that for all 0  ≤ r ≤ ρ and

for all  x ∈ [0, 1]p,

image

We first state a Lemma proving some important properties of  R1. Recall that two sequences (an) and (bn) are said to be asymptotically equivalent if  |an/bn| → c0 for some c0 > 0,denoted by  an ∼ bn.

image

Proof. (i) Note that  cn ≤ ρfor sufficiently large n. From Lemma 4.1 of Evans et al. (2002) we have

image

image

(ii) For  n > n0, we have pn = O{n−(1+Θn)}for a sequence Θn → ∞, Θn >0. This ensures that �∞n=n0+1 pn < ∞.

(iii) Since �∞n=1 pn < ∞, a direct application of the first Borel-Cantelli lemma proves the statement.

image

We now use the above Lemma to prove Theorem 3.8. The key idea is to leverage the fact that  Ri > cn for all i = 1, . . . , nwith probability 1 for all but finite n.

E.2 Number of unique points in each neighborhood

We now prove Theorem 3.8.

image

Proof. Using (iii) from Lemma E.1, for i = 1, . . . , n, we have an integer �Nisuch that for all n ≥ �Ni, P0(Ri > cn) = 1. However, since  R1, . . . , Rnare identically distributed, �N1 = . . . =

Nn = �N, say. Thus, for all  i = 1, . . . , n, we have P0(Ri > cn) = 1 for all  n ≥ �N. Thisimmediately implies that  P0 [�ni=1{Ri > cn}] = 1 − P0 [�ni=1{Ri ≤ cn}] ≥ 1 − �ni=1 P0[Ri ≤

cn] = 1 for all  n ≥ �N, which shows  P0 [�ni=1{Ri > cn}] = 1. Therefore, we have

image

where  θn(x) = 1 − ωx(cn), since X1, . . . , Xniid∼ f0. Using (41), we have θn(x) ≤ 1 − (cpn/A)for all  x ∈ [0, 1]p. Given the conditions on k, it follows that as  n → ∞,

image

for all  x ∈ [0, 1]p, where ξ = 1 − (1 + ǫ − i0)(1 + δ) >0. Therefore, we have

image

as  n → ∞. This proves the result.

F.1 Proof of Theorem 3.9

Proof. Let η(n) = (η1, . . . , ηn)T. Then, we have Θ = �ni=1 πiηi = η(n)T π(n) where π(n) =(π1, . . . , πn)T satisfies π(n) | X (n) ∼Dirichlet(α + 1, . . . , α + 1) and η(n) = (η1, . . . , ηn)T. Westart out by observing that

image

Let n be sufficiently large so that  k > 2 − γ0, since k → ∞ as n → ∞. For i = 1, . . . , n, let

image

Since the pseudo-posterior covariance matrix of  π(n) is Σπ = Vn{(1 − Cn)In + CnJn}, weobtain

image

where ¯η = (1/n) �ni=1 ηi. Now, for i = 1, . . . , n, we have E(η2i | X (n)) = µ2i + vi, andE(¯η2 | X (n)) = (¯v/n) + ¯µ2. Putting these back in equation (44) we get that

image

Combining the results of equations (43) and (45), putting them back in equation (42), and multiplying both sides by n, we get the result.

F.2 Choice of  α

Suppose  σ2f0 is the variance of the underlying true density  f0satisfying Assumptions 3.1-3.3. Let  S2µ = (1/n) �ni=1(µi − ¯µ)2 and S2 = (1/n) �ni=1(Xi − ¯X)2. We start out by observing that

image

by the triangle inequality and the fact that  |µi|, |Xi| ≤ 1 for i = 1, . . . , n. Since (µi)ni=1 areidentically distributed and (Xi)ni=1 are identically distributed, we have

image

But  EPf0( |¯µ − ¯X| ) ≤ (1/n) �ni=1 EPf0( |µi − Xi|) by the triangle inequality, from which it follows that  EPf0( |¯µ − ¯X| ) ≤ EPf0( |µ1 − X1| ) since (µi − Xi) are identically distributed for i = 1, . . . , n. Thus, we have

image

using (25). Since  S2 → σ2f0 in Pf0-probability as  n → ∞by the weak law of large numbers, we get that  S2µ → σ2f0 in Pf0-probability as  n → ∞as well. Equating the pseudo-posterior variance of  n1/2Θ from Theorem 3.9 with  σ2f0, we get after some rearranging,

image

As  n → ∞, since each  λi satisfies λ2i − h2 → 0 in Pf0-probability for i = 1, . . . , n using equation (29) with  p = 1, ¯vis well approximated by (γnνn)−1(γ0δ20) in the sense that  {¯v −(γnνn)−1(γ0δ20)} → 0 in Pf0-probability as  n → ∞. In particular, we have ¯v → 0 in Pf0-probability. Combining these with the fact that  S2µ → σ2f0 in Pf0-probability as  n → ∞, weobtain,

image

Since 1/n can be asymptotically neglected in comparison to ¯v/σ2f0 owing to the fact that k2/n → 0 as n → ∞ for p = 1, (48) implies the choice of  αas described in equation (17).

Define the standard multivariate t-density with d > 0 degrees of freedom to be  gd(x) =td(x; 0p, Ip). Since H = Hnas defined in Section 3.1 is diagonal, it immediately follows that tγn−p+1(x; x′, H) = h−pgγn−p+1{h−1(x − x′)}. The following lemma proves the consistency of any such generic kernel density estimator with t kernel depending on n, say

image

where the bandwidth  w = wn satisfies wn → 0 and nwpn → ∞ as n → ∞, with independent and identically distributed data  X1, . . . , Xn ∼ f0satisfying Assumptions 3.1-3.3.

Lemma G.1. Suppose w = wnis a sequence satisfying  w −→ 0 and nwp −→ ∞ as n −→ ∞.Let  fK(x) = (nwp)−1 �ni=1 gγn−p+1{w−1(x − Xi)}. Then fK(x) → f0(x) in Pf0-probability

image

Proof. It is enough to show that  EPf0{fK(x)} −→ f0(x) and varPf0{fK(x)} −→ 0 as n −→ ∞.Let us start first with  EPf0{fK(x)}. We have

image

using the mean value theorem and Polya’s theorem (P´olya, 1920) along with Assumption 3.2 to bound  ∇f0(·). As n → ∞, this implies that  EPf0{fK(x)} → f0(x) since w → 0 asn → ∞.

The variance may be dealt with in a similar manner. Following the same steps as before we get

image

which shows that the variance goes to 0 as  n → ∞, since nwp → ∞ as n → ∞.

For the nearest neighbor-Dirichlet mixture, recall  fK(x) = (1/n) �ni=1 tγn−p+1(x; Xi, Hn)from Section 3.1 of the main document, where  Hn = h2nIp and h2n = {νn(γn −p+1)}−1{(νn +1)(γ0−p+1)}δ20. Here, the bandwidth  hn satisfies hn → 0 and nhpn → ∞ as n → ∞. LemmaG.1 then shows that  fK(x) converges to  f0(x) in Pf0-probability as  n → ∞.

H.1 Algorithm for leave-one-out cross-validation

Consider independent and identically distributed data  X1, . . . , Xn ∈ Rp ∼ f with f havingthe nearest neighbor-Dirichlet mixture formulation. In the univariate setting, the prior for each of the neighborhood specific parameters is  θi = (ηi, σ2i ) ∼ NIG(µ0, ν0, γ0/2, γ0δ20/2).The equivalent prior in the general multivariate setting following Sections 2.2 and 2.3 is (ηi, Σi) ∼ NIWp(µ0, ν0, γ0, Ψ0) where Ψ0 = (γ∗δ20) Ip with γ∗ = γ0 − p + 1. We use thepseudo-posterior mean in equations (7) and (8) to compute leave-one-out log-likelihoods L(δ20) for different choices of the hyperparameter  δ20, choosing δ20,CV = arg supδ20L(δ20) tomaximize this criteria. The details of the computation of  L(δ20) for a fixed  δ20 are provided in Algorithm 2.

image

H.2 Fast Implementation of cross-validation

In Algorithm 2, the nearest neighborhood specification for each  X −i is different for i = 1, . . . , n. However, we bypass this computation by initially forming a neighborhood of size (k + 1) for each data point using the entire data and storing the respective neighborhood means and covariance matrices. Suppose for  Xi, the indices of the (k + 1)-nearest neighbors are given by  Ni = {j ∈ {1, . . . , n} : ||Xi − Xj||2 ≤ ||Xi − Xi[k+1]||2}, ar-ranged in increasing order according to their distance from  Xi with Xi[1] = Xi. Definethe neighborhood mean  mi = {1/(k + 1)} �j∈Ni Xi[j]and the neighborhood covariance ma- trix  Si = (k +1)−1{�j∈Ni(Xi[j] −mi)(Xi[j]−mi)T}. Then, to form a k-nearest neighborhood for the new data  X −i, a single pass over the initial neighborhoods  Niis sufficient to update the new neighborhood means and covariance matrices. Below, we describe the update for the neighborhood means  m(−i)jand covariance matrices  S(−i)j for j = 1, . . . , n and j ̸= i,considering the data  X −i. For j = 1, . . . , n and j ̸= i, we have,

image

Suppose we have independent and identically distributed observations  X (n) = (X1, . . . , Xn)from the density  f, where Xi ∈ ℜ, i = 1, . . . , n. In the nearest neighbor-Dirichlet mixture framework for univariate data with the Gaussian kernel  φ(· ; η, σ2), neighborhood specific parameters  θi = (ηi, σ2i ) ∼ NIG(µ0, ν0, γ0/2, γ0δ20/2) a prioriindependently for i = 1, . . . , n. Monte Carlo samples for the estimated density at any point x can be generated following the steps of Algorithm 3.

image

The parametrization of the inverse Wishart density defined on the set of all  p × p matriceswith real entries used in this article is given as follows. Suppose  γ > p −1 and Ψ is a  p × ppositive definite matrix. If Σ  ∼ IWp(γ,Ψ), then Σ has the following density function:

image

where Γp(·) is the multivariate gamma function defined by

image

for  a ≥ (p−1)/2 and the function etr (A) = exp {tr(A)} for a square matrix A. When p = 1, the IWp(γ,Ψ) density is the same as the IG(γ/2, γδ2/2) density, where  δ2 = Ψ/γ.

image

Table 3: Comparison of the methods in terms of  L1error in the univariate case. Number of test points and replications considered are  nt = 500 and R= 20, respectively.

image

Abramson, I. S. (1982). On bandwidth variation in kernel estimates-a square root law. The Annals of Statistics, pages 1217–1223.

Azzalini, A. (2005). The skew-normal distribution and related multivariate families. Scandinavian Journal of Statistics, 32(2):159–188.

Biau, G. and Devroye, L. (2015). Lectures on the Nearest Neighbor Method. Springer.

Blei, D. M. and Jordan, M. I. (2006). Variational inference for Dirichlet process mixtures. Bayesian Analysis, 1(1):121–143.

Bowman, A. W. (1984). An alternative method of cross-validation for the smoothing of density estimates. Biometrika, 71(2):353–360.

Breiman, L., Meisel, W., and Purcell, E. (1977). Variable kernel estimates of multivariate densities. Technometrics, 19(2):135–144.

Devroye, L. and Gyorfi, L. (1985).  Nonparametric Density Estimation: the L1 view. WileySeries in Probability and Statistics.

Duong, T. (2020). ks: Kernel Smoothing. R package version 1.11.7.

Evans, D. (2008). A law of large numbers for nearest neighbour statistics. Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences, 464(2100):3175–3192.

Evans, D., Jones, A. J., and Schmidt, W. M. (2002). Asymptotic moments of near–neighbour distance distributions. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences, 458(2028):2839–2849.

Ghosal, S., Ghosh, J. K., Ramamoorthi, R., et al. (1999). Posterior consistency of Dirichlet mixtures in density estimation. The Annals of Statistics, 27(1):143–158.

Ghosal, S. and Van der Vaart, A. (2017). Fundamentals of nonparametric Bayesian inference, volume 44. Cambridge University Press.

Ghosal, S., Van Der Vaart, A., et al. (2007). Posterior convergence rates of Dirichlet mixtures at smooth densities. The Annals of Statistics, 35(2):697–723.

Gneiting, T. and Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and esti- mation. Journal of the American Statistical Association, 102(477):359–378.

Golub, G. H. and van Loan, C. F. (1996). Matrix Computations. John Hopkins University Press, 3 edition.

Hahn, P. R., Martin, R., and Walker, S. G. (2018). On recursive bayesian predictive distri- butions. Journal of the American Statistical Association, 113(523):1085–1093.

Hall, P. (1987). On Kullback-Leibler loss and density estimation. The Annals of Statistics, 15(4):1491–1519.

Hjort, N. L. and Jones, M. C. (1996). Locally parametric nonparametric density estimation. The Annals of Statistics, pages 1619–1647.

J. Ross, G. and Markwick, D. (2019). dirichletprocess: Build Dirichlet Process Objects for Bayesian Modelling. R package version 0.3.1.

Jara, A., Hanson, T., Quintana, F., M¨uller, P., and Rosner, G. (2011). DPpackage: Bayesian semi- and nonparametric modeling in R. Journal of Statistical Software, 40(5):1–30.

Keith, M., Jameson, A., Van Straten, W., Bailes, M., Johnston, S., Kramer, M., Possenti, A., Bates, S., Bhat, N., Burgay, M., et al. (2010). The High Time Resolution Universe Pulsar Survey I, System configuration and initial discoveries. Monthly Notices of the Royal Astronomical Society, 409(2):619–627.

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

Lavine, M. (1994). More aspects of Polya tree distributions for statistical modelling. The Annals of Statistics, 22(3):1161–1176.

Loader, C. (2006). Local regression and likelihood. Springer Science & Business Media.

Loader, C. R. (1996). Local likelihood density estimation. The Annals of Statistics, 24(4):1602–1618.

Loftsgaarden, D. O. and Quesenberry, C. P. (1965). A nonparametric estimate of a multi- variate density function. The Annals of Mathematical Statistics, 36(3):1049–1051.

Lorimer, D. R. and Kramer, M. (2012). Handbook of Pulsar Astronomy.

Lyon, R. J. (2016). Why are pulsars hard to find? PhD thesis, The University of Manchester (United Kingdom).

Ma, H. and Li, J. (2019). A true O(n log n) algorithm for the all-k-nearest-neighbors problem. In International Conference on Combinatorial Optimization and Applications, pages 362– 374. Springer.

Mack, Y. and Rosenblatt, M. (1979). Multivariate k-nearest neighbor density estimates. Journal of Multivariate Analysis, 9(1):1–15.

Mildenberger, T. and Weinert, H. (2012). The benchden package: Benchmark densities for nonparametric density estimation. Journal of Statistical Software, 46(14):1–14.

Miller, J. W. and Dunson, D. B. (2019). Robust Bayesian inference via coarsening. Journal of the American Statistical Association, 114(527):1113–1125.

Newton, M. A. (2002). On a nonparametric recursive estimator of the mixing distribution. Sankhy¯a: The Indian Journal of Statistics, Series A, 64(2):306–322.

Newton, M. A. and Zhang, Y. (1999). A recursive algorithm for nonparametric analysis with missing data. Biometrika, 86(1):15–26.

Ni, Y., Ji, Y., and M¨uller, P. (2020). Consensus monte carlo for random subsets using shared anchors. Journal of Computational and Graphical Statistics, 29(4):1–12.

P´olya, G. (1920). ¨Uber den zentralen grenzwertsatz der wahrscheinlichkeitsrechnung und das momentenproblem. Mathematische Zeitschrift, 8(3-4):171–181.

R Core Team (2018). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria.

Rivoirard, V. and Rousseau, J. (2012). Bernstein–von Mises theorem for linear functionals of the density. The Annals of Statistics, 40(3):1489–1523.

Rousseau, J. and Mengersen, K. (2011). Asymptotic behaviour of the posterior distribution in overfitted mixture models. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 73(5):689–710.

Scott, D. W. (2015). Multivariate Density Estimation: Theory, Practice, and Visualization. John Wiley & Sons.

Sheather, S. J. and Jones, M. C. (1991). A reliable data-based bandwidth selection method for kernel density estimation. Journal of the Royal Statistical Society: Series B (Methodological), 53(3):683–690.

Song, H., Wang, Y., and Dunson, D. B. (2020). Distributed Bayesian clustering using finite mixture of mixtures. arXiv preprint, page arXiv:2003.13936.

Song, P. X.-K. (2000). Multivariate dispersion models generated from Gaussian copula. Scandinavian Journal of Statistics, 27(2):305–320.

Terrell, G. R. and Scott, D. W. (1992). Variable kernel density estimation. The Annals of Statistics, pages 1236–1265.

Teschl, G. (2009). Mathematical methods in quantum mechanics. Graduate Studies in Mathematics, 99:106.

Tsybakov, A. B. (2004). Introduction to nonparametric estimation, 2009. URL https://doi. org/10.1007/b13794. Revised and extended from the.

Vaidya, P. M. (1986). An optimal algorithm for the all-nearest-neighbors problem. In 27th Annual Symposium on Foundations of Computer Science, pages 117–122.

Wand, M. P. and Jones, M. C. (1994). Multivariate plug-in bandwidth selection. Computational Statistics, 9(2):97–116.

Wang, L. and Dunson, D. B. (2011). Fast Bayesian inference in Dirichlet process mixture models. Journal of Computational and Graphical Statistics, 20(1):196–216.

West, M. (1992). Hyperparameter estimation in Dirichlet process mixture models. Duke University ISDS Discussion Paper# 92-A03.

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

Zhang, X., Nott, D. J., Yau, C., and Jasra, A. (2014). A sequential algorithm for fast fitting of Dirichlet process mixture models. Journal of Computational and Graphical Statistics, 23(4):1143–1162.


Designed for Accessibility and to further Open Science