Mvgam

Ecological forecasting with R 📦’s {mvgam} and {brms}

Time series analysis and forecasting are standard goals in applied ecology. But most time series courses focus only on traditional forecasting models such as ARIMA or Exponential Smoothing. These models cannot handle features that dominate ecological data, including overdispersion, clustering, missingness, discreteness and nonlinear effects. Using the flexible and powerful Bayesian modelling software Stan, we can now meet this complexity head on. R packages such as {mvgam} and {brms} can build Stan code to specify ecologically appropriate models that include nonlinear effects, random effects and dynamic processes, all with simple interfaces that are familiar to most R users. In this course you will learn how to wrangle, visualize and explore ecological time series. You will also learn to use the {mvgam} and {brms} packages to analyse a diversity of ecological time series to gain useful insights and produce accurate forecasts. All course materials (presentations, practical exercises, data files, and commented R scripts) will be provided electronically to participants.

State-Space Vector Autoregressions in mvgam

Vector Autoregressions (VAR models), also known as Multivariate Autoregressions (MAR models), offer a way to model delayed and contemporaneous interactions among sets of multiple time series. These models are widely used in econometrics and psychology, among other fields, where they can be analyzed to ask many interesting questions about potential causality or stability. But software to fit these models to real-world time series, which often present as non-Gaussian counts, proportions or even binary observations with measurement error, is lacking. Here I show how to fit VARs in a State-Space format, and how to interrogate the models to ask meaningful questions about interactions and stability, using the mvgam package in R.

Incorporating time-varying seasonality in forecast models

Many time series show repeated seasonal patterns, and fitting models that can capture this seasonality is a major focus of time series forecasting algorithms. There are a lot of useful, established methods to deal with this (i.e. SARIMA, Harmonic regression), but sometimes the seasonal patterns change over time. Fewer time series and forecasting models can handle this feature. This post introduces some strategies for capturing time-varying seasonality and time-varying periodicity in Dynamic Generalized Additive Models, using the mvgam package in R.

Ecological forecasting with R 📦’s {mvgam} and {brms}

Time series analysis and forecasting are standard goals in applied ecology. But most time series courses focus only on traditional forecasting models such as ARIMA or Exponential Smoothing. These models cannot handle features that dominate ecological data, including overdispersion, clustering, missingness, discreteness and nonlinear effects. Using the flexible and powerful Bayesian modelling software Stan, we can now meet this complexity head on. R packages such as {mvgam} and {brms} can build Stan code to specify ecologically appropriate models that include nonlinear effects, random effects and dynamic processes, all with simple interfaces that are familiar to most R users. In this course you will learn how to wrangle, visualize and explore ecological time series. You will also learn to use the {mvgam} and {brms} packages to analyse a diversity of ecological time series to gain useful insights and produce accurate forecasts. All course materials (presentations, practical exercises, data files, and commented R scripts) will be provided electronically to participants.

First release of mvgam(v1.1.0) to CRAN

The mvgam package has been officially released to CRAN. This package fits Bayesian Dynamic Generalized Additive Models to sets of time series. Users can build dynamic nonlinear State-Space models that can incorporate semiparametric effects in observation and process components, using a wide range of observation families. Estimation is performed using Markov Chain Monte Carlo with Hamiltonian Monte Carlo in the software Stan.

Time series modeling with Bayesian Dynamic Generalized Additive Models

In this talk I introduce Bayesian Dynamic Generalized Additive Models (DGAMs) and illustrate their advantages for analyzing and forecasting real-world time series. I discuss mvgam, an open-source R package that can fit DGAMs with nonlinear effects, hierarchical effects and dynamic processes to data from a wide variety of observation distributions. These models are especially useful for analysing multiple series, as they can estimate hierarchical smooth functions while learning complex temporal associations with latent vector autoregressive processes or dimension-reduced dynamic factor processes. Because the package uses Hamiltonian Monte Carlo inference through Stan, it is straightforward to create Stan code and all necessary data structures so that additional stochastic elements can be added to suit the user’s bespoke needs. Other key features of {mvgam} are functions to critique models using rolling window forecasts and posterior predictive checks, online data augmentation via a recursive particle filter and graphical tools to visualise probabilistic uncertainties for smooth functions and predictions. I hope show how models that describe real-world complexity, both through nonlinear covariate functions and multi-series dependence, are useful to ask targeted questions about drivers of change.

Ecological forecasting with dynamic GAMs

Time series analysis and forecasting are standard goals in applied ecology. But ecological forecasting is difficult because ecology is complex. The abundances of species, for example, fluctuate for many reasons. Food and shelter availability limit survival. Biotic interactions affect colonization and vital rates. Severe weather events and climate variation alter habitat suitability. These sources of variation make it difficult to understand, let alone predict, ecosystem change. Moreover, most available time series software cannot handle features that dominate ecological data, including overdispersion, clustering, missingness, discreteness and nonlinear effects. In this talk, I will introduce Dynamic Generalized Additive Models (DGAMs) as one solution to meet this complexity. I illustrate a number of models that can be tackled with the mvgam R package, which builds Stan code to specify probabilistic Bayesian models that include nonlinear smooth functions, random effects and dynamic processes, all with a simple interface that is familiar to most R users.

Ecological forecasting with dynamic Generalized Additive Models (DGAMs)

Time series analysis and forecasting are standard goals in applied ecology. But ecological forecasting is difficult because ecology is complex. The abundances of species, for example, fluctuate for many reasons. Food and shelter availability limit survival. Biotic interactions affect colonization and vital rates. Severe weather events and climate variation alter habitat suitability. These sources of variation make it difficult to understand, let alone predict, ecosystem change. Moreover, most available time series software cannot handle features that dominate ecological data, including overdispersion, clustering, missingness, discreteness and nonlinear effects. In this talk, I will introduce Dynamic Generalized Additive Models (DGAMs) as one solution to meet this complexity. I illustrate a number of models that can be tackled with the mvgam R package, which builds Stan code to specify probabilistic Bayesian models that include nonlinear smooth functions, random effects and dynamic processes, all with a simple interface that is familiar to most R users.

Temporal autocorrelation in GAMs and the mvgam package

Temporal autocorrelation is a dominant feature of time series. We often want to use Generalized Additive Models (GAMs) to fit smoothing splines to time series data, but incorporating autocorrelation in these models can be difficult. Enter the mvgam package

Ascertainment and near-term forecasting of tick paralysis admissions

Tick paralysis is a leading cause of emergency veterinary admissions for Australian companion animals, often resulting in death if left untreated. Availability of timely information on periods of increased risk can help modulate behaviours that reduce exposures to ticks and improve awareness of owners for the need of preventative ectoparasite treatment. However, detection of trends in risk is hampered by the lack of clearly annotated historical records of tick paralysis. Natural Language Processing (NLP) of clinical records is required to first ascertain historical cases. Here we describe a platform to perform NLP on VetCompass Australia’s veterinary clinical records to accurately identify historical cases of canine tick paralysis where we make use of combine bespoke spellchecking and tokenization routines with a domain-expertise inspired clinical dictionary to identify important terms in free text indicative of a tick paralysis diagnosis. Resulting time series of tick paralysis cases are then analysed using Dynamic Generalised Additive Models to jointly estimate nonlinear distributed lag effects of environmental predictors and dynamic latent temporal processes that facilitate probabilistic near-term forecasts of tick paralysis risk. Our models forecast tick paralysis cases with exceptional accuracy while preserving epidemiological interpretability. We have designed an interactive online dashboard to showcase our data and modelling results so that we can refine the way we present probabilistic predictions to meet end-user requirements. We expect our data acquisition / modelling pipeline to act as a platform for developing early warning systems that can notify clinicians and pet owners about heightened risks of environmentally driven veterinary conditions.