## 4 Approximate Bayesian Computation
In this example, having observed \(y_{1},y_{2},\ldots,y_{n_{1}}\) and knowing \(\sigma=0.1\), we can assume \(\mu\) lies between say \(L=\overline{y}-5\sigma/n_{1}\) and \(U=\overline{y}+5\sigma/n_{1}\). 2. Choose \(\mu\) values on a grid of equally-spaced values in the range \((L,U)\). For each \(\mu_{i}\) value in the grid, simulate \(n_{2}\) observations from \(N(\mu_{i},\sigma)\) and use these \(n_{2}\) observations to estimate the pdf using density estimation [25]. In the toy example, we know the true pdf is \(N(\mu,\sigma)\), but in cases below, we might not know the pdf because it involves algebraic combinations of non-normal pdfs. 3. The likelihood of each observed \(y_{j}\) can be estimated by interpolation of the estimated pdf for each \(\mu_{i}\) value in the grid. The size of the steps in the \(\mu\) grid can be decreased and \(n_{2}\) can be increased until estimates of \(\mu\) stabilize. 4. The overall likelihood is then the product (because the \(y_{j}\) are independent) of the estimated likelihood for each observed \(y_{j}\). 5. Use MCMC to estimate the posterior probability for \(\mu\), and to compute \(\hat{\mu}\) as the mean of the posterior. To implement MCMC, we used the metrop function in the mcmc package in R and used the approx function to interpolate the estimated pdf on the grid of trial \(\mu\) values. The Appendix has this \"likelihood\" function, where the estimated pdf is used in place of an analytical likelihood. Figure 1 illustrates the resulting log likelihood for \(\mu=1\), \(\mu=1.1\), \(n_{1}=10\), and \(n_{2}=1000\). Notice that the log likelihood peaks very near the true \(\mu\) value in both cases. **Figure 1.** Example ABC. The solid black curve is for \(\mu=1\) and the dotted red curve is for \(\mu=1.1\). To check our implementation, we specified the prior \(p(\mu)\) to be \(N(\mu_{\mbox{prior}},\sigma_{\mbox{prior}}^{2})\). Then, because the normal prior for \(\mu\) is the \"conjugate\" prior (meaning that the posterior distribution is the same type of distribution as the prior distribution) for the normal likelihood, the posterior \(\pi(\theta|D)\) is \(N(\mu_{\mbox{post}},\sigma_{\mbox{post}}^{2})\). The ABC estimate of the posterior mean can then be compared to the mean of the exact posterior \(\pi(\theta|D)\) to ensure proper implementation. In this case, our implementation of ABC also leads to \(\hat{\mu}\approx\overline{y}\) because we used \(\sigma=0.1\), \(\sigma_{\mbox{prior}}=10\), and \(n_{1}=10\), so the posterior distribution has mean essentially equal to \(\overline{y}\). Specifically, in 100 simulations of the entire process of generating \(n_{1}=10\) observations, and applying density estimation to estimate the likelihood using \(n_{2}=1000\) observations resulted in no statistical difference (based on a paired \(t\)-test) between the 100 values of the exact Bayesian \(\hat{\mu}\), the ABC estimate of \(\hat{\mu}\), and \(\hat{\mu}=\overline{y}\). Readers can duplicate our results using the \(R\) functions listed in the Appendix. To our knowledge, this simple use of density estimation to substitute for having an analytical form for the likelihood has not been studied in the ABC literature. However, provided the data can be simulated sufficiently fast to acquire many observations (\(n_{2}=1000\) was sufficiently large in this toy problem), and provided the dimension of the data is not too large, density estimation is feasible and effective. In the PPP case, we have only two variables, \(y_{1}\) and \(y_{2}\), so certainly 2-dimensional density estimation is feasible. We note here that summary statistics such as moments from the real and simulated data in the MCMC accept/reject steps in typical ABC implementations are fast to compute, but convergence criteria and measures of adequacy are still being developed [23].