## Updating Variational Bayes: Fast sequential posterior inference

Nathaniel Tomasetti ∗

Catherine Forbes †

Anastasios Panagiotelis ‡

August 2, 2019

## Abstract

Variational Bayesian (VB) methods produce posterior inference in a time frame considerably smaller than traditional Markov Chain Monte Carlo approaches. Although the VB posterior is an approximation, it has been shown to produce good parameter estimates and predicted values when a rich classes of approximating distributions are considered. In this paper we propose Updating VB (UVB), a recursive algorithm used to update a sequence of VB posterior approximations in an online setting, with the computation of each posterior update requiring only the data observed since the previous update. An extension to the proposed algorithm, named UVB-IS, allows the user to trade accuracy for a substantial increase in computational speed through the use of importance sampling. The two methods and their properties are detailed in two separate simulation studies. Two empirical illustrations of the proposed UVB methods are provided, including one where a Dirichlet Process Mixture model with a novel posterior dependence structure is repeatedly updated in the context of predicting the future behaviour of vehicles on a stretch of the US Highway 101.

Keywords: Importance Sampling, Forecasting, Clustering, Dirichlet Process Mixture, Variational Inference

JEL Classifications: C11, G18, G39.

## 1 Introduction

Time series data often arrives in high frequency streams in applications that may require a response within a very short period of time. For example, self-driving vehicles may need to constantly monitor the position of each surrounding vehicle, predict or infer the behaviour of their human drivers, and react accordingly. In this context, the most recently received data can be highly informative for very short-term predictions, if the inferred models can be processed very quickly in an online fashion. In order to account for uncertainty in the models or predictions, Bayesian updating methods may be employed by targeting a sequence of posterior distributions, each conditioned on an

∗ Department of Econometrics and Business Statistics, Monash University, VIC, 3800, Australia. Email: nathaniel.tomasetti@monash.edu . Code available at https://github.com/NTomasetti/UVB\_Code

† Corresponding author. Department of Econometrics and Business Statistics, Monash University, VIC, 3800, Australia. Email: catherine.forbes@monash.edu . This author acknowledges financial support under the Australian Research Council Discovery Grant No. DP150101728.

‡ Department of Econometrics and Business Statistics, Monash University, VIC, 3800, Australia. Email: anastasios.panagiotelis@monash.edu .

expanding dataset. The computational demands of such an algorithm may be improved if the incorporation of additional data does not require the re-use of any observations that have previously been conditioned upon.

In many empirical settings, the desired Bayesian posterior distributions are not analytically tractable. In such cases posterior inference may be obtained using Markov chain Monte Carlo (MCMC) methods, which result in a (dependent) sample from the posterior. Unfortunately, this approach typically involves relatively slow algorithms that are incompatible with the time frames demanded by streaming data, as the computation of each posterior update involves the entire currently observed dataset. Further, while particle filtering methods for sequential posterior updating have been developed both for static parameter models (Chopin, 2002) and dynamic latent variable models (e.g. Doucet et al., 2001), these available methods appear to be too slow for practical online use. This is particularly the case when they require use of the entire dataset to avoid particle degeneracy and/or when the number of inferred parameters is large. For a recent review of particle filtering methods, see Doucet and Lee (2018). An alternative approach appears in Jasra et al. (2010) and Del Moral et al. (2015), who apply Approximate Bayesian Computation (ABC) for sequential posterior updating, however this involves an embedded particle filter that similarly scales poorly to higher dimensional models. Bhattacharya and Wilson (2018) provide a sequential method to update parameter inference, however their grid-based posterior evaluation is suitable only for low dimensions. Taking a different approach, Chen et al. (2019) learn the parameters of a so-called flow operator, a neural network that approximates a function which maps a set of particles from a posterior distribution at one time period, and additional data, to a set of particles belonging to an updated posterior distribution.

An alternative approach that has grown in popularity in the recent literature for high dimensional models is the so-called Variational Bayes (VB) method (see Zhang et al., 2017, for a review). VB approximates the posterior with a tractable family of distributions, and chooses a member of this family by minimising a particular loss function with respect to auxiliary parameters. Early work in VB found an optimal approximation with coordinate descent algorithms in exponential family models, an approach widely known as Mean Field Variational Bayes (MFVB, see Jordan et al., 1999, Attias, 1999 Ghahramani and Beal, 2000, Wainwright and Jordan, 2008). Recent developments in VB consider gradient based algorithms (Ranganath et al., 2014, Kingma and Welling, 2014), which allow for a much richer class of models and approximating distributions to be utilised. These gradient based approaches are stochastic, and target the true gradient of a given loss function with an unbiased estimator. We refer to this approach as Stochastic Variational Bayes (SVB).

There is a rich tradition of using only a subset of the complete dataset for certain aspects of VB inference, such as for gradient estimation. Hoffman et al. (2010) and Wang et al. (2011) propose MFVB algorithms for Dirichlet Process Mixture (DPM) models where the optimisation of a subset of the auxiliary parameter vector occurs through gradient based approaches, using a subsample of the complete data at each iteration. Hoffman et al. (2013) and Titsias and L´zaro-Gredilla (2014) a implement this data subsampling into the fully gradient based SVB approaches. Alternatively, Sato (2001) considers an alternative loss function defined as the expected value of the Kullback-Leibler (KL) divergence, with respect to the data generating process. Any realisation from the data generating process may be used within the MFVB coordinate descent algorithm, which is applied online with newly observed data substituted in as it becomes available. However, each of these approaches results in only a single posterior distribution conditioned on data up to some pre-specified time period T n , and do not provide a mechanism for the approximation to be updated at a later time period T n +1 following the availability of additional observations.

Smidl (2004) and Broderick et al. (2013) each consider VB approximations for Bayesian updating, resulting in a progressive sequence of approximate posterior distributions that each condition on data up to any given time period T n . Their approaches update to the time T n +1 by substitution of the time T n posterior with MFVB approximations, which are feasibly obtained due to assuming the model and approximation each adhere to a suitably defined exponential family form. In these special settings, MFVB is able to linearly combine the available optimally converged auxiliary parameters. While Smidl (2004) is concerned with state space models, Broderick et al. (2013) considers application to a latent Dirichlet allocation problem, and shows it performs favourably compared to the approach of Hoffman et al. (2010) in terms of log predictive score and computational time.

In this paper we formalise and extend the prior approximation approach, developing a new algorithm that we call Updating Variational Bayes (UVB). UVB can be applied to sequentially update posterior distributions, and in a manner suitable for applications of streaming data. UVB treats data as arriving in a sequence, with the production of recursive, but approximate, posterior distributions obtained from conditioning on past information at nominated time points according to a Bayesian updating scheme. The approach delivers the approximate posterior distributions to the user at any desired point in time, with each new update using only the data observed since the previous update time. UVB requires an optimisation step for each update, which may be too slow for practical use. To reduce the computational load of repeated updates, we extend UVB to a second algorithm, called Updating Variational Bayes with Importance Samping (UVB-IS). Significant gains in computation speed per update can be achieved, albeit with some potential cost in gradient estimator variance and subsequently accuracy. Our proposed UVB-IS shares some similarities with the gradient estimator of Sakaya and Klami (2017), however the important distinction is that our proposed UVB-IS is developed for the sequential updating setting.

We provide two simulation studies: a small scale time series forecasting application, and a larger clustering application, to compare the approximation error of each of SVB, UVB, and UVB-IS relative to exact inference obtained using MCMC. We also compare the computational time required by each of the variational approximations, and show that UVB-IS is substantially faster than either UVB or SVB, while incurring only a minor cost in performance, dependent on the application. We also demonstrate the application of UVB and UVB-IS to a simple hierarchical model to re-analyse the eight schools problem of Gelman et al. (1997), and measure the increased approximation error from the updating approaches relative to SVB in this setting.

Finally we demonstrate the application of UVB to the problem of updating posterior inference in the context of a DPM model. Here the aim is to provide Bayesian inference and prediction regarding the heterogeneous behaviour of 500 drivers from the New Generation Simulation dataset (FHWA, 2017), according to the distribution of their lateral lane position. In this context, data arrives rapidly. We introduce a new class of dependent approximating distributions, and show that the DPM model with UVB based inference is able to provide more accurate forecasts than those achieved using a standard MFVB based approach. UVB in this case has accuracy comparable to repeated use of (full data) SVB, but benefits from an ability to process updates sequentially as additional data arrives.

The paper is arranged as follows: in Section 2 we review standard VB methods and the available gradient algorithms commonly employed. In Section 3 we propose our main UVB approach, with

the UVB-IS extension detailed in Section 4. Next, Section 5 contains simulation studies for time series data and a mixture distribution, while Section 6 details applications of the newly proposed methods to the Eight Schools hierarchical model of Gelman et al. (2014). UVB is applied to a vehicle DPM model in Section 7, and Section 8 concludes the paper.

## 2 Background on Variational Bayes

Before introducing our novel algorithms for recursively updating approximations to the posterior, the main ideas associated with the implementation of an SVB approach are introduced. A more detailed description of SVB can be found in Blei et al. (2017), with further references provided therein.

The usual target of Bayesian inference is the posterior distribution for a potentially vector-valued static parameter θ , as characterised by its probability density function (pdf) denoted by p ( θ y | 1: T ). Here y 1: T denotes data observed from time 1 to T and the posterior pdf is obtained using Bayes' theorem, given by

$$p ( \theta | y _ { 1 \colon T } ) = \frac { p ( y _ { 1 \colon T } | \theta ) p ( \theta ) } { \int _ { \theta } p ( y _ { 1 \colon T } | \theta ) p ( \theta ) d \theta } \,, \quad \, \quad \, \quad \, \quad \, \quad \, \quad \, \quad ( 1 )$$

where p ( θ ) denotes the pdf for the prior distribution that characterises belief about θ prior to the observation of y 1: T . Although MCMC algorithms are commonly used to produce a (typically dependent) sample from this posterior distribution, these can be computationally intensive.

As an alternative to MCMC, VB aims to approximate the pdf in (1) with another density of given parametric form, denoted by q λ ( θ y | 1: T ). Here λ is a vector of auxiliary parameters associated with the approximation, to be selected via optimisation. We note that the distribution q is explicitly parameterised by λ , and any evaluation of this distribution does not require y 1: T . The approximating distribution depends on y 1: T only through the choice of λ , however it is included in the notation to reinforce that q λ ( θ y | 1: T ) is an approximation to the posterior distribution p ( θ y | 1: T ).

In the SVB context, the family of the approximating distribution q λ is held fixed, with the member of that family indexed by the parameter vector λ selected to minimise a given loss function. Typically the KL divergence (Kullback and Leibler, 1951) from q λ ( θ y | 1: T ) to p ( θ y | 1: T ), denoted as KL q [ λ ( θ y | 1: T ) || p ( θ y | 1: T )], is used, with

$$K L [ q _ { \lambda } ( \theta | y _ { 1 \colon T } ) \, | | \, p ( \theta | y _ { 1 \colon T } ) ] = E _ { q } \left [ \log ( q _ { \lambda } ( \theta | y _ { 1 \colon T } ) ) - \log ( p ( \theta | y _ { 1 \colon T } ) ) \right ] \,.$$

Often in practice, the KL divergence in (2) is intractable, with p ( θ y | 1: T ) only known up to a proportionality constant due to the difficulties involved in the evaluation of the integral in the denominator of (1). Nevertheless, it has been shown that an equivalent problem to minimising the KL divergence is to maximise the so-called evidence lower bound (ELBO Attias, 1999), given by

$$\mathcal { L } ( q, \lambda ) = E _ { q } \left [ \log ( p ( \theta, y _ { 1 \colon T } ) ) - \log ( q _ { \lambda } ( \theta | y _ { 1 \colon T } ) ) \right ].$$

Afurther complication that typically arises when attempting to implement SVB is that an analytical expression for the expectation in (3) may not be available. In this case, maximisation of the ELBO may be achieved via stochastic gradient ascent (SGA, Bottou, 2010). To apply SGA to the problem of maximising the ELBO, an inital value λ (1) is selected and is recursively modified to λ ( m ) , for m = 2 3 , , . . . , according to

$$\lambda ^ { ( m + 1 ) } = \lambda ^ { ( m ) } + \rho ^ { ( m ) } \frac { \widehat { \partial \mathcal { L } ( q, \lambda ) } } { \partial \lambda } \Big | _ { \lambda = \lambda ^ { ( m ) } }$$

with the final value of λ ( M ) obtained when the change from L ( q, λ ( M -1) ) to L ( q, λ ( M ) ) falls below some pre-specified threshold (Hoffman et al., 2013).

The adjustment term in (4) is made of two factors, the so-called learning rate , ρ ( m ) , and an estimate of the gradient of the ELBO, ̂ ∂ L ( q, λ ) ∂ λ . A popular estimator of this gradient is the score-based estimator (Ranganath et al., 2014), given by

$$\frac { \widehat { \partial \mathcal { L } ( q, \lambda ) } } { \partial \lambda } _ { S C } = \frac { 1 } { S } \sum _ { j = 1 } ^ { S } \frac { \partial \log ( q _ { \lambda } ( \theta ^ { ( j ) } | y _ { 1 \cdot T } ) ) } { \partial \lambda } \left ( \log ( p ( y _ { 1 \cdot T }, \theta ^ { ( j ) } ) ) - \log ( q _ { \lambda } ( \theta ^ { ( j ) } | y _ { 1 \cdot T } ) ) - \widehat { a } \right ),$$

where the simulated values { θ ( j ) , for j = 1 2 , , . . . , S } are drawn from the presiding approximating density q λ ( m ) ( θ y | 1: T ), and ̂ a is a vector of control variates with

$$\widehat { a } _ { k } = \frac { \widehat { C o v } \left ( \frac { \partial \log ( q _ { \lambda } ( \theta | y _ { 1 \cdot T } ) ) } { \partial \lambda _ { k } } \left ( \log ( p ( y _ { 1 \cdot T }, \theta ) ) - \log ( q _ { \lambda } ( \theta | y _ { 1 \cdot T } ) ) \right ), \frac { \partial \log ( q _ { \lambda } ( \theta | y _ { 1 \cdot T } ) ) } { \partial \lambda _ { k } } \right ) } { \widehat { V a r } \left ( \frac { \partial \log ( q _ { \lambda } ( \theta | y _ { 1 \cdot T } ) ) } { \partial \lambda _ { k } } \right ) }.$$

As (5) results in an unbiased estimator of the gradient of the ELBO, it is known that the SGA procedure will converge in probability to a local maximum (Robbins and Monro, 1951), provided that the learning rate sequence 1 satisfies

$$\sum _ { m = 1 } ^ { \infty } \rho ^ { ( m ) } = \infty$$

and

$$\sum _ { m = 1 } ^ { \infty } ( \rho ^ { ( m ) } ) ^ { 2 } < \infty.$$

We note that although SGA is itself a recursive procedure, the result in the VB context is the one-time posterior pdf approximation q λ ∗ ≈ p ( θ y | 1: T ), where λ ∗ = λ ( M ) is the optimal parameter.

## 2.1 Dependence in the Approximation

Considering the vector θ = ( θ , θ 1 2 ) , the application of SVB often employs the so-called Mean Field ′ approximation (Bishop, 2006) where the approximating distribution is factorised as

$$q _ { \lambda } ( \theta _ { 1 }, \theta _ { 2 } | y _ { 1 \colon T } ) = q _ { \lambda } ( \theta _ { 1 } | y _ { 1 \colon T } ) q _ { \lambda } ( \theta _ { 2 } | y _ { 1 \colon T } ).$$

However SVB allows more general forms of the approximating distribution that may include dependence, for example

$$q _ { \lambda } ( \theta _ { 1 }, \theta _ { 2 } | y _ { 1 \colon T } ) = q _ { \lambda } ( \theta _ { 1 } | y _ { 1 \colon T } ) q _ { \lambda } ( \theta _ { 2 } | \theta _ { 1 }, y _ { 1 \colon T } ). & & ( 1 0 )$$

In this paper we also consider approximating distribution families that include the true posterior distribution for the subset θ 2 , when available. We implicitly use the marginal posterior for the

1 The learning rate used for all implementations of SGA in this paper is provided by the Adaptive Moment (Adam) algorithm of Kingma and Ba (2014).

approximation in Section 5, while in Section 7 we also explicitly include the exact conditional distribution in place of the approximation, i.e.

$$q _ { \lambda } ( \theta _ { 1 }, \theta _ { 2 } | \boldsymbol y _ { 1 \colon T } ) & = q _ { \lambda } ( \theta _ { 1 } | \boldsymbol y _ { 1 \colon T } ) p ( \theta _ { 2 } | \theta _ { 1 }, \boldsymbol y _ { 1 \colon T } ). & ( 1 1 )$$

To our knowledge, the potential to exploit this conditional approximation structure - and in particular to include an exact component within that structure - appears to be a novel contribution to the literature.

## 3 Updating Variational Bayes

We now introduce the proposed algorithm for updating VB when data is observed in an online setting. Let T , T 1 2 , . . . be a sequence of time points, from which a sequence of posterior distributions p ( θ y | 1: T 1 ) , p ( θ y | 1: T 2 ) , . . . , is desired. Now suppose that the (exact) posterior distribution for the governing (static) parameter vector θ is available, as given by its pdf p ( θ y | 1: T n ). Our objective is to update this posterior distribution, after observing data up to, and including, time T n +1 , when the additional T n +1 -T n data points have become available. The pdf of the resulting updated posterior distribution is denoted as p ( θ y | 1: T n +1 ). In an online setting, where new data continues to appear, we will want to repeat this updating procedure sequentially, each time updating the past posterior to reflect all of the data, including the latest available.

The usual application of Bayes' rule at a given time T n +1 involves a likelihood made up of T n +1 factors. However with the availability of the posterior at time T n , given by its density p ( θ y | 1: T n ), the updated time T n +1 posterior is given by

$$p ( \theta | y _ { 1 \colon T _ { n + 1 } } ) \, \in p ( y _ { T _ { n } + 1 \colon T _ { n + 1 } } | y _ { 1 \colon T _ { n } }, \theta ) p ( \theta | y _ { 1 \colon T _ { n } } ),$$

where p ( y T n +1: T n +1 | θ y , 1: T n ) on the right hand side of (12) is comprised of only T n +1 -T n factors.

We propose the Updating Variational Bayes (UVB) algorithm for use when the evaluation of the online posterior updating is computationally demanding. Our UVB algorithm, detailed in Algorithm 1, is initialised by forming the variational approximation at a given time T 1 as q λ ∗ 1 ( θ y | 1: T 1 ) where

$$\lambda _ { 1 } ^ { * } = \arg \min _ { \lambda _ { 1 } } K L [ q _ { \lambda _ { 1 } } ( \theta | y _ { 1 \colon T _ { 1 } } ) \, | | \, p ( \theta | y _ { 1 \colon T _ { 1 } } ) ].$$

At this first stage, we simply approximate the first posterior p ( θ y | 1: T 1 ) with the optimised distribution as in SVB, namely q λ ∗ 1 ( θ y | 1: T 1 ) .

In general then, after approximating the posterior at time T n with q λ ∗ n ( θ y | 1: T n ) and observing additional data up to time T n +1 , UVB replaces the posterior construction described by (12) with the available approximation,

$$\widetilde { p } ( \theta | y _ { 1 \colon T _ { n + 1 } } ) \in p ( y _ { T _ { n } + 1 \colon T _ { n + 1 } } | \theta ) q _ { \lambda _ { n } ^ { * } } ( \theta | y _ { 1 \colon T _ { n } } ).$$

This defines an alternate target distribution, ˜ p ( θ y | 1: T n +1 ) , referred to as the 'pseudo-posterior' at time T n +1 .

The objective for each update is to find λ ∗ n +1 (and hence q λ ∗ n +1 ( θ y | 1: T n +1 )) through the minimisation of the KL divergence to the corresponding pseudo-posterior, resulting in

$$\lambda _ { n + 1 } ^ { * } = \arg \min _ { \lambda _ { n + 1 } } K L [ q _ { \lambda _ { n + 1 } } ( \theta | y _ { 1 \cdot T _ { n + 1 } } ) \, | | \, \widetilde { p } ( \theta | y _ { 1 \cdot T _ { n + 1 } } ) ],$$

for each n = 1 2 , , . . . . The sequence of distributional families q λ 1 , q λ 2 , . . . , may differ at each time period, though we note it is convenient to hold the family fixed.

Algorithm 1: Updating Variational Bayes (UVB) Input: Prior, Likelihood. Result: Posterior approximation at T τ . Observe y 1: T 1 . Minimises KL q [ λ 1 ( θ y | 1: T 1 ) || p ( θ y | 1: T 1 )] using SGA via (5). for n in 1 , . . . , τ - 1 do Observe next data y T n +1: T n +1 . Use q λ n ( θ y | 1: T n ) and (14) to construct the UVB pseudo-posterior up to proportionality. Minimise KL q [ λ n +1 ( θ y | 1: T n +1 ) || ˜ p ( θ y | 1: T n +1 )] using SGA via (5). end

We note some important features of the proposed UVB algorithm compared with an SVB implementation. First, at time T n +1 an SVB implementation would target the exact posterior p ( θ y | 1: T n +1 ) ∝ p ( y 1: T n +1 | θ ) p ( θ ) whereas UVB instead targets an alternate pseudo-posterior distribution in (14). Second, at time T n +1 , the evaluation for UVB corresponding to (5) is composed of only T n +1 -T n factors. Hence, the computational complexity of UVB has rate O T ( n +1 -T n ) rather than rate O T ( n +1 ), i.e. computing UVB is not increasing in the number of observations for equally spaced intervals, as is the case for SVB. Third, unlike SVB, the UVB algorithm can begin even when only part of the data has been observed, making it well-suited to online applications. Further, the prevailing optimal value of λ n , denoted λ ∗ n , could be used as the UVB starting value for the optimisation at time T n +1 as long as the class of approximating distributions q is the same for each update. This may reduce the number of SGA iterations required for the UVB algorithm to converge. However, even with frequent updating via UVB, there will be some loss of accuracy in the posterior approximation at time T n +1 , q λ n +1 ( θ y | 1: T n +1 ), relative to the corresponding approximation obtained by SVB. The extent of this loss will be context specific.

Clearly there will be a trade-off between computational speed and accuracy. These issues are investigated in a simulation setting in Section 5. Before exploring these aspects, we introduce a modified approach whereby the computational speed may be further improved, albeit potentially with some additional loss in accuracy. This modified approach, referred to as UVB with Importance Sampling (UVB-IS), is described in the next section.

## 4 UVB with Importance Sampling

An application of UVB up to some time T n involves SVB inference at time T 1 followed by n -1 updates, for a total of n applications of SGA optimisation. Repeated updates may incur a significant computational overhead relative to SVB, which applies only a single SGA algorithm using all data up to time T n . In this section we address this problem and explore the possibility of achieving large computational gains per update through the incorporation of ideas from importance sampling. (For a general overview of importance sampling, see Gelman et al. (2014).) Before introducing our UVB with Importance Sampling (UVB-IS) algorithm, we briefly review the incorporation of importance sampling into SGA, as introduced by Sakaya and Klami (2017).

Temporarily suppressing the subscript n on the given time period T , the m th iteration in the SGA algorithm for a given target VB posterior changes λ ( m ) to λ ( m +1) via S simulations of θ ( m ) from q λ ( m ) ( θ y | 1: T ) as per (5). For each of these simulations, the log-likelihood, log-prior, and additional terms involving q λ ( m ) ( θ y | 1: T ) must be evaluated. Note that, for large scale applications this computation is dominated by the T terms in the log-likelihood.

In the subsequent SGA iteration from λ ( m +1) to λ ( m +2) , the evaluation of the log-likelihood requires a new set of S simulations θ ( m +1) from q λ ( m +1) ( θ y | 1: T ). Sakaya and Klami (2017) note that as the change from λ ( m ) to λ ( m +1) is likely to be small, the distributions q λ ( m ) ( θ y | 1: T ) and q λ ( m +1) ( θ y | 1: T ) will likely be similar. Using this motivation, an alternative gradient estimator is suggested for each iteration k = m + 1 , m + 2 , . . . , m + r via an importance sampler that uses q λ ( m ) ( θ y | 1: T ) as a proposal distribution, rather than generating new draws of θ from each q λ ( k ) ( θ y | 1: T ). This approach retains the set of samples θ ( m ) and their associated log-likelihood values, only resampling θ and re-evaluating the corresponding log-likelihood at iteration m + r + 1. In the SVB context the value of r should not be taken to be too large, as substantial differences between λ ( m ) and λ ( m r + ) may lead to a corresponding increase in the variance of the resulting gradient estimator.

In the context of UVB, we sequentially update the posterior approximation at each time T n via repeated applications of SGA. As before UVB-IS holds the family of the approximating distribution q λ fixed between each update, and sets the initial value of the parameter vector at time T n +1 equal to the optimal value from the previous update, i.e. we set λ (1) n +1 = λ ∗ n . During the subsequent application of SGA, the sequence of parameter vectors λ (1) n +1 , λ (2) n +1 , . . . , λ ∗ n +1 corresponds to a sequence of distributions moving from q λ ∗ n ( θ y | 1: T n ) to q λ ∗ n +1 ( θ y | 1: T n +1 ). For repeated updates with small values of T n +1 -T n , the new information about θ in y T n +1: T n +1 will typically be relatively small, and unless there is a structural change in the data process, we expect the approximating distributions will become similar.

The above observation motivates the addition of an importance sampling gradient estimator to be applied for each update. In each update using the SGA algorithm at time T n +1 all of the requisite gradients are estimated via importance sampling, using the previous UVB posterior q λ ∗ n ( θ y | 1: T n ) as the (identical) proposal distribution. The consequence of this approach is that only S θ samples are required for the entire SGA algorithm, and the likelihood is evaluated S times in total, rather than S times per iteration (or S times per r iterations in the case of Sakaya and Klami (2017)).

Suppressing the SGA iteration superscript index ( m ), the UVB-IS gradent estimator is derived from the score-based estimator implied by (5). In this case, the updated joint distribution, given by p ( y T n +1: T n +1 , θ y | 1: T n ), is replaced by an expression proportional to (14), with

$$\frac { \partial \mathcal { L } ( q, \lambda _ { n + 1 } ) } { \partial \lambda _ { n + 1 } } = \int _ { \theta } q _ { \lambda _ { n + 1 } } ( \theta | y _ { 1 \colon T _ { n + 1 } } ) \underbrace { \frac { \partial \log ( q _ { \lambda _ { n + 1 } } | y _ { 1 \colon T _ { n + 1 } } ) } { \partial \lambda _ { n + 1 } } \left ( \log \left ( \frac { \widetilde { p } ( y _ { T _ { n + 1 } \colon T _ { n + 1 } }, \theta | y _ { 1 \colon T _ { n } } ) } { q _ { \lambda _ { n + 1 } } ( \theta | y _ { 1 \colon T _ { n + 1 } } ) } \right ) - \widehat { a } \right ) } _ { f ( \theta ) } d \theta. \\ M l t i n i c i a t i o n \, \text{and division of the intogram in } ( 1 6 \vee \text{by} \, a, \theta | a, a \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \real \, \null \, \text{allows it to be written as an}$$

Multiplication and division of the integrand in (16) by q λ ∗ n ( θ y | 1: T n ) allows it to be written as an expectation with respect to q λ ∗ n ( θ y | 1: T n ),

$$\frac { \partial \mathcal { L } ( q, \lambda _ { n + 1 } ) } { \partial \lambda _ { n + 1 } } = \int _ { \theta } q _ { \lambda _ { n } ^ { * } } ( \theta | y _ { 1 \colon T _ { n } } ) \frac { q _ { \lambda _ { n + 1 } } ( \theta | y _ { 1 \colon T _ { n + 1 } } ) } { q _ { \lambda _ { n } ^ { * } } ( \theta | y _ { 1 \colon T _ { n } } ) } f ( \theta ) d \theta,$$

where we note the factor f ( θ ) is defined using the underbrace in (16). Hence, (17) may be estimated via a Monte Carlo average,

$$\frac { \partial \mathcal { L } ( \bar { q }, \bar { \lambda } _ { n + 1 } ) } { \partial \lambda _ { n + 1 } } _ { I S } = \frac { 1 } { S } \sum _ { j = 1 } ^ { S } w ( \theta ^ { ( j ) } ) f ( \theta ^ { ( j ) } )$$

since θ ( j ) ∼ q λ ∗ n ( θ y | 1: T n ) and

$$\nu ^ { \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \mu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \varepsilon \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nu \nolimits _ { \nu } \nu ^ { \nu } } \quad w ( \theta ^ { ( j ) } ) = \frac { q _ { \lambda _ { n + 1 } } } { q _ { \lambda _ { n } ^ { \nu } } } ( \theta ^ { ( j ) } | y _ { 1 \cdot T _ { n + 1 } } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ( \theta ^ { ( j ) } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu }) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ | \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \narrow } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } | _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ } _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ r } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } \ ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) ^ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { {nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu ] } _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) ^ _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _, _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ <nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } ) _ { \nu } )$$

with ̂ a estimated as per Equation (6).

Since only the value of λ n +1 changes in each iteration of SGA, and the S samples θ ( j ) are held fixed, only the terms involving λ n +1 , namely ∂ ∂ λ n +1 log( q λ n +1 ( θ ( j ) | y 1: T n +1 )) and q λ n +1 ( θ ( j ) | y 1: T n +1 ), are required to be calculated.

The variance of the UVB-IS gradient estimator is increased relative to the score-based gradient estimator in (5) due to the presence of the importance sampling weights. This increased variance may result in a reduction in the accuracy of q λ ∗ n +1 ( θ y | 1: T n +1 ). This is due to the fact that the algorithm stopping criterion, which is a sufficiently small value of |L ( q, λ ( m +1) ) -L ( q, λ ( m ) ) | can only be evaluated approximately by a noisy estimator, also produced via an importance sampler. As the computation per iteration is extremely small, S may be set to a larger value to reduce the variance, thereby allowing the user the capacity to balance the inevitable trade-off between computational time and approximation accuracy to suit their requirements. Provided there is no major structural change in the data generating process, it is expected that the distributions q λ ∗ n ( θ y | 1: T n ) and q λ ∗ n +1 ( θ y | 1: T n +1 ) become more similar as n increases, subsequently reducing the UVB-IS gradient estimator variance.

The proposed UVB-IS algorithm is summarised in Algorithm 2. Figure 1 provides a diagram to help illustrate the differences between the approach of Sakaya and Klami (2017) to UVB-IS. In panel (a) of Figure 1, each block indicates r separate iterations of SGA, each undertaken over an entire sample of length T , with arrows indicating that the final iteration of each block is used as an importance sampling proposal distribution for the entire next block. That is, there is one SGA algorithm applied for all data, but the importance sampling distribution changes every r th iteration until convergence is reached. In panel (b) of Figure 1, three distributional updates using UVB-IS are depicted. In this case, the posterior itself is updated periodically, as indicated by arrows and corresponding to times T , T 1 2 , and T 3 , with the same importance sampling distribution used for all SGA iterations needed to complete a single distributional update.

## 5 Simulation Study

To investigate the trade-off between the computational efficiency and accuracy of different methods we consider two simulated examples. The first is a time series forecasting application, while the second is a clustering example based on a mixture model. As well as considering both of the proposed algorithms (i.e. UVB and UVB-IS) we also consider a standard SVB approach and an exact MCMC algorithm, based on a Random Walk Metropolis Hastings strategy (see Gilks et al.,

Algorithm 2: UVB with Importance Sampling (UVB-IS) Input: Prior, Likelihood. Result: Approximating distribution at T τ . Observe y 1: T 1 . Minimises KL q [ λ 1 ( θ y | 1: T 1 ) || p ( θ y | 1: T 1 )] using SGA via (5). for n in 1 , . . . , τ - 1 do Observe next data y T n +1: T n +1 . Sample θ ( j ) ∼ q λ ∗ n ( θ y | 1: T n ) for j = 1 2 , , . . . S . Evaluate p ( y T n +1: T n +1 | θ ( j ) ) and q λ ∗ n ( θ ( j ) | y 1: T n ) for each j . Set λ (1) n +1 to λ ∗ n . Minimise KL q [ λ n +1 ( θ y | 1: T n +1 ) || ˜ p ( θ y | 1: T n +1 )] using SGA via (18). end

1995, Gilks et al., 1995, and Garthwaite et al., 2016), employed using all data observed up to each relevant time point.

## 5.1 Time Series Forecasting

In this first simulation study, we consider R = 500 replications of time series data, with each comprised of T = 500 observations simulated from the following auto-regressive order 3 (AR3) model,

$$y _ { t } = \mu + \phi _ { 1 } ( y _ { t - 1 } - \mu ) + \phi _ { 2 } ( y _ { t - 2 } - \mu ) + \phi _ { 3 } ( y _ { t - 3 } - \mu ) + e _ { t }$$

where e t ∼ N (0 , σ 2 ). For each replication, the true values of the parameters are obtained by drawing µ and each auto-regressive coefficient, φ , φ 1 2 , and φ 3 from an independent N (0 1) distribution, , accepting only draws where each φ lies in the AR3 stationary region. The precision parameter, σ -2 , is drawn from a Gamma distribution with both shape and rate equal to five.

The inferential objective is to progressively produce the one-step ahead predictive densities, each based on a UVB approximation to the target posterior distribution that results from assuming data arises from the AR3 model above, with a prior distribution specified for θ = { µ, φ 1 , φ 2 , φ 3 , log( σ 2 ) } . The prior distribution for the parameter vector is taken as θ ∼ N ( 0 5 , 10 I 5 ), where 0 d and I d denote, respectively, the d -dimensional zero vector and identity matrix. In particular, we aim to produce UVB-based approximate one-step ahead predictive distributions progressively, using at time T n all (and only) data up to and including time period T n , recursively for each of the 21 time periods given by T n = 100 125 150 , , , . . . 500. That is, the first target predictive distribution is given by p y ( 101 | y 1:100 ), followed by p y ( 126 | y 1:125 ), and continuing on to the final predictive p y ( 501 | y 1:500 ). For each update, predictive distributions are approximated with q λ taken as a K -component mixture of multivariate normal distributions, with the results compared using three different choices of K , with K = 1 2 and 3. This strategy allows us to compare the approximation accuracy of the , simple K = 1 distribution that may not adequately capture the entire posterior distribution as well as more complex approximations.

For the cases involving SVB and UVB, the score-based gradient estimator (5) uses S = 25 draws of θ , however we use a larger number of draws for UVB-IS to offset the increased variance, setting S = 100. Finally the MCMC benchmark comparison is based on 15000 posterior draws, with the first 10000 discarded for 'burn in'. In each approach we allow { φ , φ 1 2 , φ 3 } to take any value in

(a) Sakaya and Klami (2017)

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-3ddf3b04-8b6e-4540-8816-ac9f990ba0ae.jpg)

Figure 1: Graphical illustrations for importance sampling in SVB algorithms. (a): The approach of Sakaya and Klami (2017). Each block indicates r iterations of a single implementation of the SGA algorithm, with arrows indicating that the final iteration of each block is used as an importance sampling proposal distribution for the next r iterations contained in the subsequent block. (b): The UVB-IS algorithm, where each block indicates that SGA is applied three times, once for each of three distributional updates corresponding to an increase in data. For update, indicated by an arrow, a sample from the pseudo-posterior distribution corresponding to the previous update is used as proposal draws in every iteration of the SGA algorithm.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-4cd3f9bd-829e-4abf-bce7-1cb9ba2c34d8.jpg)

R 3 , so the posterior distribution for these parameters is not restricted to the AR3 stationary region.

Under the posterior given by p ( θ y | 1: T n ) together with the conditional predictive densities implied by (20), the one-step ahead predictive density is given by

$$p ( y _ { T _ { n } + 1 } | y _ { 1 \colon T _ { n } } ) = \int _ { \theta } p ( y _ { T _ { n } + 1 } | y _ { 1 \colon T _ { n } }, \theta ) p ( \theta | y _ { 1 \colon T _ { n } } ) d \theta.$$

Given our UVB approximation to the posterior at time T n , we approximate the integral in (21) using M draws θ (1) . . . θ ( M ) ∼ q λ ∗ n ( θ y | 1: T n ) , with the resulting marginal predictive density estimate given by

$$\widehat { p } ( y _ { T _ { n } + 1 } | y _ { 1 \colon T _ { n } } ) \approx \frac { 1 } { M } \sum _ { i = 1 } ^ { M } p ( y _ { T _ { n } + 1 } | y _ { 1 \colon T _ { n } }, \theta ^ { ( i ) } ).$$

The forecast accuracy associated with the resulting approximate predictive densities is measured using the cumulative predictive log score ( CLS ), given by

$$C L S _ { n } = \sum _ { j = 1 } ^ { n } \log ( \widehat { p } ( y _ { T _ { j } + 1 } ^ { ( o b s ) } | \boldsymbol y _ { 1 \colon T _ { j } } ) ),$$

for n = 1 2 , , ..., 21, where y ( obs ) T n +1 denotes the realised (observed) value of y T n +1 . In particular, we compare the mean CLS (MCLS) over the R replications, for each approximation method and each

given value of K , at consecutive update times T n with n = 1 2 , , .., 21 . The results are displayed in Figure 2, where each row indicates a different (known) value of K . Panel (a), on the left-hand side, the MCLS value is displayed relative to the MCLS value for MCMC inference, against the corresponding incremental values of T n +1 = 101 126 , , . . . , 501. As greater values of MLS indicate better forecast accuracy, it is not surprising to find that each of the approximate VB method produces a lower MLS relative to exact (MCMC) inference. Amongst the approximate methods, UVB performs the best, in terms of MLS, followed by SVB and UVB-IS at K = 1, though all of the variational methods improve as K increases.

Panel (b) of Figure 2 displays the relative cumulative mean runtime (RCMR) for each VB method using data up to T n , for T n = 100 125 150 , , , . . . 500, each calculated by dividing the CMR by the mean run time of the SVB algorithm fitting a single mixture (i.e. K = 1) at T n = 100. Note that the SVB approximation at each update time T n requires an application of the SGA algorithm using all data from time T = 1 up to time T n , while each of the updating methods are comprised of an SVB approximation at T 1 , followed by n -1 progressive updates each using only the new data since the last update period. As can be seen in the top row of Panel (b), the RCMRs are all identical and equal to one at the first update time T n = 100 and all increase with consecutive updates. While all three methods show an increase in RCMR with each update, the UVB method appears least efficient.

In this setting the amount of data in each update is relatively small, and UVB increases the runtime compared to SVB. This is due to the computational overhead of n SGA applications not being offset by a reduction in the number of log-likelihood calculations. In contrast, UVB-IS achieves sizeable computational gains despite showing minimal loss in the corresponding MLS for K &gt; 1.

To illustrate the reduced variability in subsequent UVB gradient estimators, Figure 3 displays the median variance of the gradient estimator for the posterior mean parameter of µ , with UVB at S = 25, and UVB-IS at each of S = 25 50 100 and 200, for each of six selected update periods. , , The algorithms at T 1 are applications of SVB with arbitary starting values for λ (1) 1 . This causes extreme, but declining, variance until convergence is reached. This pattern is typical for SVB inference at all time periods, parameters, and values of K . In subsequent time periods each updating method sets the starting value at λ (1) n = λ ∗ n -1 , noting that, for example, λ (1) 5 is equal to the omitted λ ∗ 4 . The estimated variance is subsequently orders of magnitude smaller than SVB. For small values of n the distributions q λ ∗ n ( θ y | 1: T n ) and q λ ( m ) n +1 ( θ y | 1: T n ) may differ as m increases, causing a reduction in the effective sample size associated with the gradient estimator, and an increase in the UVB-IS estimator variance. This effect is visible at times T , T 2 3 , and T 5 , though the UVB-IS estimator variance is low relative to SVB despite this inefficiency.

## 5.2 Mixture Model Clustering

In the second simulated example we consider the case where repeated measurements are simulated on N = 100 cross-sectional units at each of T = 100 times. The measurements for a given unit follows one of two possible DGPs, with the objective being to cluster the units into the correct groups, according to the underlying DGP, with additional observations of each cross-sectional unit accumulating in an online fashion as time increases. Each of these scenarios was then replicated R = 500 times.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-8fdeb487-abdd-45ac-8c93-0b87c13bdab1.jpg)

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-595606b0-6f2d-4364-a092-fc3015338f3f.jpg)

(a) Forecast accuracy (MCLS)

(b) Computational efficiency (RCMR)

Figure 2: AR3 Simulation (a): Forecast accuracy, indicated by one-step-ahead mean cumulative predictive log scores (MCLS), corresponding to incremental updates under competing methods (SVB, UVB and UVB-IS) relative to MCMC. Higher values of MCLS indicate better forecast accuracy. (b): Computational efficiency, indicated by relative cumulative mean runtime (RCMR), again corresponding to incremental updates under competing method (SVB, UVB and UVB-IS), each reported relative to the mean runtime for SVB when K = 1 and T n = 100.

For each independent replication, we generate data y i,t as the measurement of unit i at time t , for i = 1 2 , , ..., N and t = 1 2 , , ..., T as follows. We first define the cluster indicator for unit i as k i , and generate these for a given probability 0 &lt; π &lt; 1 according to

$$k _ { i } | \pi ^ { \ i. i. d. } \sim B e r n o u l l i ( \pi ),$$

where i.i.d abbreviates independent and identically distributed. Then, conditional on k i we let

$$y _ { i, t } | ( k _ { i } = j ), \mu _ { j }, \sigma _ { j } ^ { 2 } \stackrel { i n d } { \sim } N ( \mu _ { j }, \sigma _ { j } ^ { 2 } ),$$

for j = 0 1, with , ind short for independent . For this exercise, we set π = 0 5, with the replicated . values of µ 0 and µ 1 independently drawn from an N (0 0 25) , . distribution, while σ 2 0 and σ 2 1 are independently drawn from a uniform distribution over the interval (1 2). ,

Method, $ UVB. 25 UVB-IS. 50 UVB-IS. 100 UVB-IS. 200

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-d3327faa-ca41-4a93-a3f2-bf4cc5ee7fc1.jpg)

Figure 3: Median gradient estimator variance for the first 100 SGA iterations, with colour indicated by the acronym (either UVB or UVB-IS) followed by the value of S . Both UVB and UVB-IS algorithms have arbitary starting values at T 1 , denoted as λ (1) 1 , where the estimated gradient exhibits high variance. Note the difference in the y-axis scales at subsequent update times, where the starting value at time T n is set to the previous optimal value, i.e. λ (1) n = λ ∗ n -1 , noting several time periods have associated λ ∗ n values, but are omitted in the figure. Consequently, we the variance of the UVB gradient estimator is reduced relative to SVB, though the UVB-IS variance increases slightly for small n and large iteration index m .

Having simulated the data, the actual values k i are retained for each replication. We then use the UVB algorithm of the described model with the simulated data, as if all N units were being observed online at increasing times T n = 10 20 30 , , , ..., 100. The aim of the exercise is to cluster the units into two groups aligning with the true, but 'unobserved' value of k i .

The Bayesian updating analysis proceeds as follows. Denoting the collective parameter vector as θ = { log( σ 2 0 ) , log( σ 2 1 ) , µ 0 , µ 1 } , the joint prior for θ and π used at T 1 is given by independent components

$$& \theta \sim N ( 0 _ { 4 }, 1 0 \mathbb { I } _ { 4 } ), \text{ and } & & ( 2 6 ) \\ & \pi \sim B e t a ( \alpha, \beta ). & & ( 2 7 )$$

Note that the model for π in (24) and the prior in (27) imply that the k i are independent a priori , with marginal probabilities given by

$$\Pr ( k _ { i } = j ) = \frac { \mathcal { B } ( j + \alpha, \beta - j + 1 ) } { \mathcal { B } ( \alpha, \beta ) },$$

for j = 0 1, where , B · · ( , ) denotes the Beta function. Hence we have marginalised out the 'unknown' value of π , and can now proceed to updating the prior in (28), for each i = 1 2 , , ..., N , on the basis of information at times T n = 10 20 , , ..., 100 .

Denoting y i, 1: T n = { y i,t | t = 1 , . . . , T n } and y 1: N, 1: T n = { y i, 1: T n ; i = 1 , . . . N } , the initial augmented posterior distribution is given by

$$p ( \theta, k _ { 1 \colon N } | y _ { 1 \colon N, 1 \colon T _ { 1 } } ) \in p ( \theta ) \prod _ { i = 1 } ^ { N } p ( y _ { i, 1 \colon T _ { 1 } } | \theta, k _ { i } = j ) P r ( k _ { i } = j ),$$

with each likelihood p ( y i, 1: T 1 | θ , k i = ) given by the product of densities associated with (25) and j the value of j .

Due to the conditional independence of the components of θ and the cluster indicators, subsequent posteriors at times T n +1 are approximated by

$$\widehat { p } ( \theta, k _ { 1 \colon N } | \mathcal { y } _ { 1 \colon N, 1 \colon T _ { n + 1 } } ) \in \prod _ { i = 1 } ^ { N } p ( \mathcal { y } _ { i, T _ { n } + 1 \colon T _ { n + 1 } } | \theta, k _ { i } = j ) \widehat { \Pr } ( k _ { i } = j | \mathcal { y } _ { 1 \colon N, 1 \colon T _ { n } } ) p ( \theta | \mathcal { y } _ { 1 \colon N, 1 \colon T _ { n } } ), \quad ( 3 0 )$$

where the latent class probabilities, Pr( k i = j | y 1: N, 1: T n ), are estimated before updating with

$$\widehat { \Pr } ( k _ { i } = j | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { n } } ) \in \frac { 1 } { M } \sum _ { l = 1 } ^ { M } p ( \boldsymbol y _ { 1 \colon N, 1 \colon T _ { n } } | \boldsymbol \theta ^ { ( l ) }, k _ { i } = j ) \, \Pr ( k _ { i } = j ),$$

with θ ( ) l ∼ p ( θ y | 1: N, 1: T n ) for l = 1 2 , , . . . , M .

As in Section 5.1, the UVB and UVB-IS algorithms are compared to standard SVB and MCMC. Each of these approaches utilises an approximation to the augmented posterior of the form

$$q _ { \lambda _ { n + 1 } } ( \theta, k _ { 1 \cdot N } | y _ { 1 \cdot N, 1 \cdot T _ { n + 1 } } ) = q _ { \lambda _ { n + 1 } } ( \theta | y _ { 1 \cdot N, 1 \cdot T _ { n + 1 } } ) \prod _ { i = 1 } ^ { N } \widehat { \Pr } ( k _ { i } = j | y _ { 1 \cdot N, 1 \cdot T _ { n } } ),$$

where q λ n +1 ( θ y | 1: N, 1: T n +1 ) is a K = 1 2, or 3 component mixture of multivariate normal distribu-, tions and the θ ( ) l samples used to estimate (31) are simulated from the previous approximation q λ n ( θ y | 1: N, 1: T n ).

The form of the approximation used in (32) is chosen due to the fact that the gradient of the augmented divergence, KL q [ λ n ( θ k , 1: N | y 1: N, 1: T n ) || ̂ p ( θ k , 1: N | y 1: N, 1: T n )] is equivalent to the gradient of the marginal divergence, KL q [ λ n ( θ y | 1: N, 1: T n ) || ̂ p ( θ y | 1: N, 1: T n )], and hence the same approximation can be found by instead targeting the marginal posterior distribution,

$$p ( \theta | y _ { 1 \colon N, 1 \colon T _ { 1 } } ) \, \in p ( \theta ) \, \prod _ { i = 1 } ^ { N } \left ( \sum _ { j = 0 } ^ { 1 } p ( y _ { i, 1 \colon T _ { 1 } } | \theta, k _ { i } = j ) \, \Pr ( k _ { i } = j ) \right ),$$

or its updated form

$$\widehat { p } ( \theta | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { n + 1 } } ) \in \prod _ { i = 1 } ^ { N } \left ( \sum _ { j = 0 } ^ { 1 } p ( \boldsymbol y _ { i, T _ { n } + 1 \colon T _ { n + 1 } } | \theta, k _ { i } = j ) \widehat { \Pr } ( k _ { i } = j | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { n } } ) p ( \theta | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { n } } ) \right ).$$

At each update we estimate class labels for k i according to

$$\widehat { k } _ { i, n } = \arg \max _ { j } \widehat { \Pr } ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n } } ),$$

and assign a classification accuracy (CA) score at T n , given by glyph[negationslash]

$$C A _ { n } = \max \left ( \frac { 1 } { N } \sum _ { i = 1 } ^ { N } I ( \widehat { k } _ { i, n } = k _ { i } ), \ \frac { 1 } { N } \sum _ { i = 1 } ^ { N } I ( \widehat { k } _ { i, n } \neq k _ { i } ) \right ),$$

the proportion of successful classifications up to label switching.

SVB and UVB gradients are estimated from S = 25 samples of θ per iteration, while UVB-IS sets S = 100.

The results for this problem are displayed in Figure 4, where each row corresponds to a different value of K . Panel (a) displays the mean classification accuracy (MCA), corresponding to updates at times T n = 10 20 , , ..., 100 and across R replications. As in the previous study, each variational approximation reduces accuracy relative to exact inference. In this example both UVB and UVBIS are more accurate than SVB, with little change apparent in any variational approach between different values of K .

As in the previous section, Panel (b) of Figure 4 displays the relative cumulative mean runtime (RCMR) for each VB method using data up to T n , for T n = 10 20 , , . . . , 100, calculated relative to the mean run time of the SVB algorithm fitting a single mixture at the initial update time, when T n = 10. As the problem features a large number of cross-sectional units, the computational cost of calculating the log-likelihood dominates the gradient estimation. Processing smaller amounts of data, and having a reduced gradient variance, considerably increases the computational efficiency of UVB and UVB-IS relative to SVB while increasing accuracy. Despite the updating methods consisting of 10 SGA applications while SVB uses only one, UVB and UVB-IS require, on average, 14 7%, and 4 6% of the computational time of SVB, respectively, in the top right panel when . . K = 1 at time T 10 = 100.

## 6 Eight Schools Example

In this section the co-called 'Eight Schools' problem described in Gelman et al. (2014) is considered. This problem analyses the effectiveness of a short term coaching program, implemented independently by each of eight studied schools, for the SAT-V test . 2 For students i = 1 2 , , . . . , N j in each school j = 1 2 , , . . . , 8, consider the linear regression

$$S A T { \text{-} } V _ { i, j } = \beta _ { 0, j } + \beta _ { 1, j } C o a c h _ { i, j } + \beta _ { 2, j } P S A T { \text{-} } V _ { i, j } + \beta _ { 3, j } P S A T { \text{-} } M _ { i, j } + \epsilon _ { i, j }$$

where Coach i,j is a dummy variable indicating a student's inclusion (or not) in a coaching program run by their school, alongside control variables PSAT V -i,j and PSAT M -i,j , corresponding to each student's scores in the verbal and mathematical preliminary SAT, respectively.

Following Gelman et al. (2014), the estimated school-level coaching coefficients that correspond to the ordinary least squares estimators are taken as the observations, y j = ̂ β 1 ,j , for j = 1 2 , , . . . 8, and have approximate sampling distributions given by

$$y _ { j } | \theta _ { j }, \sigma _ { j } ^ { 2 } & \sim \mathcal { N } ( \theta _ { j }, \sigma _ { j } ^ { 2 } ),$$

where θ j is the latent 'true' effectiveness of school j 's coaching program. The standard deviation of the sampling distribution, σ j , is assumed to be known and is held fixed at the standard error estimated by the relevant regression, with each having taken account of the individual school sample

2 The SAT-V is a standardised aptitude test commonly taken by high school students in the USA.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-04631427-f7dd-46c3-ade2-742645520d8b.jpg)

(a) Clustering Accuracy (MCA)

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-a77008ba-573d-4bce-a93d-0c78b583f4e1.jpg)

(b) Computational Efficiency (RCMR)

Figure 4: (a): Mean Classifcation Accuracy (MCA) for each inference method, higher is better. (b): Average SVB runtime for one approximation at time T n and average cumulative UVB and UVB-IS runtimes fit to T 1 , then updated n -1 times to T n . Runtimes are relative to the time required for the T 1 fit. UVB and UVB-IS perform better than SVB and are also much faster, as computation of the data likelihood is a large part of the gradient calculation in this scenario.

size N j .

Again following Gelman et al. (2014), we apply a hierarchical prior to the population mean values in (38), assuming that the θ j themselves are random and iid from a Studentt distribution,

$$\frac { \theta _ { j } - \mu } { \tau } \sim t ( \nu )$$

where ν is the degrees of freedom, fixed at ν = 4. The hierarchical model also employs the uninformative hyper-prior

$$p ( \mu, \tau ) \in 1,$$

over positive values of τ , and both positive and negative values of µ .

Collecting the unknown school means together and denoting by θ 1:8 = { θ , θ 1 2 , . . . , θ 8 } , the posterior

distribution of all unknowns and based on the observed values from all schools is then given by

$$p ( \theta _ { 1 \colon 8 }, \mu, \tau | y _ { 1 \colon 8 } ) & \in \prod _ { j = 1 } ^ { 8 } p ( y _ { j } | \theta _ { j }, \sigma _ { j } ^ { 2 } ) p ( \theta _ { j } | \tau, \mu ).$$

It is feasible to obtain this posterior exactly, via MCMC, for example using the algorithm provided in the statistical modelling platform Stan (Stan Development Team, 2018).

Our aim here is to demonstrate the application of UVB and UVB-IS to this hierarchical model, where with each update we sequentially 'observe' an additional school, as indicated by the inclusion of an additional observation y j . Each variational algorithm approximates the progressive posterior by the multivariate normal distribution q λ n ( θ 1: n , µ, τ | y 1: n ), for n = 1 2 , , ..., 8. The initial distribution approximation at T 1 for UVB and UVB-IS is given by the multivariate normal distribution q λ ∗ 1 ( θ , µ, τ 1 | y 1 ) where

$$\lambda _ { 1 } ^ { * } = \arg \min _ { \lambda _ { 1 } } K L [ q _ { \lambda _ { 1 } } ( \theta _ { 1 }, \mu, \tau | y _ { 1 } ) \, | | \, p ( \theta _ { 1 }, \mu, \tau | y _ { 1 } ) ].$$

Updates at further 'times' T n +1 = n +1 for , n = 1 2 , , . . . , 7, involves sequentially adding schools to the model targetting the pseudo-posterior distribution, given by the decomposition

$$\widetilde { p } ( \theta _ { 1 \colon n + 1 }, \mu, \tau | y _ { 1 \colon n + 1 } ) \in p ( y _ { n + 1 } | \theta _ { n + 1 } ) p ( \theta _ { n + 1 } | \mu, \tau ) q _ { \lambda _ { n } ^ { * } } ( \theta _ { 1 \colon n }, \mu, \tau | y _ { 1 \colon n } ).$$

Either UVB or UVB-IS then may be used to obtain the updated approximate posterior, given by q λ ∗ n +1 ( θ 1: n +1 , µ, τ | y 1: n +1 ), with

$$\lambda _ { n + 1 } ^ { * } = \arg \min _ { \lambda _ { n + 1 } } K L [ \varphi _ { \lambda _ { n + 1 } } ( \theta _ { 1 \colon n + 1 }, \mu, \tau | y _ { 1 \colon n + 1 } ) \, | | \, \widetilde { p } ( \theta _ { 1 \colon n + 1 }, \mu, \tau | y _ { 1 \colon n + 1 } ) ],$$

for n = 1 2 , , ..., y. As each update adds a new variable θ n +1 to the model, the optimal vector λ ∗ n +1 updates the auxiliary parameters associated with the pseudo-posterior distribution for θ n +1 together with the previously included variables µ, τ , and θ 1: n . We note that our implementation of UVB-IS here employs a hybrid strategy utilising importance sampled gradients (18) for simulations of µ, τ , and θ 1: n from the previous q λ ∗ n ( θ 1: n , µ, τ | y 1: n +1 ), and score-based gradients for θ n +1 , as per (5). The score-based gradients use samples generated from θ n +1 ∼ q λ n +1 ( θ n +1 | y 1: n +1 , µ, τ, θ 1: n ), which is available as this variational approximation was chosen to be a multivariate normal distribution.

We compare approximations that result from using UVB and UVB-IS, relative to the sequential implementation of SVB, as each new school is added. As the ordering of the inclusion of schools is arbitrary in this example, we report results that are averaged over a randomly selected 100 of the 8! = 40 320 possible permutations of school sequences. , For each ordering, the KL divergence KL q [ λ ( θ 1: n +1 , µ, τ | y 1: n +1 ) || p ( θ 1: n +1 , µ, τ | y 1: n +1 )] is calculated and tallied, using the exact posterior p (( bmθ 1: n +1 , µ, τ | y 1: n +1 ) in (41), each calculated using 10,000 MCMC sample draws retained following a burn-in period of 10,000 iterations.

These results are shown in Table 1, where the row labelled UVB contains the average difference between the KL divergence calculated from the UVB approximation and the KL divergence calculated from the SVB approximation. These values are calculated independently for each margin of the distribution, and for the entire joint distribution. Each KL divergence was obtained using simulated draws from each relevant distribution. Marginal densities were estimated using the

density function in R (R Core Team, 2017), with the corresponding joint density estimated using an additional vine copula (Dißmann et al., 2013). The row labelled UVB-IS contains the average difference between the corresponding UVB-IS and SVB KL divergences.

Table 1: Results of the Schools example. Average KL divergence measures: KL UVB -KL SV B (row 2) and KL UVB -IS -KL SV B (row 3), with each KL divergence calculated from the VB approximation to MCMC samples. Lower is better.

|        |    τ |    µ |   θ 1 |   θ 2 |   θ 3 |   θ 4 |   θ 5 |   θ 6 |   θ 7 |   θ 8 |   Joint |
|--------|------|------|-------|-------|-------|-------|-------|-------|-------|-------|---------|
| UVB    | 1.04 | 0.11 |  0.26 |  0.05 |  0.16 |  0.08 |  0.16 |  0.12 |  0.16 |  0.14 |    2.67 |
| UVB-IS | 0.16 | 0.64 |  0.32 |  0.34 |  0.38 |  0.22 |  0.17 |  0.27 |  0.36 |  0.42 |    5    |

## 7 Lane Position Example

Vehicle drivers may exhibit a tendency to move laterally (i.e. side-to-side) within their designated lane on a highway. Figure 5 displays this notion, by plotting the trajactory of five drivers as they travel along a section of the US Route 101 Highway, as taken from the Next Generation Simulation (NGSIM, FHWA (2017)) dataset. In this figure, the vehicles - indicated in black - are travelling towards the right, with each (estimated) lane centre line given by the red dashed line. Drivers likely adapt their position in real time, in at least partial response to the perceived position of vehicles that are travelling nearby.

The aim of this section is to apply the UVB methodology to analyse a model of the lateral position of vehicles. The model incorporates driver heterogeneity, while the analysis itself produces sequential, per-vehicle distributional forecasts of a large number of future car positions. The methodology suggests that a smart vehicle (i.e. one without a human driver) may be able to repeatedly 'observe' neighbouring vehicle positions, predict their positions in real time as they travel along the road, and appropriately respond to those forecasts.

Figure 5: The path of five selected vehicles from the NGSIM dataset, travelling from left to right, with each black line representing a unique vehicle, with estimated lane centre lines in red. This section of US Route 101 is comprised of five main lanes, with a sixth entry/exit lane not shown.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-37553b3b-7221-497c-b448-4774dffcd764.jpg)

To set up the scenario, we randomly select, from the NGSIM dataset, trajectories associated with N = 500 vehicles that do not change lane. We note that the NGSIM dataset is the result of a project conducted by the US Federal Highway Administration (FHWA), and includes data recorded from 6101 vehicles traveling along a 2235 foot long section of the US 101 freeway in Los Angeles, California from 7:50 am to 8:35 am on June 15th, 2005. Though initially collected by static cameras, the data was then processed by Cambridge Systematics Inc. to produce coordinates of the centre of the front of each vehicle at 100 millisecond intervals.

## 7.1 A Hierarchical Model

In developing a model for the position of cars we consider a number of issues. First, each vehicle/driver is likely to have its own idiosyncratic behaviour, captured by its own parameter values. Let y i,t denote the lateral deviation from the lane centre of vehicle i at time t , with details on calculating the lateral deviation provided in Appendix A. For i = 1 , . . . , N and t = 1 , . . . , T , we assume

$$y _ { i, t } \, | \, \mu _ { i }, \sigma _ { i } ^ { 2 } \stackrel { i n d } { \sim } \mathcal { N } \left ( \mu _ { i }, \sigma _ { i } ^ { 2 } \right ),$$

where µ i and σ 2 i are parameters specific to vehicle i . For simplicity, we collect the individual vehicle-specific parameters into a single vector, θ i , by defining θ i = ( µ , i log ( σ 2 i )), for i = 1 2 , , .., N . We note that alternative parametric models could be used here, including a time series model for vehicle i , with little loss in generality.

Multiple cars may display similar behaviour, a phenomenon that can be modeled by allowing different cross sectional units to share parameters. This structure, whereby cross sectional units belong to mixture components, leads to predictions that 'borrow strength' from the full sample of vehicles. To make this idea explicit, let k i denote an indicator variable such that vehicle i belongs to mixture component j if k i = . All vehicles within the same mixture component share parameters, that is j θ i = θ ∗ j , for all i such that k i = . Note that the star superscript and j j subscript are generally used to index the mixture component that the parameters belong to, while the subscript i is generally used to index the cross-sectional unit, i.e. vehicle.

Since the number of components are unknown and since there is a possibility that a new vehicle will be observed with behaviour that cannot be well described by any of the prevailing parameters, we consider an infinite mixture model. In particular, we use an infinite mixture model induced by a Dirichlet Process (DP) Prior for the distribution of the parameters. The DP prior is given by

$$G \sim D P ( \alpha, G _ { 0 } ) \,,$$

where G 0 is the DP base distribution, assumed here to be N ( 0 2 , 10 I 2 ), and the DP concentration parameter α is fixed here and equal to one. The prior for the collection of θ i values represent a draw from the DP, with

$$\theta _ { i } | G \stackrel { i i d } { \sim } G, \text{ for } i = 1, 2, \dots, N \,.$$

Combining (45), (46) and (47) leads to the hierarchy

$$G & \sim D P ( \alpha, G _ { 0 } ) \\ \theta _ { i } | G ^ { i i d } & \sim G, \text{ for } i = 1, 2, \dots, N \\ y _ { i, t } & \left | \, \theta _ { i } ^ { \ i n d } \sim \mathcal { N } \left ( \mu _ { i }, \sigma _ { i } ^ { 2 } \right ), \text{ for } i = 1, 2, \dots, N \text{ and } t = 1, 2, \dots, T.$$

We note that the DP prior induces clustering on the observation sequences, as described by the Chinese Restaurant Process (CRP, Aldous, 1985) representation. The CRP provides a mechanism for drawing from the prior of θ 1 , . . . , θ n , marginal of the random G , via the introduction of discrete variables that act as component indicators. Define s i as the number of unique values in k , k 1 2 , . . . , k i , and let n ij = ∑ i m =1 I ( k m = j ). Then, the indicator variables can be simulated from p k ( i = j α, | k 1: i -1 ) where

$$p ( k _ { 1 } = 1 \ | \ \alpha, G _ { 0 } ) = 1,$$

$$p ( k _ { i } = j | \alpha, G _ { 0 }, \ k _ { 1 \colon i - 1 } ) = \begin{cases} \begin{array} { c c c } \frac { n _ { i - 1, j } } { \alpha + i - 1 } \\ \frac { \alpha } { \alpha + i - 1 } \end{array} \end{cases} & \text{for $j=1,2,\dots,s_{i-1}$} \\ \text{for $j=s_{i-1}+1$,} \end{cases}$$

for i = 2 , . . . , N . Note that although simulation of the indicators does not require knowledge of G 0 , we include explicit conditioning on both α and G 0 in (49) and (50) to emphasise the marginalisation over G . Under the CRP, unique values of θ i , denoted as θ ∗ j , for j = 1 2 , , ..., s N are drawn from the base distribution G 0 , and if we set θ i = θ ∗ j for all i such that k i = , then ( j θ 1 , θ 2 , . . . , θ N ) is a draw from the hierarchical setup in (48). Note that although the model is an infinite component mixture model, under the CRP the maximum number of unique clusters, s N , can be no greater than the number of vehicles in the sample, N . For simplicity we retain the full vector θ ∗ 1: N , noting that some values θ ∗ 1: N may not be associated with any vehicle.

The overall model may be seen as a Dirichlet Process Mixture (DPM) model for the lane deviations. Background material regarding Bayesian analysis of DPM models, including many references and detailed discussions relating to MCMC-based techniques for sampling from the relevant posterior, is given in M¨ller et al. (2015). u Online VB-based inference for DPMs has been established using a Mean Field approach - see, e.g., Hoffman et al. (2010), Wang et al. (2011), and Kabisa et al. (2016)). In contrast, our approach incorporates SVB, which allows for greater flexibility regarding the form of the approximating posterior distribution. Another important distinction between our analysis and this literature is that our setting involves multiple observations over time, on each cross-sectional unit. Rather than updating as new cross-sectional units are observed, we update parameters relating to the same cross-sectional units observed periodically over a period of time.

## 7.2 Implementation of SVB at time T 1

Before discussing how UVB is applied to this problem it is instructive to discuss how SVB is implemented for the DPM in (48) that targets the posterior conditional on all cross-sectional units N over just the first time period from t = 1 to t = T 1 . For notational convenience, conditional dependence on α and G 0 is supressed in all notation for the remainer of this section. The objective is to minimise the KL divergence between a suitable variational approximation and a posterior that is augmented by indicator variables. To implement SVB, we must evaluate

$$p ( y _ { 1 \colon N, 1 \colon T _ { 1 } }, \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon N } ) = \left [ \prod _ { i = 1 } ^ { N } \prod _ { t = 1 } ^ { T _ { 1 } } p ( y _ { i, t } | \theta _ { 1 \colon N } ^ { * }, k _ { i } ) \right ] \left [ \prod _ { i = 1 } ^ { N } p ( k _ { i } | k _ { 1 \colon i - 1 } ) \right ] p ( \theta _ { 1 \colon N } ^ { * } )$$

for given values of y 1: N, 1: T 1 , θ ∗ 1: N , and k 1: N , . Each of the three main components on the right hand side of (51) can be computed from the hierarchical structure in (48) and the CRP, as Sethuraman (1994) shows that the unique values θ ∗ 1: N are a priori independent and identically distributed according to the base distibution G 0 .

A second required input into SVB is an approximate posterior density structure, given by q λ , and for this we propose

$$q _ { \lambda } ( \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon N } | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { 1 } } ) = \left [ \prod _ { j = 1 } ^ { N } q _ { j } ( \theta _ { j } ^ { * } | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { 1 } } ) \right ] \left [ \prod _ { i = 1 } ^ { N } p ( k _ { i } | \boldsymbol y _ { 1 \colon N, 1 \colon T _ { 1 } }, \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon i - 1 } ) \right ].$$

Each q j ( ) . on the right hand side is a bivariate normal distribution with unique means, variances and covariances for each i = 1 2 , , .., N , leading to a total of 5 N auxiliary parameters in the approximation. In the second product term on the right hand side of (52), the notation p is used instead of q since p k ( i | y 1: N, 1: T 1 , k 1: i -1 , θ ∗ 1: N ) is known exactly and can be computed recursively using

$$p ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { 1 } }, k _ { 1 \colon i - 1 }, \theta _ { 1 \colon N } ^ { * } ) \, \in p ( k _ { i } = j | k _ { 1 \colon i - 1 } ) p ( y _ { i, 1 \colon T _ { 1 } } | \theta _ { 1 \colon N } ^ { * }, k _ { i } ),$$

for i = 1 2 , , ..., N .

The use of the so-called full conditional distribution for k 1: N , given by the second product in (52), is a novel inclusion that enables our model to capture some of the dependence structure of the posterior. In contrast, a MFVB approximation would force posterior independence between each k i and every θ ∗ j , as in, for example, Wang et al. (2011).

Furthermore, in addition to minimising the KL divergence to the augmented posterior, our choice has the benefit of ensuring minimisation of the KL divergence to the corresponding marginal posterior. That is, the augmented gradients are given by

$$\frac { \partial K L [ q _ { \lambda _ { 1 } } ( \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon N } | y _ { 1 \colon N, 1 \colon T _ { 1 } } ) \, | | \, p ( ( \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon N } | y _ { 1 \colon N, 1 \colon T _ { 1 } } ) ] } { \partial \lambda _ { 1 } }$$

and are equal to the marginal gradients

$$\frac { \partial K L [ q _ { \lambda _ { 1 } } ( \theta _ { 1 \colon N } ^ { * } | y _ { 1 \colon N, 1 \colon T _ { 1 } } ) \, | | \, p ( \theta _ { 1 \colon N } ^ { * } | y _ { 1 \colon N, 1 \colon T _ { 1 } } ) ] } { \partial \lambda _ { 1 } },$$

and so the optimisation procedure is equivelent to one where the indicator variables used to construct the DPM have been marginalised out.

The proof of this result is shown in Appendix B.

## 7.3 Iterating UVB

Using data up to time T 1 , the first UVB posterior is obtained using SVB, as described in Section 7.2. For updating at time T n +1 , we construct a pseudo-posterior using information from the previous variational approximation q λ n ( θ ∗ 1: N , k 1: N | y 1: N, 1: T n ) in two distinct ways. First, the base distribution in the DP as the prior distibution for θ ∗ 1: N is updated to reflect the clustering present in the previously obtained posterior, and so is replaced with q λ n ( θ ∗ 1: N | y 1: N, 1: T n ). Second, retaining the form of the approximation in (52) for the update is complicated by the use of the full conditional distribution for k i , given by

$$p ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n + 1 } }, \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon i - 1 } ) \in p ( y _ { i, T _ { n } + 1 \colon T _ { n + 1 } } | \theta _ { 1 \colon N } ^ { * }, k _ { i } ) p ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n } }, \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon i - 1 } ), \quad ( 5 6 )$$

as all currently observed data up to time T n +1 is required for each new θ ∗ 1: N value simulated within the SGA algorithm. Instead our approach is to marginalise the variational distribution using

$$q ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n } }, k _ { 1 \colon i - 1 } ) = \int _ { \theta _ { 1 \colon N } ^ { * } } q _ { \lambda _ { n } } ( \theta _ { 1 \colon N } ^ { * } | y _ { 1 \colon N, 1 \colon T _ { n } } ) p ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n } }, \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon i - 1 } ) d \theta _ { 1 \colon N } ^ { * }, \quad ( 5 7 )$$

before each update, estimating (57) from a sample average of p k ( i = j | y 1: N, 1: T n , θ ∗ 1: N , k 1: i -1 ) using M samples θ ∗ 1: N and k 1: i -1 simulated from the available approximate distribution. This requires use of all observed data at T n , for each of the M samples, but is independent of θ ∗ 1: N and thus data up to T n is not required as new θ ∗ 1: N values are simulated in the SGA algorithm. The component of the variational approximation for k i is then replaced by

$$\widehat { p } ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n + 1 } }, \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon i - 1 } ) \in p ( y _ { i, T _ { n } + 1 \colon T _ { n + 1 } } | \theta _ { 1 \colon N } ^ { * }, k _ { i } = j ) q ( k _ { i } = j | y _ { 1 \colon N, 1 \colon T _ { n + 1 } }, k _ { 1 \colon i - 1 } ), \quad ( 5 8 )$$

which may be calculated using only the newly observed data y 1: N,T n +1: T n +1 in the SGA algorithm. Note that the marginalisation step for all updates uses the exact full conditional distribution from the CRP representation, p k ( i = j | y 1: N, 1: T n , θ ∗ 1: N , k 1: i -1 ), rather than the marginalised form ̂ p k ( i = j | y 1: N, 1: T n +1 , θ ∗ 1: N , k 1: i -1 ) from the previous update.

The targeted pseudo-posterior distribution for the update at T n +1 is given by

$$\widetilde { p } ( \theta _ { 1 ; N } ^ { * }, k _ { 1 ; N } | \boldsymbol y _ { 1 ; N, 1 ; T _ { n + 1 } } ) \in \prod _ { i = 1 } ^ { N } \left [ p ( \boldsymbol y _ { i, T _ { n + 1 } ; T _ { n + 1 } } | \boldsymbol o _ { 1 ; N } ^ { * }, k _ { i } ) q ( k _ { i } | \boldsymbol y _ { 1 ; N, 1 ; T _ { n } }, k _ { 1 ; i - 1 } ) \right ] \mathcal { q } _ { n } ( \boldsymbol o _ { 1 ; N } ^ { * } | \boldsymbol y _ { 1 ; N, 1 ; T _ { n } } ), \\ \text{when the two down} \, \text{distribution} \, \text{of} \, \text{the} \, \text{DD} \, \text{out} \, \text{in} \, \text{the} \, \text{DD} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{end}$$

where the base distribution of the DP posterior in the DPM (and its corresponding CRP) is replaced with it's associated variational approximation at time T n . The approximating distribution for the update at time T n +1 is given by

$$q _ { \lambda _ { n + 1 } } ( \theta _ { 1 ; N } ^ { * }, k _ { 1 ; N } | \boldsymbol y _ { 1 ; N, 1 ; T _ { n + 1 } } ) = \prod _ { j = 1 } ^ { N } q _ { j, n + 1 } ( \theta _ { j } ^ { * } | \boldsymbol y _ { 1 ; N, 1 ; T _ { n + 1 } } ) \prod _ { i = 1 } ^ { N } \widehat { p } ( k _ { j } | \boldsymbol y _ { 1 ; N, 1 ; T _ { n + 1 } }, \theta _ { 1 ; N } ^ { * }, k _ { 1 ; i - 1 } ). \quad ( 6 0 )$$

Given the pseudo-posterior (51), form of approximating distribution (60), and components of the time T n approximation: q λ n ( θ ∗ 1: N | y 1: N, 1: T n ) and q k ( i = j | y 1: N, 1: T n , k 1: i -1 ), the optimal parameter vector at time T n +1 , λ ∗ n +1 , may be obtained via Algorithm 3.

## 7.4 Predicting Lane Positions

Given a posterior approximation q λ n ( θ ∗ 1: N , k 1: N | y 1: N, 1: T n ) we may obtain the approximate predictive distribution for vehicle i at some future time T n + h as

$$q ( y _ { i, T _ { n } + h } | y _ { 1 \colon N, 1 \colon T _ { n } } ) = \int p ( y _ { i, T _ { n } + h } | \theta _ { 1 \colon N } ^ { * }, k _ { i } ) q _ { \lambda _ { n } } ^ { * } ( \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon N } | y _ { 1 \colon N, 1 \colon T _ { n } } ) d \theta _ { 1 \colon N } ^ { * } d k _ { 1 \colon N }.$$

After obtaining this distribution from samples { θ ∗ 1: N , k 1: N } ( j ) ∼ q ∗ λ n ( θ ∗ 1: N , k 1: N | y 1: N, 1: T n ) , for j = 1 2 , , . . . , M , we calculate the predictive log score (LS),

$$L S _ { i, n, h } = \log ( q ( y _ { i, T _ { n } + h } ^ { ( o b s ) } | y _ { 1 \colon N, 1 \colon T _ { n } } ) ),$$

where y ( obs ) i,T n + h is the observed value of y i,T n + h . The performance of the UVB algorithm is evaluated by comparing its cumulative predictive log scores relative to those produced by competing methods.

$$\text{Algorithm 3: UVB for the DPM} \\ \text{Input: DP base distribution G} or updated approximating distribution at T} _ { n + 1 }. \\ \text{Calculate (57) for all i}. \\ \text{Observe $y_{1:N,T}_{n+1:T}_{n+1}$}. \\ \text{Set $\mathcal{L}(q,\lambda_{n+1})=-\infty$}. \\ \text{Set initial values $\lambda_{n+1}^{n+1}$}. \\ \text{Set $m=1$}. \\ \text{while |\mathcal{L}(q,\lambda_{n+1})=-\mathcal{L}(q,\lambda_{n+1})|<\epsilon$ do} \\ | \text{ Simulate $\theta^{%}(s)N\sim q_{\lambda(m)(\theta^{%}_{1:N}|y_{1:N,1:T}_{n+1}) for s=1,2,\dots,S}$}. \\ \text{Simulate $\mathcal{L}(q,\lambda$ with probabilities (53) or (58).} \\ \text{Evaluate $\mathcal{P}(\mathcal{Y}_{1:N,1:T}_{n+1}$, $\theta^{%}_{1:S}$, $\mathcal{K}_{1:S}_{1:-1}$}. \\ \text{Evaluate $q_{\lambda_{n+1}(\theta^{%}_{1:N}$, $\mathcal{K}_{1:N}|y_{1:N,1:T}_{n+1}$}. \\ \text{Evaluate $\partialq_{\lambda_{n+1}(\theta^{%}_{1:N}$, $\mathcal{K}_{1:N}|y_{1:N,1:T}_{n+1})/\partial\mathcal{N}_{n+1}$}. \\ \text{Update auxiliary parameter $\lambda_{n+1}^{m+1}=\lambda_{n+1}^{m} + \rho^{(m) \mathcal{Q}_{\lambda_{n+1}}_{n+1}|\lambda_{n+1}=\lambda_{n+1}^{(m)}$}. \\ \text{Calculate $\mathcal{L}(q,\lambda_{n+1}^{m}$}. \\ \text{Set $m=m+1$}. \\ \text{end} \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{ } \\ \text{                                                                                                                                                                                                        
\text{We also infer the DPM model via MFVB using the so-called'stick-breaking' representation of t} \\ \text{Dirichlet Process. as in Wang et al. (2011). This approach estimates the fully factorised posterie}$$

We also infer the DPM model via MFVB using the so-called 'stick-breaking' representation of the Dirichlet Process, as in Wang et al. (2011). This approach estimates the fully factorised posterior approximation, given by

$$q _ { \lambda } ( \theta _ { 1 \colon N } ^ { * }, k _ { 1 \colon N } | y _ { 1 \colon N, 1 \colon T _ { n } } ) = \prod _ { j = 1 } ^ { N } q ( \theta _ { j } ^ { * } | y _ { 1 \colon N, 1 \colon T _ { n } } ) q ( k _ { j } | y _ { 1 \colon N, 1 \colon T _ { n } } ).$$

This may be used to build a predictive distribution in the same manner as (61). Details of the MFVB approximation are provided in Appendix C.

To illustrate the benefits of including posterior dependence in the approximation, we also introduce a parametric and independent model, which retains a normal likelihood for each vehicle, i.e.

$$y _ { i, t } \sim \mathcal { N } ( \mu _ { i }, \sigma _ { i } ^ { 2 } )$$

and assumes for each vehicle an independent uninformative prior, given by

$$p ( \mu _ { i }, \sigma _ { i } ^ { 2 } ) \in \sigma _ { i } ^ { - 2 }.$$

For this model the predictive distribution for vehicle i is analytically available as

$$p ( y _ { i, T _ { n } + h } | \boldsymbol y _ { i, 1 \colon T _ { n } } ) = \frac { \Gamma \left ( \frac { \nu + 1 } { 2 } \right ) } { \Gamma \left ( \frac { \nu } { 2 } \right ) \sqrt { \frac { \pi \nu ( T _ { n } + 1 ) s _ { i, n } ^ { 2 } } { T _ { n } } } } \left ( 1 + \frac { T _ { n } \left ( y _ { i, T _ { n } + h } - \bar { y } _ { i, n } \right ) ^ { 2 } } { \nu ( T _ { n } + 1 ) s _ { i, n } ^ { 2 } } \right ) ^ { \frac { - ( \nu + 1 ) } { 2 } }$$

a location-scale transform of the usual Studentt distribution with ν = T n -1 degrees of freedom, where ¯ y i,n and s 2 i,n denote the sample mean and variance of y i, 1: T n , respectively. Note that this model ignores any information from all other vehicles, and is similarly evaluated by the corresponding cumulative predictive log score.

## 7.5 Analysis of the NGSIM Data

We now discuss the empirical application results from the UVB algorithm for the DPM model described above for the NGSIM data. The posterior updates for both the cluster locations, θ ∗ 1: N , and the indicator variables, k 1: N , occur at a sequence of pre-determined time periods, given by T 1 = 50 , T 2 = 75 , T 3 = 100 , T 4 = 125 , T 5 = 150, and T 6 = 175.

Consider first the two graphs shown in the top panel (panel (a)) of Figure 6. In each graph, the approximate marginal posterior distributions for each unique value µ ∗ j (on the left) and σ 2 , ∗ j (on the right). Noting there are N = 500 marginal densities for each of µ ∗ and σ 2 , ∗ , the plotted densities for each parameter are weighted according to the proportion of vehicles in a sample of M = 100 draws of ( θ ∗ 1: N , k 1: N ) obtained from the UVB approximation. That is, the weights are calculated according to

$$w _ { j } = \sum _ { m = 1 } ^ { M } \sum _ { i = 1 } ^ { N } \frac { I ( k _ { i } ^ { ( m ) } = j ) } { M N },$$

so that w j represents the proportion of the MN many sampled k i values, denoted by k ( m ) i for i = 1 2 , , ..., N and m = 1 2 , , ..., M , that correspond to the given value of j . The weights suggest that only six of the θ ∗ j values account for the majority of the vehicles, with the six weighted densities associated with µ ∗ k and σ ∗ k most prominent in the figures shown in panel (a). In contrast, the sample of θ ∗ j values that are seldom (if ever) allocated to a vehicle and hence receive little or no weight appear in these figures as flat lines indistinguishable from zero.

Now turning to panel (b) of Figure 6, a predictive distribution for new values of y is estimated for each cluster location j , using the M previously simulated values θ ∗ 1: N . The mean of each predictive distribution is plotted against the corresponding predictive standard deviation, with the size of each point given by w j . The fifty pairs of means and standard deviations shown correspond to 80% of all simulated k i values, with the results showing that the majority of vehicles belong to a relatively small number of large and cohesive groups, each associated with a distinct predictive mean value coupled with low predictive standard deviation. Members of these groups appear to stay in the same region of their lane, but with these regions spread across both sides of the centre line. There are also many smaller groups, having predictive means closer to zero but with larger standard deviations, perhaps describing idiosyncratic vehicle positioning in the region of the centre lane.

The bottom panel plots, in grey, the individual predictive densities associated with fifty randomly selected vehicles, with the average predictive density over all N = 500 vehicles in the sample shown in dark blue. Note that the predictive distribution associated with an individual vehicle will typically itself be comprised of a mixture of components. Importantly, many of the individual predictive densities display reduced uncertainty, relative to the overall average.

Using data up to each time period T n , we predict the future position y i,T n + h , h = 1 2 , , . . . , 50 for each vehicle using four different predictive distributions described in Section 7.4:

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-7fe989e0-1f9d-41cd-aa81-9d9d7216eb22.jpg)

6

(a) Weighted

θ

∗

marginal posterior approximation, based on UVB, at time

T

.

(b) UVB Predictive moments for high probability groups, at time T 6 .

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-1c8b9e0c-4a56-4466-b69e-e134911ce864.jpg)

(c) Individual vehicle and average predictive densities from UVB at time T 6 .

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-f07b88e2-d311-4cbd-a0e0-8215c4027d89.jpg)

Figure 6: (a): Posterior approximation for each θ ∗ , weighted by proportion of k 1: N draws. Two groups have high posterior precision with numerous groups showing more uncertainty. (b): Posterior predictive distribution means and standard deviations, sized according to the top 80% of k 1: N draws. (c): Averaged predictive distribution for all groups in dark blue, with a random subset of fifty per vehicle distributions in grey.

- 1. The DPM predictive distribution (61), with approximate inference provided via UVB.
- 2. The DPM predictive distribution (61), with approximate inference provided via MFVB,
- 3. The DPM predictive distribution (61), with approximate inference provided via SVB,
- 4. The independent model predictive distribution (66), with exact inference.

The mean cumulative predictive log scores (MCLS), averaged across each of the N = 500 vehicles, and associated with each of the four types of predictive distributions for individual cars enumerated above, are plotted in Figure 7.

The results show that, while in each case both approximate implementations of the DPM model outperform the analytically exact independent model, the posterior dependency in the SVB and UVB approximations greatly improves forecasts relative to MFVB. The UVB and SVB lines coincide, and there is no evidence of accumlating approximation error through the UVB recursion relative to the single model fit of SVB. As the amount of data increases, the MFVB and independent model log scores similarly increase. In contrast, the UVB inference MCLS stays at the same level: the N × ( T 6 -T 1 ) = 62 500 additional observations included in , T 6 has not provided much marginal information to improve forecasts relative to the original T 1 fit with N × T 1 = 25 000 ob-, servations. By construction the DPM shares information between vehicles, so forecasts of vehicle i are accurate even with only T 1 = 50 observations of that particular vehicle. When MFVB inference is employed forecasts are only slightly stronger than the fully independent model that does not share information, implying that the MFVB implementation did not successfully include behaviour of other vehicles.

Figure 7: Mean cumulative predictive log scores (MCLS) for each model averaged across N = 500 vehicles. Each model is fit using data up to T n , then forecasts are made for each of the following fifty observations. The SVB and UVB implementations are nearly identical, while the MFVB implementation performs only slightly better than the fully independent model.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-ad570dbf-e69a-4e1d-b868-b2df0a9b7db6.jpg)

## 8 Conclusions

This paper proposes a framework to extend the use of SVB inference to a sequential posterior updating setting. UVB is a variational analogue to exact Bayesian updating, where the previous posterior distribution, taken as the prior for the update, is replaced with an approximation itself derived from an earlier SVB approximation. This allows a sequence of posterior distributions to be available in an online data setting, before observation of the complete dataset. Repeated updates may incur a large computational overhead from multiple stochastic optimisation algorithms, and so UVB-IS is proposed as an extension to UVB, as it significantly reduces the computational load of updates by using draws from previous posterior approximations, as well as their associated loglikelihoods, in an importance sampler.

We demonstrate the application of UVB and UVB-IS in two simulation settings, namely for time series forecasting and clustering, as well as in the empirical 'Eight Schools' example involving a hierarchical model. In each case the approximation error introduced by UVB and UVB-IS is assessed relative to both exact inference, and a standard implementation of SVB, where all past observations are used in a single optimisation. We find that, despite UVB introducing additional approximations, there are mixed results in terms of accuracy and computational speed between UVB and SVB, with SVB having less error and being faster in scenarios where the log-likelihood component of the gradient estimation is small. However, in the clustering model, where the loglikelihood computation dominates the gradient estimation, UVB outperforms SVB in terms of both accuracy and speed. In each case UVB-IS introduces a small amount of additional error relative to UVB, but nevertheless still achieves large computational gains. In addition, the variance of the gradient estimator in UVB and UVB-IS is shown to be orders of magnitude less than that of SVB, which may partially offset the approximation error in the prior used by the updating methods.

The proposed UVB and UVB-IS algorithms are highly suited to large time-series data streams where up-to-date inference is required at all times to inform decisions, including those based on forecasts and where data arrives so rapidly as to render MCMC infeasible. To illustrate this type of situation, an empirical illustration regarding observed lane positions of vehicles on the US-101 Highway is presented using a Dirichlet Process Mixture. In this implementation of UVB, an approximating distributional family that exploits dependence between cluster locations and indicator variables is detailed. Forecasts of future lane positions produced using UVB are comparable to an SVB approach. Posterior dependence is induced by exploiting the known full conditional distribution for the discrete indicator variables by using these as a component of the approximating distribution. Infering the model through UVB and SVB outperform inference using MFVB, as this method requires an independent posterior approximation. Future research involves the application of UVB to build a more sophisticated heterogeneous model to provide forecasts of vehicle movement from this dataset in an online fashion - where UVB facilitates model updates and forecasts in a short time-frame after data arrives.

## References

Aldous, D. J. (1985). Exchangeability and related topics. In Ecole d'Ete de Probabilities de Saint-Flour XIII 1983.

| Attias, H. (1999). A variational Bayesian framework for graphical models. In Advances in Neural Information Processing Systems 12.                                                                                        |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Bhattacharya, A. and S. P. Wilson (2018). Sequential Bayesian inference for static parameters in dynamic state space models. Computational Statistics and Data Analysis 127, 187 - 203.                                   |
| Bishop, C. M. (2006). Pattern Recognition and Machine Learning. Springer.                                                                                                                                                 |
| Blei, D. M., A. Kucukelbir, and J. D. McAuliffe (2017). Variational inference: A review for statisticians. Journal of the American Statistical Association 112(518), 859-877.                                             |
| Bottou, L. (2010). Large-scale machine learning with stochastic gradient descent. In Proceedings of COMPSTAT'2010.                                                                                                        |
| Broderick, T., N. Boyd, A. Wibisono, A. C. Wilson, and M. I. Jordan (2013). Streaming variational Bayes. In Advances in Neural Information Processing Systems 26.                                                         |
| Chen, X., H. Dai, and L. Song (2019). Meta particle flow for sequential Bayesian inference. arXiv:1902.00640 [cs.LG].                                                                                                     |
| Chopin, N. (2002). A sequential particle filter method for static models. Biometrika 89, 539-551.                                                                                                                         |
| Del Moral, P., A. Jasra, A. Lee, C. Yau, and X. Zhang (2015). The alive particle filter and its use in particle markov chain monte carlo. Stochastic Analysis and Applications 33(6), 943-974.                            |
| Dißmann, J., E. C. Brechmann, C. Czado, and D. Kurowicka (2013). Selecting and estimating regular vine copulae and application to financial returns. Computional Statistics and Data Analysis 59, 52-69.                  |
| Doucet, A., N. de Freitas, and N. Gordon (2001). Sequential Monte Carlo Methods in Practice. Springer-Verlag.                                                                                                             |
| Doucet, A. and A. Lee (2018). Sequential Monte Carlo methods, Chapter 7, pp. 165-189. Chapman and Hall.                                                                                                                   |
| FHWA (2017). Next Generation Simulation (NGSIM) Vehicle Trajectories and Supporting Data. Available online at https://data.transportation.gov/Automobiles/ Next-Generation-Simulation-NGSIM-Vehicle-Trajector/8ect-6jqj . |
| Garthwaite, P. H., Y. Fan, and S. A. Sisson (2016). Adaptive optimal scaling of Metropolis- Hastings algorithms using the Robbins-Monro process. Communications in Statistics - Theory and Methods 45(17), 5098-5111.     |
| Gelman, A., J. B. Carlin, H. S. Stern, D. B. Dunson, A. Vehtari, and D. B. Rubin (2014). Bayesian Data Analysis (3 ed.). CRC Press.                                                                                       |
| Gelman, A., W. R. Gilks, and G. O. Roberts (1997). Weak convergence and optimal scaling of random walk Metropolis algorithms. Annals of Applied Probability 7, 110-120.                                                   |
| Ghahramani, Z. and M. J. Beal (2000). Propagation algorithms for variational Bayesian learning. In Advances in Neural Information Processing Systems 13.                                                                  |
| Gilks, W. R., N. G. Best, and K. K. C. Tan (1995). Adaptive rejection Metropolis sampling within Gibbs sampling. Journal of the Royal Statistical Society. Series C (Applied Statistics) 44(4), 445-472.                  |

| Gilks, W. R., S. Richardson, and D. Spiegelhalter (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall.                                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Hoffman, M., F. R. Bach, and D. M. Blei (2010). Online learning for latent Dirichlet allocation. In Advances in Neural Information Processing Systems 23.                                      |
| Hoffman, M., D. M. Blei, C. Wang, and J. Paisley (2013). Stochastic variational inference. Journal of Machine Learning Research 14, 1303-1347.                                                 |
| Jasra, A., S. S. Singh, and J. S. Martin (2010). Filtering via approximate Bayesian computation. Statistics and Computing 22, 1223-1237.                                                       |
| Jordan, M. I., Z. Ghahramani, T. S. Jaakola, and L. K. Saul (1999). An introduction to variational methods for graphical models. Machine Learning 37, 183-233.                                 |
| Kabisa, S. T., D. B. Dunson, and J. S. Morris (2016). Online variational Bayes inference for high- dimensional correlated data. Journal of Computational and Graphical Statistics 25, 426-444. |
| Kingma, D. P. and J. L. Ba (2014). arXiv:1412.6980v9 [cs.LG].                                                                                                                                  |
| Kingma, D. P. and M. Welling (2014). Auto-encoding variational Bayes. arXiv:1312.6114 [stat.ML].                                                                                               |
| Kullback, S. and R. A. Leibler (1951). On information and sufficiency. The Annals of Mathematical Statistics 22(1), 79-86.                                                                     |
| Llera, A. and C. F. Beckmann (2016). Estimating an inverse gamma distribution. arXiv:1605.01019 [stat.ME].                                                                                     |
| Miller, J. W. (2018). An elementary derivation of the chinese restaurant process from Sethuraman's stick-breaking process. arXiv:1801.00513 [math.ST].                                         |
| M¨ller, u P., F. A. Quintana, A. Jara, and T. Hanson (2015). Bayesian Nonparametric Data Analysis. Springer.                                                                                   |
| R Core Team (2017). R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. Available online at https://www.R-project.org/ .         |
| Ranganath, R., S. Gerrish, and M. Blei, David (2014). Black box variational inference. In Proceedings of the Seventeenth International Conference on Artificial Intelligence and Statistics.   |
| Robbins, H. and S. Monro (1951). Astochastic approximation method. The Annals of Mathematical Statistics 22(3), 400-407.                                                                       |
| Sakaya, J. and A. Klami (2017). Importance sampled stochastic optimization for variational infer- ence. In Uncertainty in Artificial Intelligence.                                             |
| Sato, M. (2001). Online model selection based on variational Bayes. Neural Computation 13, 1649-1681.                                                                                          |
| Sethuraman, J. (1994). A constructive definition of Dirichlet priors. Statistica Sinica 4, 639-650.                                                                                            |
| Smidl, V. (2004). The Variational Bayes Approach in Signal Processing. Ph. D. thesis, Trinity College, The University of Dublin.                                                               |

Stan Development Team (2018). RStan Getting Started. Available online at https://github. com/stan-dev/rstan/wiki/RStan-Getting-Started .

Titsias, M. K. and M. L´zaro-Gredilla (2014). Doubly stochastic variational Bayes for non-conjugate a inference. In Proceedings of the 31st International Conference on International Conference on Machine Learning - Volume 32.

Wainwright, M. J. and M. I. Jordan (2008). Graphical models, exponential families, and variational inference. Foundations and Trends in Machine Learning 1(1-2), 1-305.

Wang, C., J. Paisley, and D. Blei (2011). Online variational inference for the hierarchical Dirichlet process. In Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics.

Zhang, C., J. B¨tepage, H. Kjellstr¨m, and S. Mandt (2017). u o Advances in variational inference. arXiv:1711.05597 [cs.LG].

## A Calculation of Lateral Lane Deviation

Let x i,t denote the position of vehicle i along the direction of travel at time t , and y i,t denote the position across the lane, as in Figure 8 for one vehicle travelling to the right.

Figure 8: Coordinate system for one vehicle. The X -axis denotes distance travelled along the lane, and the Y -axis denotes the relative vertical position in the lane.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-1e0d2db8-2390-44f9-9370-6691cd6cc382.jpg)

For each vehicle i and time t since entering the road, with travel originating at t = 1, the total distance travelled up to time t is given by

$$d _ { i, t } = \sum _ { s = 2 } ^ { t } \sqrt { ( x _ { i, s } - x _ { i, s - 1 } ) ^ { 2 } + ( y _ { i, s } - y _ { i, s - 1 } ) ^ { 2 } }.$$

Using this distance measure and 100 randomly sampled vehicles per lane, the two-dimensional coordinates corresponding to the centre line of each lane are estimated via independent smoothing splines, where each coordinate is a function of the distance travelled to that point. Each smoothing spline is calculated using the 'R stats' package (R Core Team, 2017). The estimated centre line for lane k , is denoted by the curve { ̂ x d,k = f k x ( d , y ) ̂ d,k = f k y ( d ) } , for d ≥ 0. The fitted spline models are shown in red overlaying the raw data in Figure 9

Figure 9: The fitted spline models for each lane in red overlaid on the raw data in black.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00225v1-figure-11fa2cb8-9e26-4195-b128-55fed2f34871.jpg)

Excluding the vehicles used to estimate the spline models, each of the vehicles in the dataset uses the relevant lane centre line estimate fit from the spline model associated with its starting lane to calculate relative coordinates { x ∗ i,t , y ∗ i,t } . x ∗ i,t denotes the distance travelled along the road, and y ∗ i,t denotes the deviation from the lane centre line, and are calculated by

$$\widehat { d } _ { i, t } = \arg \min _ { d } \sqrt { ( x _ { i, t } - f _ { x } ^ { k } ( d ) ) ^ { 2 } + ( y _ { i, t } - f _ { y } ^ { k } ( d ) ) ^ { 2 } }$$

$$\widehat { x } _ { i, t } = f _ { x } ^ { k } ( \widehat { d } _ { i, t } ) \\ \dots \widehat { \ }$$

$$\widehat { y } _ { i, t } & = f _ { y } ^ { k } ( \widehat { d } _ { i, t } ) & &.$$

$$y _ { i, t } ^ { * } = \sin \left ( \tan \left ( \frac { \widehat { x } _ { i, t } - x _ { i, t } } { \widehat { y } _ { i, t } - y _ { i, t } } \right ) ^ { - 1 } - \tan \left ( \frac { f _ { x } ^ { \prime, k } ( \widehat { d } _ { i, t } ) } { f _ { y } ^ { \prime, k } ( \widehat { d } _ { i, t } ) } \right ) ^ { - 1 } \right ) \sqrt { ( x _ { i, t } - \widehat { x } _ { i, t } ) ^ { 2 } + ( y _ { i, t } - \widehat { y } _ { i, t } ) ^ { 2 } } \quad \quad ( 7 2 )$$

The coordinate pair ( ̂ x i,t , y ̂ i,t ) denotes the closest position of the spline model to the actual vehicle position given by the pair ( x i,t , y i,t ). Lateral deviation y ∗ i,t has magnitude equal to that of the vector from ( ̂ x i,t , y ̂ i,t ) to ( x i,t , y i,t ). A negative sign on y ∗ i,t indicates that the vehicle is to the left of the lane centre, and a positive sign indicates that the vehicle is to the right of the lane centre.

## B Equivalence of augmented and marginal KL Divergence gradients

Consider the augmented posterior distribution

$$p ( \theta, k | y ) \in p ( y | \theta, k ) p ( k | \theta ) p ( \theta )$$

and variational approximation given by

$$q _ { \lambda } ( \theta, k | y ) = q _ { \lambda } ( \theta | y ) p ( k | y, \theta ).$$

The corresponding KL divergence, KL q [ λ ( θ, k y | ) || p θ, k y ( | )], is indirectly minimised using the gradient

$$\frac { \partial K L [ q _ { \lambda } ( \theta, k | y ) \, | | \ p ( \theta, k | y ) ] } { \partial \lambda } = - \frac { \partial \mathcal { L } ( q, \lambda ) } { \partial \lambda }, \quad \ \.$$

where the gradient ∂ L ( q, λ ) /∂λ is the score-based gradient of the ELBO, given by

$$\frac { \partial \mathcal { L } ( q, \lambda ) } { \partial \lambda } = \int _ { \theta, k } q _ { \lambda } ( \theta, k | y ) \frac { \partial \log ( q _ { \lambda } ( \theta, k | y ) ) } { \partial \lambda } \left ( \log ( p ( y, \theta, k ) ) - \log ( q _ { \lambda } ( \theta, k | y ) ) \, d \theta d k.$$

Next, consider the associated marginal posterior distribution,

$$p ( \theta | y ) \in p ( y | \theta ) p ( \theta ),$$

and consider using as the variational approximation ˜ q λ ( θ y | ) given by the first component (only) on the right hand side of (74), i.e. ˜ q λ ( θ y | ) ≡ q λ ( θ y | ). Note that, as a consequence, log q λ ≡ log ˜ q λ and ∂ log q λ ∂λ ≡ ∂ log ˜ q λ ∂λ . The KL divergence in this case, KL q [ ˜ λ ( θ y | ) || p θ y ( | )], has gradient given by

$$\frac { \partial K L [ \widetilde { q } _ { \lambda } ( \theta | y ) \, | | \, p ( \theta | y ) ] } { \partial \lambda } = - \frac { \partial \mathcal { L } ( \widetilde { q }, \lambda ) } { \partial \lambda },$$

where ∂ L ( ˜ q, λ ) /∂λ is

$$\frac { \partial \mathcal { L } ( \widetilde { q }, \lambda ) } { \partial \lambda } = \int _ { \theta } \widetilde { q } _ { \lambda } ( \theta | y ) \frac { \partial \log ( \widetilde { q } _ { \lambda } ( \theta | y ) ) } { \partial \lambda } \left ( \log ( p ( y, \theta ) ) - \log ( \widetilde { q } _ { \lambda } ( \theta | y ) ) \right ) d \theta.$$

Here we show that (76) is equal to (79), and hence the gradient of both KL divergences are equal, and must share local minima.

Begin by expanding each joint density in (76) by (73) and (74),

$$\text{gem} \, \L y \, \text{expanding each jump weusely } \Pi \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \Lv \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L v \, \L } \, \partial \, \mathcal { L } ( q, \lambda ) & = \int _ { \theta, k } q _ { \lambda } ( \theta | y ) p ( k | \theta, y ) \, \frac { \partial ( \log ( q _ { \lambda } ( \theta | y ) ) + \log ( p ( k | \theta, y ) ) } { \partial \lambda } } \\ & \times ( \log ( p ( \theta ) p ( y | k, \theta ) p ( k | \theta ) ) - \log ( q _ { \lambda } ( \theta | y ) p ( k | \theta, y ) ) \, d \theta d k & = \int _ { \theta, k } q _ { \lambda } ( \theta | y ) p ( k | \theta, y ) \, \frac { \partial \log ( q _ { \lambda } ( \theta | y ) ) } { \partial \lambda } } \\ & \times \left ( \log ( p ( \theta ) + \log \left ( \frac { p ( y | k, \theta ) p ( k | \theta ) ) p ( y | \theta ) } { p ( y | \theta ) } \right ) - \log ( q _ { \lambda } ( \theta | y ) ) - \log ( p ( k | \theta, y ) ) \right ) d \theta d k & = \int _ { \theta, k } \, \text{for} \, \L v \, \text{in} \, \text{for} \, \L v \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \text{in} \, \end{array}$$

as the term log( p k θ, y ( | )) is independent of λ . Then

$$\frac { \partial \mathcal { L } ( q, \lambda ) } { \partial \lambda } & = \int _ { \theta, k } q _ { \lambda } ( \theta | y ) p ( k | \theta, y ) \frac { \partial \log ( q _ { \lambda } ( \theta | y ) ) } { \partial \lambda } \\ & \times ( \log ( p ( \theta ) + \log ( p ( y | \theta ) ) + \log ( p ( k | y, \theta ) ) - \log ( q _ { \lambda } ( \theta | y ) ) - \log ( p ( k | \theta, y ) ) ) \, d \theta d k$$

by Bayes' Rule. Cancelling log( p k y, θ ( | )) results in

$$\frac { \partial \mathcal { L } ( q, \lambda ) } { \partial \lambda } & = \int _ { \theta, k } q _ { \lambda } ( \theta | y ) p ( k | \theta, y ) \frac { \partial \log ( q _ { \lambda } ( \theta | y ) ) } { \partial \lambda } \left ( \log ( p ( \theta ) + \log ( p ( y | \theta ) ) - \log ( q _ { \lambda } ( \theta | y ) ) \right ) d \theta d k } \\ & = \int _ { \theta } \left ( \int _ { k } p ( k | \theta, y ) d k \right ) \ q _ { \lambda } ( \theta | y ) \frac { \partial \log ( q _ { \lambda } ( \theta | y ) ) } { \partial \lambda } \left ( \log ( p ( y, \theta ) - \log ( q _ { \lambda } ( \theta | y ) ) \right ) d \theta.$$

The final expression (84) is equivalent to the marginal model gradient (79) and the proof is complete.

## C Mean Field Variational Bayes implementation of the Dirichlet Process Mixture

Implementation of MFVB for this model follows the offline coordinate ascent approach of Wang et al. (2011), employing the stick-breaking construction of the Dirichlet Process as

$$\theta _ { j } ^ { * } \stackrel { i i d } { \sim } G _ { 0 },$$

$$\beta _ { j } ^ { \prime } \stackrel { i i d } { \sim } B e t a ( 1, \alpha ),$$

$$\beta _ { N } ^ { \prime } = 1,$$

$$\beta _ { j } = \beta _ { j } ^ { \prime } \prod _ { l = 1 } ^ { j - 1 } ( 1 - \beta _ { l } ^ { \prime } ),$$

$$G = \sum _ { j = 1 } ^ { N } \beta _ { j } \delta ( \theta _ { j } ^ { * } ),$$

where δ is the Dirac Delta function. The stick-breaking construction is equivalent to the CRP representation of the DP, after marginalisation over β (Miller, 2018), and is similarly augmented with the set of indicator variables k 1: N . In this case the prior distribution is given by

$$k _ { i } \sim M u l t i n o m i a l ( \beta _ { 1 \colon N } ).$$

The contribution to the likelihood from observation i is then determined by

$$y _ { i, 1 \colon T _ { 1 } } | \theta _ { 1 \colon N } ^ { * }, k _ { i } \sim \mathcal { N } \left ( \mu _ { k _ { i } } ^ { * }, \sigma _ { k _ { i } } ^ { 2 * } \right ).$$

To maintain the analytical tractablility of the MFVB approximation, we replace the base distribution G 0 with a conjugate prior for the normal likelihood,

$$\mu ^ { * } | G _ { 0 } \sim \mathcal { N } ( 0, 1 0 )$$

$$\sigma ^ { 2 * } | G _ { 0 } \sim I n v e r s e G a m m a ( s h a p e = \alpha _ { 0 }, s c a l e = \kappa _ { 0 } )$$

where α 0 and κ 0 are chosen to be the MLE values for the inverse gamma distribution, estimated from 100,000 samples of the implied lognormal(0 10) distribution for , σ 2 ∗ that was used in the SVB and UVB approaches. These values are estimated by the second algorithm of Llera and Beckmann (2016) as

$$\alpha _ { 0 } = 0. 1 5 2 7 5$$

$$\kappa _ { 0 } = 0. 0 0 1 0 2.$$

The variational approximation employed is of the form

$$q _ { \lambda _ { n } } ( k _ { 1 \colon N }, \beta _ { 1 \colon N } ^ { \prime }, \theta _ { 1 \colon N } ^ { * } ) = \prod _ { i = 1 } ^ { N } q ( k _ { i } ) q ( \beta _ { i } ^ { \prime } ) q ( \mu _ { i } ^ { * } ) q ( \sigma _ { i } ^ { 2 * } )$$

with

$$k _ { i } \sim M u l t i n o m ( \rho _ { i } )$$

$$\beta _ { i } ^ { \prime } \sim B e t a ( a _ { i }, b _ { i } )$$

$$\mu _ { i } ^ { * } \sim \mathcal { N } ( \gamma _ { i }, \tau _ { i } )$$

$$\sigma _ { i } ^ { 2 * } \sim I n v. G a m m a ( \alpha _ { i }, \kappa _ { i } )$$

Coordinate ascent algorithms for MFVB consists of cycling through in a set of equations for each parameter until the change in each parameter is below some threshold. For this model the equations are given by

$$a _ { j } = 1 + \sum _ { \substack { i = 1 \\ \cdot \cdot \cdot \cdot \cdot } } ^ { N } \rho _ { i j },$$

$$b _ { j } = \alpha + \sum _ { i = 1 } ^ { N } \sum _ { l = j + 1 } ^ { N } \rho _ { i l },$$

$$\rho _ { i j } \in - \frac { T _ { n } } { 2 } E _ { q } [ \log ( \sigma _ { j } ^ { 2 * } ) ] - \frac { \alpha _ { j } } { 2 \kappa _ { j } } \left ( \sum _ { t = 1 } ^ { T _ { n } } y _ { i t } ^ { 2 } - 2 \gamma _ { j } \sum _ { t = 1 } ^ { T _ { n } } y _ { i t } + T _ { n } ( \gamma _ { j } ^ { 2 } + \tau _ { j } ) \right ) + E _ { q } [ \log ( \beta _ { j } ) ],$$

$$\gamma _ { j } = \frac { 1 0 \frac { \alpha _ { i } } { \kappa _ { j } } \sum _ { i = 1 } ^ { N } \sum _ { t = 1 } ^ { T _ { n } } \rho _ { i j } y _ { i t } } { 1 0 T _ { n } \frac { \alpha _ { j } } { \kappa _ { j } } \sum _ { i = 1 } ^ { N } \rho _ { i j } + 1 }, \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdclots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \cdots \quad \colon$$

$$\tau _ { j } = \frac { \lambda _ { 1 0 } ^ { 1 } } { 1 0 T _ { n } \frac { \alpha _ { j } } { \kappa _ { j } } \sum _ { i = 1 } ^ { N } \rho _ { i j } + 1 },$$

$$\alpha _ { j } = \alpha _ { 0 } + \frac { T _ { n } } { 2 } \sum _ { i = 1 } ^ { \cdot } \rho _ { i j }, \quad \sum _ { \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \cdot \colon$$

$$\kappa _ { j } = \kappa _ { 0 } + \frac { 1 } { 2 } \left ( \sum _ { i = 1 } ^ { N } \rho _ { i j } \left ( \sum _ { t = 1 } ^ { T _ { n } } y _ { i t } ^ { 2 } + T _ { n } ( \gamma _ { j } ^ { 2 } + \tau _ { j } ) - 2 \gamma _ { j } \sum _ { t = 1 } ^ { T _ { n } } y _ { i t } \right ) \right ).$$

The expectations E q [log( β j )] are available in closed form as

$$E _ { q } [ \log ( \beta _ { j } ) ] = E _ { q } [ \log ( \beta _ { j } ^ { \prime } ) ] + \sum _ { l = 1 } ^ { j - 1 } E _ { q } [ \log ( 1 - \beta _ { j } ^ { \prime } ) ]$$

where and

$$E _ { q } [ \log ( 1 - \beta _ { j } ^ { \prime } ) ] = \Psi ( b _ { j } ) - \Psi ( a _ { j } + b _ { j } ) & & ( 1 1 0 )$$

where Ψ is the digamma function. The expectation E q [log( σ 2 ∗ j )] does not have a closed form solution but is estimated from samples of q σ ( 2 ∗ j ).

$$E _ { q } [ \log ( \beta _ { j } ^ { \prime } ) ] = \Psi ( a _ { j } ) - \Psi ( a _ { j } + b _ { j } )$$
Nathaniel Tomasetti Catherine S. Forbes Anastasios Panagiotelis
Updating Variational Bayes: Fast sequential posterior inference
Variational Bayesian (VB) methods produce posterior inference in a time frame
considerably smaller than traditional Markov Chain Monte Carlo approaches.
Although the VB posterior is an approximation, it has been shown to produce
good parameter estimates and predicted values when a rich classes of
approximating distributions are considered. In this paper we propose Updating
VB (UVB), a recursive algorithm used to update a sequence of VB posterior
approximations in an online setting, with the computation of each posterior
update requiring only the data observed since the previous update. An extension
to the proposed algorithm, named UVB-IS, allows the user to trade accuracy for
a substantial increase in computational speed through the use of importance
sampling. The two methods and their properties are detailed in two separate
simulation studies. Two empirical illustrations of the proposed UVB methods are
provided, including one where a Dirichlet Process Mixture model with a novel
posterior dependence structure is repeatedly updated in the context of
predicting the future behaviour of vehicles on a stretch of the US Highway 101.