physalia-forecasting-course
Ecological forecasting using Dynamic Generalized Additive Models with R 📦's {mvgam} and {brms}
https://github.com/nicholasjclark/physalia-forecasting-course
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
â—‹CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
â—‹DOI references
-
â—‹Academic publication links
-
â—‹Committers with academic emails
-
â—‹Institutional organization owner
-
â—‹JOSS paper metadata
-
â—‹Scientific vocabulary similarity
Low similarity (6.3%) to scientific vocabulary
Keywords
Repository
Ecological forecasting using Dynamic Generalized Additive Models with R 📦's {mvgam} and {brms}
Basic Info
- Host: GitHub
- Owner: nicholasjclark
- Language: HTML
- Default Branch: main
- Homepage: https://nicholasjclark.github.io/physalia-forecasting-course/
- Size: 400 MB
Statistics
- Stars: 41
- Watchers: 2
- Forks: 12
- Open Issues: 2
- Releases: 0
Topics
Metadata Files
README.html
README Ecological forecasting with
mvgamandbrms
Physalia-Courses
Nicholas J Clark
2428th March, 2025
COURSE OVERVIEW
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. 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 mostRusers. 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 commentedRscripts) will be provided electronically to participants.TARGET AUDIENCE AND ASSUMED BACKGROUND
This course is aimed at higher degree research students and early career researchers working with time series data in the natural sciences (with particular emphasis on ecology) who want to extend their knowledge by learning how to add dynamic processes to model temporal autocorrelation. Participants should ideally have some knowledge of regression including linear models, generalized linear models and hierarchical (random) effects. But well briefly recap these as we connect them to time series modelling.
Participants should be familiar with RStudio and have some fluency in programming
Rcode. This includes an ability to import, manipulate (e.g.modify variables) and visualise data. There will be a mix of lectures and hands-on practical exercises throughout the course.LEARNING OUTCOMES
- Understand how dynamic GLMs and GAMs work to capture both nonlinear covariate effects and temporal dependence
- Be able to fit dynamic GLMs and GAMs in R using the
{mvgam}and{brms}packages- Understand how to critique, visualize and compare fitted dynamic models
- Know how to produce forecasts from dynamic models and evaluate their accuracies using probabilistic scoring rules
COURSE PREPARATION
Please be sure to have at least version 4.2 and preferably version 4.3 or above of
Rinstalled. Note thatRandRStudioare two different things: it is not sufficient to just updateRStudio, you also need to updateRby installing new versions as they are released.To install
RStudio, go to https://posit.co/download/rstudio-desktop/ and follow the instructions.To download
Rgo to the CRAN Download page and follow the links to downloadRfor your operating system:To check what version of
Ryou have installed, you can runversionin
Rand look at theversion.stringentry (or themajorandminorentries).We will make use of several
Rpackages that youll need to have installed. Prior to the start of the course, please run the following code to update your installed packages and then install the required packages:# update any installed R packages update.packages(ask = FALSE, checkBuilt = TRUE) # install the development version of brms, including its dependencies install.packages("remotes") remotes::install_github("paul-buerkner/brms", dependencies = TRUE) # install mvgam and a few other packages we will use for plotting install.packages(c("mvgam", "gratia", "tidybayes"))INSTALLING AND CHECKING STAN
When working in
R, there are two primary interfaces we can use to fit models withStan({rstan}andCmdStan). It is highly recommended that you use theCmdstanbackend, with the{cmdstanr}interface, rather than using{rstan}. But either interface will work. What is more important is that you have an up to date version ofStan. For all{mvgam}and{brms}functionalities to work properly, please ensure you have at least version 2.33 ofStaninstalled. The CRAN and GitHub development versions of{rstan}andCmdStanare currently several versions ahead of this, and all of these versions are stable.Compiling a Stan program requires a modern C++ compiler and the GNU Make build utility (a.k.a. gmake). The correct versions of these tools to use will vary by operating system, but unfortunately most standard Windows and MacOS X machines do not come with them installed by default. The first step to installing
Stanis to update your C++ toolchain so that you can compile models correctly. The{cmdstanr}package usually makes this easy to do. First install theRpackage{cmdstanr}by running the following command in a freshRenvironment:install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))If you dont have
CmdStaninstalled then{cmdstanr}can install it for you, assuming you have a suitable C++ toolchain. To double check that your toolchain is set up properly you can call thecheck_cmdstan_toolchain()function:library(cmdstanr) check_cmdstan_toolchain(fix = TRUE)This may give you a message that you need to update
rtoolsto match your current version ofR, so please follow the instructions in the printed error message if that is the case. Once the toolchain is set up properly,{cmdstanr}will require a working installation ofCmdStan, the shell interface toStan.CmdStancan be installed by calling theinstall_cmdstan()function:install_cmdstan(cores = 2)The exact version you have installed can be checked using
cmdstanr::cmdstan_version(). You should now be able to follow the remaining instructions on the Getting Started with{cmdstanr}page to ensure thatStanmodels can successfully compile on your machine. However a quicker way to check this would be to run this script:library(mvgam) simdat <- sim_mvgam() mod <- mvgam( y ~ s(season, bs = 'cc', k = 5) + s(time, series, bs = 'fs', k = 8), data = simdat$data_train )But issues can sometimes occur when: 1. you dont have write access to the folders that
CmdStanuses to create model executables 2. you are using a university- or company-imposed syncing system such as One Drive, leading to confusion about where your make file and compilers are located 3. you are using a university- or company-imposed firewall that is aggressively deleting the temporary executable files thatCmdStancreates when compilingIf you run into any of these issues, it is best to consult with your IT department for support. There are detailed instructions by the Stan team on how to ensure you have the correct C++ toolchain to compile models, so please refer to those when consulting your IT department.
PROGRAM
09:00 - 12:00 (Berlin time): live coding exercises and review of the lecture materials
3 additional hours: self-guided readings and viewing of lecture recordings
Monday (day 1)
Lecture 1 (html | pdf)
Lecture 2 (html | pdf)
Live code examples (Random effects)
Tutorial 1 (html) * Introduction to time series and time series visualization * Some traditional time series models and their assumptions * GLMs and GAMs for ecological modelling * Temporal random effects and temporal residual correlation structuresTuesday (day 2)
Lecture 3 (html | pdf)
Live code examples (Interactions | Time-varying effects)
Tutorial 2 (html) * Dynamic GLMs and Dynamic GAMs * Autoregressive dynamic processes * Gaussian Processes * Dynamic coefficient modelsWednesday (day 3)
Lecture 4 (html | pdf)
Live code example (Distributed lags
Tutorial 3 (html) * Bayesian posterior predictive checks * Forecasting from dynamic models * Point-based forecast evaluation * Probabilistic forecast evaluationThursday (day 4)
Lecture 5 (html | pdf)
Live code examples (Functionals | Time-varying seasonality)
Tutorial 4 (html) * Multivariate ecological time series * Vector autoregressive processes * Dynamic factor models * Multivariate forecast evaluationFriday (day 5)
- Group-based practical examples / case studies
- Review, feedback and open discussion
Owner
- Name: Nicholas Clark
- Login: nicholasjclark
- Kind: user
- Location: Brisbane, Queensland, Australia
- Website: https://researchers.uq.edu.au/researcher/15140
- Twitter: nj_clark
- Repositories: 2
- Profile: https://github.com/nicholasjclark
ARC DECRA Fellow at University of Queensland (Australia). Interested in multivariate statistics and forecasting, with applications in community ecology
GitHub Events
Total
- Issues event: 4
- Watch event: 9
- Delete event: 1
- Push event: 75
- Pull request event: 4
- Fork event: 1
- Create event: 1
Last Year
- Issues event: 4
- Watch event: 9
- Delete event: 1
- Push event: 75
- Pull request event: 4
- Fork event: 1
- Create event: 1
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Nicholas Clark | n****4@g****m | 214 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 4
- Total pull requests: 2
- Average time to close issues: 6 months
- Average time to close pull requests: less than a minute
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 3
- Pull requests: 2
- Average time to close issues: about 1 month
- Average time to close pull requests: less than a minute
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- nicholasjclark (4)
Pull Request Authors
- nicholasjclark (4)