ngme2: A Computational Framework for Non-Gaussian Mixed Effects
Overview
ngme2 is an R package for fitting a broad class of linear mixed effects models encompassing time series analysis, spatial statistics, and many other statistical frameworks. The key innovation is that the latent components, including random effects, measurement errors, and underlying stochastic processes, can follow non-Gaussian distributions, extending the popular latent Gaussian modeling framework. The package incorporates flexible noise structures, including the normal-inverse Gaussian distribution, into the latent structure. It supports a diverse range of latent components including autoregressive (AR) models, conditional autoregressive (CAR) models, random walks, and stochastic partial differential equation (SPDE) Matérn fields, which can be combined in versatile ways and made non-Gaussian independently of the specific modeling approach.
By integrating these components in a unified and modular framework, ngme2 enables applications across diverse fields, including longitudinal studies, spatial epidemiology, environmental monitoring, and econometrics. Inference is based on maximum likelihood estimation, with efficient algorithms for likelihood evaluation and prediction, making the package computationally practical even for complex models. This flexibility makes ngme2 a powerful tool for analyzing data with heavy tails, abrupt changes, or other complex features that are not well captured by standard Gaussian assumptions.
At the core of the package lies an extension of the SPDE approach to non-Gaussian settings. In the traditional formulation, Gaussian random fields are represented as solutions to a stochastic partial differential equation driven by Gaussian white noise. The ngme2 framework generalizes this construction by replacing the Gaussian white noise with type-G Lévy noises, allowing the creation of random fields and mixed effects models with flexible marginal distributions while still preserving essential computational advantages.
The theoretical foundations of ngme2 are drawn from a series of research papers establishing non-Gaussian extensions of SPDE methods. The foundational work by Bolin (2014, Scandinavian Journal of Statistics) introduced spatial Matérn fields driven by non-Gaussian noise, demonstrating how type-G Lévy noises can replace Gaussian white noise in SPDE formulations. This was extended by Wallin and Bolin (2015, Scandinavian Journal of Statistics) to geostatistical modeling with non-Gaussian Matérn fields, and further developed by Asar, Bolin, Diggle, and Wallin (2020, Journal of the Royal Statistical Society) for longitudinal mixed effects models with non-Gaussian components. The ngme2 package builds upon these contributions as an ongoing research effort, with active development by several contributors including David Bolin, Xiaotian Jin, Alexandre B. Simas and Jonas Wallin, who are also involved in recent related work on computational methods for non-Gaussian models.
A particularly important contribution concerns the computational implementation using preconditioned stochastic gradient descent (PSGD) optimization. Traditional maximum likelihood estimation for non-Gaussian mixed effects models typically requires expensive MCMC sampling or approximate methods with limited theoretical guarantees. The PSGD approach implemented in ngme2 uses unbiased gradient estimates with subsampling and variance reduction techniques, enabling scalable maximum likelihood estimation for complex models with thousands of measurements while maintaining computational efficiency comparable to Gaussian methods.
These developments are fully integrated into the ngme2 package. Users can specify mixed effects models with flexible distributional assumptions for any combination of random effects, time-varying processes, and measurement errors. The package provides efficient implementations of maximum likelihood estimation, prediction, and simulation for non-Gaussian mixed effects models. In cases where analytical solutions exist, the package exploits exact computational methods, while for complex models, it employs the PSGD optimization framework to achieve scalable inference even for large longitudinal datasets.
The ngme2 developers provide extensive educational resources to facilitate user adoption, including detailed vignettes on different latent models, comprehensive installation and configuration guides, and practical tutorials covering various distribution families. These materials are freely accessible through the package documentation articles, which bridge theoretical understanding with practical implementation. They include mathematical background, computational considerations, and reproducible case studies using publicly available datasets.
ngme2 is available on GitHub for access to the latest development versions. The stable version can be installed using install.packages(“ngme2”, repos = “https://davidbolin.github.io/ngme2/”)
while the development version is accessible via remotes::install_github(“davidbolin/ngme2”, ref = “devel”)
. The package supersedes the original ngme package, providing enhanced functionality, improved computational efficiency, and broader distributional support.
By extending SPDE approaches beyond Gaussian assumptions while maintaining computational scalability through advanced optimization methods, ngme2 opens new possibilities for rigorous, efficient, and reproducible statistical modeling of complex longitudinal and spatial phenomena. Its integration of type-G Lévy noises, sparse matrix computation, and maximum likelihood estimation establishes it as a state-of-the-art framework for non-Gaussian mixed effects modeling in modern data analysis.