Linear Latent Non-Gaussian Models with Flexible Distributions

Fits and analyzes linear latent non-Gaussian models for temporal, spatial, and space-time data. The package provides model components for autoregressive and Ornstein-Uhlenbeck processes, random walks, Matern fields based on stochastic partial differential equations, separable and non-separable space-time models, graph-based Matern models, bivariate type-G fields, and user-defined sparse operators. Latent fields and observation models can use Gaussian and non-Gaussian noise distributions, including normal inverse Gaussian, generalized asymmetric Laplace, and skew-t distributions. Functions are included for simulation, likelihood-based estimation, prediction, cross-validation, convergence diagnostics, stochastic gradient optimization, batch-means confidence intervals, and posterior-like sampling. The modeling framework is described in Bolin, Jin, Simas and Wallin (2026) "A Unified and Computationally Efficient Non-Gaussian Statistical Modeling Framework" .


The ngme2 Package

CRAN status CRAN downloads per month

Description

ngme2 (https://davidbolin.github.io/ngme2/) is a unified, efficient, and flexible framework for fitting latent non-Gaussian models in R. It extends the SPDE-based Gaussian modeling toolkit to handle skewness, heavy tails, and non-smooth behavior while keeping familiar workflows for estimation, prediction, and model assessment.

Features

  • Temporal processes: AR(1), Ornstein–Uhlenbeck, random walks, and ARMA models.
  • Spatial processes: Matérn fields (including graph-based meshes) and separable/non-separable space–time variants.
  • Non-Gaussian driven noise: NIG, generalized asymmetric Laplace, skew-(t); non-Gaussian measurement noise is also supported.
  • Joint and custom structures: bivariate type-G fields, longitudinal random-effects models, and user-defined operators via generic / generic_ns, flexible combinations of different models and driven noise.
  • Practical tools: kriging-style prediction, cross-validation helpers, and diagnostics for convergence/fit quality.

Quick start

library(ngme2)
time_index <- seq(1, 1000, by = 1)
n <- length(time_index)

# Define the AR(1) model with NIG driven noise
ar1_nig <- f(time_index,
  model = ar1(rho = 0.7),
  noise = noise_nig(mu = 3, sigma = 2, nu = 0.5)
)

# Simulate the AR(1) process with NIG driven noise
nig_field <- simulate(ar1_nig, seed = 123, nsim = 1)[[1]]
Y <- nig_field + rnorm(n, mean = 0, sd = 1)
plot(time_index, nig_field, type = "l")

# Fit the model
fit <- ngme(
  formula = Y ~ 0 + f(time_index, model = ar1(), noise = noise_nig()),
  data    = data.frame(Y = Y, time_index = time_index),
  family  = "normal" # likelihood family
)

summary(fit)

Use ngme_optimizers() to see available optimizers and configure stochastic gradient settings via control_opt.

Installation

The stable version can be installed with:

install.packages("ngme2", repos = "https://davidbolin.github.io/ngme2/")

See the Installation and Configuration vignette if compilation tools are needed.

Learn more

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ngme2")

1.0.1 by Xiaotian Jin, 3 hours ago


https://davidbolin.github.io/ngme2/, https://github.com/davidbolin/ngme2


Report a bug at https://github.com/davidbolin/ngme2/issues


Browse source code at https://github.com/cran/ngme2


Authors: David Bolin [aut, cph] , Xiaotian Jin [aut, cre] , Alexandre Simas [aut] , Jonas Wallin [aut] , Andrea V. Rocha [ctb] (contributed to many vignettes and examples) , Timothy A. Davis [ctb, cph] (SuiteSparse components) , Patrick R. Amestoy [ctb, cph] (SuiteSparse AMD and CAMD components) , Iain S. Duff [ctb, cph] (SuiteSparse AMD and CAMD components) , John K. Reid [ctb, cph] (SuiteSparse AMD-derived code) , Yanqing Chen [ctb, cph] (SuiteSparse CAMD components) , Sivasankaran Rajamanickam [ctb, cph] (SuiteSparse CCOLAMD components) , Stefan Larimore [ctb, cph] (SuiteSparse CCOLAMD and COLAMD components) , William W. Hager [ctb, cph] (SuiteSparse CHOLMOD Modify components) , University of Florida [cph] (SuiteSparse CHOLMOD and CCOLAMD components) , Regents of the University of Minnesota [cph] (METIS/GKlib components bundled with SuiteSparse) , Free Software Foundation , Inc. [cph] (GKlib regex/getopt code bundled with SuiteSparse) , Makoto Matsumoto [ctb, cph] (Mersenne Twister code bundled with SuiteSparse) , Takuji Nishimura [ctb, cph] (Mersenne Twister code bundled with SuiteSparse) , Alexander Chemeris [ctb, cph] (MS integer headers bundled with SuiteSparse)


Documentation:   PDF Manual  


GPL (>= 3) license


Imports Matrix, Rcpp, methods, rlang, ggplot2, graphics, fmesher, stats, gridExtra, withr

Suggests knitr, rmarkdown, INLA, RcppEigen, sf, inlabru, dplyr, plyr, MASS, grid, testthat, xml2, splancs, lattice, viridis, rSPDE, tidyr, fields, lme4, plotly, usethis, devtools, MetricGraph, zoo, mvtnorm, kableExtra, reshape2

Linking to Matrix, Rcpp, RcppEigen

System requirements: GNU make


See at CRAN