This paper introduces kDGLM, an R package designed for Bayesian analysis of Generalized Dynamic Linear Models (GDLM), with a primary focus on both uni- and multivariate exponential families. Emphasizing sequential inference for time series data, the kDGLM package provides comprehensive support for fitting, smoothing, monitoring, and feed-forward interventions. The methodology employed by kDGLM, as proposed in Alves et al. (2024), seamlessly integrates with well-established techniques from the literature, particularly those used in (Gaussian) Dynamic Models. These include discount strategies, autoregressive components, transfer functions, and more. Leveraging key properties of the Kalman filter and smoothing, kDGLM exhibits remarkable computational efficiency, enabling virtually instantaneous fitting times that scale linearly with the length of the time series. This characteristic makes it an exceptionally powerful tool for the analysis of extended time series. For example, when modeling monthly hospital admissions in Brazil due to gastroenteritis from 2010 to 2022, the fitting process took a mere 0.11s. Even in a spatial-time variant of the model (27 outcomes, 110 latent states, and 156 months, yielding 17,160 parameters), the fitting time was only 4.24s. Currently, the kDGLM package supports a range of distributions, including univariate Normal (unknown mean and observational variance), bivariate Normal (unknown means, observational variances, and correlation), Poisson, Gamma (known shape and unknown mean), and Multinomial (known number of trials and unknown event probabilities). Additionally, kDGLM allows the joint modeling of multiple time series, provided each series follows one of the supported distributions. Ongoing efforts aim to continuously expand the supported distributions.
翻译:本文介绍kDGLM,这是一个专为广义动态线性模型(GDLM)贝叶斯分析设计的R包,主要聚焦于单变量和多元指数族分布。该包强调时间序列数据的序贯推断,为拟合、平滑、监测和前馈干预提供全面支持。kDGLM采用的方法(如Alves等人2024年所述)与文献中成熟技术无缝集成,尤其适用于(高斯)动态模型,包括折扣策略、自回归分量、传递函数等。通过利用卡尔曼滤波和平滑的关键性质,kDGLM展现出卓越的计算效率,实现近乎瞬时的拟合时间,且计算复杂度随时间序列长度线性增长。这一特性使其成为分析长序列的极强有力工具。例如,在建模2010年至2022年巴西因胃肠炎导致的月度住院数据时,拟合过程仅需0.11秒。即使是在时空变体模型(27个结果变量、110个潜在状态、156个月,共17,160个参数)中,拟合时间也仅为4.24秒。目前,kDGLM包支持多种分布,包括单变量正态(未知均值和观测方差)、双变量正态(未知均值、观测方差和相关性)、泊松、伽马(已知形状参数、未知均值)以及多项(已知试验次数、未知事件概率)。此外,只要各时间序列服从上述支持分布之一,kDGLM还允许对多个时间序列进行联合建模。后续工作将持续扩展支持的分布类型。