The Neural Moving Average Model for Scalable Variational Inference of State Space Models

Tom Ryder, Dennis Prangle, Andrew Golightly, Isaac Matthews · DOI

Abstract

Variational inference has had great success in scaling approximate Bayesian inference to big data by exploiting mini-batch training. To date, however, this strategy has been most applicable to models of independent data. We propose an extension to state space models of time series data based on a novel generative model for latent temporal states: the neural moving average model. This permits a subsequence to be sampled without drawing from the entire distribution, enabling training iterations to use mini-batches of the time series at low computational cost. We illustrate our method on autoregressive, Lotka-Volterra, FitzHugh-Nagumo and stochastic volatility models, achieving accurate parameter estimation in a short time.

Introduction

State Space Models (SSMs) are fundamental tools for analyzing sequential data across disciplines like neuroscience, finance, and ecology. However, performing Bayesian inference—estimating hidden states and governing parameters—remains a significant computational challenge. Traditional methods such as Markov Chain Monte Carlo (MCMC) or standard Variational Inference (VI) typically require a full pass over the entire dataset ($O(T)$ cost) for every iteration. For modern datasets where $T$ exceeds $10^6$, this linear scaling becomes a prohibitive bottleneck. Unlike independent data, time series cannot be easily mini-batched because each state depends on its predecessors.

The Neural Moving Average (nMA) Model

The Neural Moving Average (nMA) model addresses this bottleneck by breaking the sequential dependency of latent states. The core innovation is the Locality Property. Instead of an autoregressive structure where $x_i$ depends on $x_{i-1}$, the nMA uses a Convolutional Neural Network (CNN) to transform a sequence of independent noise variables ($z$) into latent states ($x$).

Because the CNN has a limited receptive field, any state $x_i$ only depends on a local window of noise variables. This allows the model to sample short subsequences from anywhere in a million-step chain at a constant $O(1)$ cost per iteration. The nMA is implemented as a specialized Inverse Autoregressive Flow (IAF), where affine transformation parameters are calculated by the CNN using local observations ($y$) and model parameters ($\theta$) as side information.

Scalability and Accuracy

The model's performance was rigorously tested on benchmarks ranging from linear AR(1) models to complex non-linear systems. A key finding is that the number of iterations required for convergence remains constant even as the sequence length $T$ increases from 5,000 to 100,000. This demonstrates true scalability for long-range time series.

Convergence and parameter estimation performance of the nMA model across varying sequence lengths (T) and receptive field sizes (l).

In the Lotka-Volterra predator-prey model, the nMA achieved parameter estimates virtually indistinguishable from near-exact MCMC samples in approximately 10 minutes. The model effectively trades long-range dependencies—which are often negligible in the posterior for many SSMs—for the ability to perform rapid, parallelizable mini-batch updates.

Handling Complex Dynamics

The nMA model excels in high-dimensional and partially observed regimes. In the FitzHugh-Nagumo model, which simulates neuronal excitability, the model was applied to a massive sequence of $T=1,000,000$ observations. Despite the scale, the nMA successfully recovered the path of the completely unobserved component ($w$) in roughly 180 minutes, a task that would be computationally infeasible for standard MCMC approaches.

Recovery of the unobserved component w in the FitzHugh-Nagumo model with T=1,000,000 observations.

Finally, the model demonstrated real-world utility on U.S. Treasury bill rate data, producing results consistent with established literature in just 20 minutes on a single GPU.

Conclusion

The Neural Moving Average model provides a scalable framework for variational inference in SSMs. By leveraging CNNs to enforce temporal locality, it enables $O(1)$ mini-batching without sacrificing the accuracy of parameter estimation. While the limited receptive field may be a constraint for systems with extremely long-range memory, the nMA offers a powerful solution for the majority of modern, large-scale sequential data challenges.

Summary updated

BibTeX
@misc{ryder2019neural,
  author = {Tom Ryder and Dennis Prangle and Andrew Golightly and Isaac Matthews},
  title = {{The Neural Moving Average Model for Scalable Variational Inference of State Space Models}},
  year = {2019},
  eprint = {1910.00879},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.00879},
}
Figure