<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/"></div></div><div><a data-url="https://www.r-bloggers.com/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/" data-counturl="https://www.r-bloggers.com/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/" data-count="horizontal" data-text="asymptotically exact inference in likelihood-free models [a reply from the authors]" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://xianblog.wordpress.com/2016/12/01/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/"> R – Xi'an's Og</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><em>[Following <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/2016/11/29/asymptotically-exact-inference-in-likelihood-free-models/">my post</a> of lastTuesday, Matt Graham commented on the paper with force détails. Here are those comments. A nicer HTML version of the Markdown reply below is also available on <a target="_blank" rel="nofollow" href="http://matt-graham.github.io/notes/2016-11-29-reply-to-xian-paper-comments.html">Github</a>.]</em></p>
<p>Thanks for the comments on the paper!</p>
<p>A few additional replies to augment what Amos wrote:</p>
<blockquote>
<p><em><span>This however sounds somewhat intense in that it involves a quasi-Newton resolution at each step.</span></em></p>
</blockquote>
<p>The method is definitely computationally expensive. If the constraint function is of the form of a function from an M-dimensional space to an N-dimensional space,<span><span><span><span><span></span></span></span></span></span> with <span><span><span><span><span>M</span><span>≥</span><span>N</span></span></span></span></span>, for large <span><span><span><span><span>N</span></span></span></span></span> the dominant costs at each timestep are usually the constraint Jacobian (<span><span><span><span><span><span><span>∂</span><span>c/</span></span><span><span>∂</span><span>u)</span></span></span></span></span></span></span> evaluation (with reverse-mode automatic differentiation this can be evaluated at a cost of <span><span><span><span><span><span><span>O</span></span></span><span>(</span><span>N</span><span>)</span></span></span></span></span> generator / constraint evaluations) and Cholesky decomposition of the Jacobian product (<span><span><span><span><span><span><span>∂</span><span>c/</span></span><span><span>∂</span><span>u)(</span></span></span><span><span><span><span>∂</span><span>c/</span></span><span><span>∂</span><span>u)</span></span></span><span><span><span>‘</span></span></span></span></span></span></span></span> with <span><span><span><span><span><span><span>O</span></span></span><span>(</span><span><span>N</span><span>³</span></span><span>)</span></span></span></span></span> cost (though in many cases e.g. i.i.d. or Markovian simulated data, structure in the generator Jacobian can be exploited to give a significantly reduced cost). Each inner Quasi-Newton update involves a pair of triangular solve operations which have a <span><span><span><span><span><span><span>O</span></span></span><span>(</span><span><span>N</span><span>²</span></span><span>)</span></span></span></span></span> cost, two matrix-vector multiplications with O<span><span><span><span><span><span><span></span></span></span><span>(</span><span>M</span><span>N</span><span>)</span></span></span></span></span> cost, and a single constraint / generator function evaluation; the number of Quasi-Newton updates required for convergence in the numerical experiments tended to be much less than <span><span><span><span><span>N</span></span></span></span></span> hence the Quasi-Newton iteration tended not to be the main cost.</p>
<p>The high computation cost per update is traded off however with often being able to make much larger proposed moves in high-dimensional state spaces with a high chance of acceptance compared to ABC MCMC approaches. Even in the relatively small Lotka-Volterra example we provide which has an input dimension of 104 (four inputs which map to ‘parameters’, and 100 inputs which map to ‘noise’ variables), the ABC MCMC chains using the coarse ABC kernel radius <span><span><span><span><span>ϵ</span><span>=</span><span>100</span></span></span></span></span> with comparably very cheap updates were significantly less efficient in terms of effective sample size / computation time than the proposed constrained HMC approach. This was in large part due to the elliptical slice sampling updates in the ABC MCMC chains generally collapsing down to very small moves even for this relatively coarse <span><span><span><span><span>ϵ</span></span></span></span></span>. Performance was even worse using non-adaptive ABC MCMC methods and for smaller <span><span><span><span><span>ϵ</span></span></span></span></span>, and for higher input dimensions (e.g. using a longer sequence with correspondingly more random inputs) the comparison becomes even more favourable for the constrained HMC approach.</p>
<p>A lot of the improvement seems to be coming from using gradient information: running standard HMC on the inputs <span><span><span><span><span>u</span></span></span></span></span> with a Gaussian ABC kernel which is equivalent to our baseline in the pose and MNIST experiments or the method proposed in the recent <a target="_blank" rel="nofollow" href="https://arxiv.org/abs/1607.02516"><em>Pseudo-marginal Hamiltonian Monte Carlo</em></a> by Lindsten and Doucet, seems to give comparable performance when normalised for computation time for moderate <span><span><span><span><span>ϵ</span></span></span></span></span>. Although the standard HMC updates are much cheaper to compute, the large difference in scale between the change in density in directions normal to the (soft) constraint and in the tangent space of the constraint manifold mean a small step-size needs to be used for the standard HMC updates to maintain reasonable accept rates (with in general the manifold being non-linear and so we cannot adjust for the scale differences by a simple linear transformation / non-identity mass matrix) which means that despite the much cheaper updates standard HMC tends to give similar effective samples per computation time (and as <span><span><span><span><span>ϵ</span></span></span></span></span> becomes smaller this approach becomes increasingly less efficient compared to the constrained HMC method).</p>
<blockquote>
<p><span><em>I also find it surprising that this projection step does not jeopardise the stationary distribution of the process, as the argument found therein about the approximation of the approximation is not particularly deep.</em></span></p>
</blockquote>
<p>The overall simulated constrained dynamic including the projection step is symplectic on the constraint manifold (as shown in <a target="_blank" rel="nofollow" href="https://www2.stat.duke.edu/~scs/Courses/Stat376/Papers/Constraints/LeimkuhlerSymplecticConstraints94.pdf"><em>Symplectic numerical integrators in constrained Hamiltonian systems</em></a> by Leimkuhler and Reich) and time reversible, providing the projection iteration is run to convergence and an ‘appropriate’ step size is chosen (i.e. sufficiently small compared to the curvature of the manifold that there is guaranteed to be a solution to the projection on to the manifold and that there is only one close by solution to the projection step that will be converge to). The issues with requiring an appropriate step size to ensure a solution to the non-linear equations being solved exists and is locally unique are the same as in the implicit integrators used in Riemannian-manifold HMC methods.</p>
<p>In practice we found the use of the geodesic integration scheme which splits up the unforced motion on the constrained manifold in to multiple smaller steps for each outer forced step helped in allowing an appropriate step-size for the curvature of the manifold to be chosen independently to that appropriate for the change in the density. Providing an appropriately small step size was used non-convergence was very rarely an issue and generally only in the initial updates where the geometry of the constraint manifold might be expected to be non-typical of that seen after warm-up.</p>
<blockquote>
<p><em><span>But the main thing that remains unclear to me after reading the paper is how the constraint that the pseudo-data be equal to the observable data can be turned into a closed form condition like g⁰(u)=0.</span></em></p>
</blockquote>
<p>For concreteness I’ll assume a parameter inference problem with parameters <span><span><span><span><span>θ</span></span></span></span></span> generated from some prior distribution given a vector of standard variates <span><span><span><span><span><span>u</span><span>¹</span></span></span></span></span></span> i.e. <span><span><span><span><span>θ</span><span>=</span><span>ρ</span><span>(</span><span><span>u</span><span>¹</span></span><span>)</span></span></span></span></span> where <span><span><span><span><span>ρ</span></span></span></span></span> is a deterministic function.</p>
<p>Further let <span><span><span><span><span>f</span><span>(</span><span>θ</span><span>,</span><span></span><span><span>u</span><span>²</span></span><span>)</span></span></span></span></span> be our simulator function which given access to a further vector of variates from a random number generator <span><span><span><span><span><span>u</span><span>²</span></span></span></span></span></span> and parameters <span><span><span><span><span>θ</span><span>=</span><span>ρ</span><span>(</span><span><span>u</span><span>¹</span></span><span>)</span></span></span></span></span> can produce simulated data <span><span><span><span><span>x</span><span>=</span><span>f</span><span><span>(</span><span><span>ρ</span><span>(</span><span><span>u</span><span>¹</span></span><span>)</span><span>,</span><span></span><span><span>u</span><span>²</span></span></span><span>)</span></span></span></span></span></span>.</p>
<p>If we have observed data <span><span><span><span><span><span><span><span>x</span><span>˘</span></span></span></span></span></span></span></span> then the constraint that <span><span><span><span><span>x</span><span>=</span><span><span><span><span>x</span><span>˘</span></span></span></span></span></span></span></span> can be written <span><span><span><span><span>f</span><span><span>(</span><span><span>ρ</span><span>(</span><span><span>u</span><span>¹</span></span><span>)</span><span>,</span><span></span><span><span>u</span><span>²</span></span></span><span>)</span></span><span>−</span><span><span><span><span>x</span><span>˘</span></span></span></span><span>=</span><span>0</span></span></span></span></span>, so we would have <span><span><span><span><span>c</span><span>(</span><span>u</span><span>)</span><span>=</span><span>f</span><span><span>(</span><span><span>ρ</span><span>(</span><span><span>u</span><span>¹</span></span><span>)</span><span>,</span><span></span><span><span>u</span><span>²</span></span></span><span>)</span></span><span>−</span><span><span><span><span>x</span><span>˘</span></span></span></span><span>=</span><span>0</span></span></span></span></span> where <span><span><span><span><span>u</span><span>=</span><span>[</span><span><span>u</span><span>¹</span></span><span>;</span><span></span><span><span>u</span><span>²</span></span><span>]</span></span></span></span></span>.</p>
<blockquote>
<p><em><span>As mentioned above, the authors assume a generative model based on uniform (or other simple) random inputs but this representation seems impossible to achieve in reasonably complex settings.</span></em></p>
</blockquote>
<p>The representation requirements can be split in to two components:</p>
<ol>
<li>We can express our simulator model in the form <span><span><span><span><span>y</span><span>=</span><span>g</span><span>(</span><span>u</span><span>)</span></span></span></span></span></li>
<li><span><span><span><span><span>g</span></span></span></span></span> is differentiable with respect to <span><span><span><span><span>u</span></span></span></span></span></li>
</ol>
<p>The assumed differentiability of the generator is definitely a strong restriction, and does limit the models which this can be applied to.</p>
<p>I’d argue that its quite rare that in the context of simulator type models that the first assumption isn’t valid (though this may be a somewhat circular argument as it could just be what I’m defining as a simulator model is something which it applies to!).</p>
<p>All (1) requires is that in the simulator code all ‘randomness’ is introduced by drawing random variates from a (pseudo-)random number generator where the density of the drawn variates is known (up to some potentially unknown normalisation constant). More explicitly for the parameter inference setting above if we can write our generator function in the form</p>
<div>
<p> </p>
<pre>
def generator(rng):
  params = generate_from_prior(rng)
  simulated_data = simulator(rng, params)
  return [params, simulated_data]
</pre>
<p>where <code>rng</code> is a pseudo-random number generator object allowing independent samples to be generated from standard densities then this assumption holds.</p>
</div>
<p>For (1) alone to hold the code in this function can be completely arbitrary . This could be code numerically integrating a set of stochastic differential equations, a graphics rendering pipeline or a learned parametric ‘neural network’ type model (with the three experiments in our paper providing toy examples of each of these).</p>
<p>There are degrees of freedom in what to consider the random inputs. I believe pseudo-random number generator implementations generally generate continuous random variates from just a pseudo-random uniform primitive (which itself will be generated from a pseudo-random integer primitive), e.g. RandomKit which is used for the random number implementation in (amongst other libraries) NumPy provides a <code>rk_double</code> function to generate a double-precision pseudo-random uniform variate in [0, 1) (and a <code>rk_gauss</code> function to generate a pair of Gaussian random variates but this uses <code>rk_double</code> internally). So assuming <span><span><span><span><span>u</span></span></span></span></span> is an arbitrarily long vector of random uniform variates will often be sufficient for allowing the simulator to be expressed as in (1) as mentioned by Dennis Prangle in the comments of your recent post ‘rare events for ABC’.</p>
<p>In general our proposed method is actually more suited to using random inputs with unbounded support otherwise it is necessary to deal with reflections at the intersection of the constraint manifold and bounds of the support (which is possible while maintaining reversibility but a bit painful implementation wise), so for example it is better to use Gaussian variates directly than specify uniform inputs then transform to Gaussians. A uniform variate might be generated by for example setting the base density to the logistic distribution and then transforming through the logistic sigmoid. This problem of automatically transforming to unconstrained inputs has been well studied in for example Stan.</p>
<p>Returning to the limitations applied by assuming (2) i.e. differentiability: some of the transforms from uniform variates used to generate random variates in random number generator implementations are non-differentiable e.g. if using an accept / reject step, for example common methods for generating a Gamma variate. There are a couple of options here. We can often just use the density of the output of the transform itself e.g. a Gamma base density on the relevant <span><span><span><span><span><span>u</span><span>i</span></span></span></span></span></span>; if the parameters of the variate distribution are themselves dependent on other random inputs we need to make sure to include this dependency, but its possible to track these dependencies automatically – again probabilistic programming frameworks like Stan do just this. In other cases we might be able to use alternative (potentially less computationally efficient) transformations that avoid the accept/reject step e.g. using the original Box-Muller transform versus the more efficient but rejection based polar variant, or use tricks such as in the recent <a target="_blank" rel="nofollow" href="https://arxiv.org/pdf/1610.05683v1.pdf"><em>Rejection Sampling Variational Inference</em></a> by Nasesseth et al.</p>
<p>Filed under: <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/category/statistics/r-statistics/">R</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/category/statistics/">Statistics</a> Tagged: <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/abc/">ABC</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/abc-mcmc/">ABC-MCMC</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/arxiv/">arXiv</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/edinburgh/">Edinburgh</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/generator/">generator</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/hamiltonian/">Hamiltonian</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/hmc/">HMC</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/jacobian/">Jacobian</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/likelihood-free-methods/">likelihood-free methods</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/lotka-volterra/">Lotka-Volterra</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/manifold/">manifold</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/normalisation/">normalisation</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/pseudo-marginal-mcmc/">pseudo-marginal MCMC</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/quasi-newton-resolution/">quasi-Newton resolution</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/reply/">reply</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/riemann-manifold/">Riemann manifold</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/simulation-under-restrictions/">simulation under restrictions</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/simulator-model/">simulator model</a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xianblog.wordpress.com/32152/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/xianblog.wordpress.com/32152/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/"></div></div><div><a data-url="https://www.r-bloggers.com/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/" data-counturl="https://www.r-bloggers.com/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/" data-count="vertical" data-text="asymptotically exact inference in likelihood-free models [a reply from the authors]" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://xianblog.wordpress.com/2016/12/01/asymptotically-exact-inference-in-likelihood-free-models-a-reply-from-the-authors/"> R – Xi'an's Og</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/s9vbLbaZrig"></a></div>