Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjclark authored Nov 26, 2024
1 parent 3e38f43 commit e8ab716
Show file tree
Hide file tree
Showing 82 changed files with 22,598 additions and 0 deletions.
892 changes: 892 additions & 0 deletions ESA_slidedeck.Rmd

Large diffs are not rendered by default.

901 changes: 901 additions & 0 deletions ESA_slidedeck.html

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions ESA_slidedeck_files/figure-html/ar_sim-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions ESA_slidedeck_files/figure-html/ar_simneg-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 152 additions & 0 deletions ESA_slidedeck_files/figure-html/basis-functions-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
146 changes: 146 additions & 0 deletions ESA_slidedeck_files/figure-html/basis-functions-weights-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,131 changes: 5,131 additions & 0 deletions ESA_slidedeck_files/figure-html/complexity-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
158 changes: 158 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-1-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 152 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-10-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
354 changes: 354 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-11-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-12-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-13-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-14-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
196 changes: 196 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-15-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-16-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-17-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-18-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
277 changes: 277 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-19-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-2-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
276 changes: 276 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-20-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
288 changes: 288 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-21-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
317 changes: 317 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-22-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
375 changes: 375 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-23-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
244 changes: 244 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-24-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
257 changes: 257 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-25-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
297 changes: 297 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-26-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
389 changes: 389 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-27-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-28-1.svg

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-29-1.svg

Large diffs are not rendered by default.

188 changes: 188 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-3-1.svg

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-30-1.svg

Large diffs are not rendered by default.

196 changes: 196 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-31-1.svg

Large diffs are not rendered by default.

192 changes: 192 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-32-1.svg

Large diffs are not rendered by default.

224 changes: 224 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-4-1.svg

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-5-1.svg

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-6-1.svg

Large diffs are not rendered by default.

213 changes: 213 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-7-1.svg

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-8-1.svg

Large diffs are not rendered by default.

354 changes: 354 additions & 0 deletions ESA_slidedeck_files/figure-html/unnamed-chunk-9-1.svg

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all: slides purl

slides: index.Rmd slides.css
Rscript -e 'library("rmarkdown"); render("index.Rmd")'

purl: index.Rmd
Rscript -e "knitr::purl(\"index.Rmd\")"

111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Ecological Time Series Analysis and Forecasting in R

### Ecological Society of Australia 2024 Conference

https://esa2024.org.au/

### Nicholas J Clark

#### 13th December, 2024

## COURSE OVERVIEW
Time series analysis and forecasting are standard goals in applied ecology. In this course, you will learn how to wrangle, visualise and explore ecological time series. You will also learn to use the {`mvgam`} package to analyse a diversity of ecological time series to gain useful insights and produce accurate forecasts.

This workshop will cover:

- Introduction to time series and time series visualization
- Generalised LInear Models (GLMs) and hierarchical models (GLMMs)
- Generalized Additive Modela (GAMs) for nonlinear effects and complex random effects
- Dynamic GLMs and Dynamic GAMs
- Multivariate modeling strategies
- Forecasting and forecast evaluation

## TARGET AUDIENCE AND ASSUMED BACKGROUND
This workshop is aimed at higher degree and early career ecologists who are interested in making better predictions with their statistical models. The strategies to be covered are extendable well beyond time series and participants will leave this workshop with a better understanding of strategies to capture the types of complex, nonlinear effects that dominate ecological data.

## LEARNING OUTCOMES
1. Understand how dynamic GLMs and GAMs work to capture both nonlinear covariate effects and temporal dependence
2. Be able to fit dynamic GLMs and GAMs in R using the {`mvgam`} package
3. Understand how to critique, visualize and compare fitted dynamic models
4. 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 `R` installed**. Note that `R` and `RStudio` are two different things: it is not sufficient to just update `RStudio`, you also need to update `R` by installing new versions as they are released.

To download `R` go to the [CRAN Download](https://cran.r-project.org/) page and follow the links to download `R` for your operating system:

* [Windows](https://cran.r-project.org/bin/windows/)
* [MacOS X](https://cran.r-project.org/bin/macosx/)
* [Linux](https://cran.r-project.org/bin/linux/)

To check what version of `R` you have installed, you can run

```r
version
```

in `R` and look at the `version.string` entry (or the `major` and `minor` entries).

We will make use of several `R` packages that you'll 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:

```r
# update any installed R packages
update.packages(ask = FALSE, checkBuilt = TRUE)

# packages to install for the course
pkgs <- c("tidyverse", "gratia", "ggplot2",
"marginaleffects", "mvgam")

# install packages
install.packages(pkgs)
```

### INSTALLING AND CHECKING STAN
When working in R, there are two primary interfaces we can use to fit models with Stan (`rstan` and `CmdStan`). Either interface will work, however it is highly recommended that you use the `Cmdstan` backend, with the `{cmdstanr}` interface, rather than using `{rstan}`. More care, however, needs to be taken to ensure you have an up to date version of Stan. **For all `mvgam` functionalities to work properly, please ensure you have at least version 2.29 of Stan installed**. The GitHub development versions of `rstan` and `CmdStan` are currently several versions ahead of this, and both of these development versions are stable. The exact version you have installed can be checked using either `rstan::stan_version()` or `cmdstanr::cmdstan_version()`

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 Stan is to update your C++ toolchain so that you can compile models correctly. [There are detailed instructions by the Stan team on how to ensure you have the correct C++ toolchain to compile models](https://mc-stan.org/docs/cmdstan-guide/installation.html#cpp-toolchain), so please refer to those and follow the steps that are relevant to your own machine. Once you have the correct C++ toolchain, you'll need to install `Cmdstan` and the relevant `R` package interface. First install the `R` package by running the following command in a fresh `R` environment:

```r
install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
```

`{cmdstanr}` requires a working installation of [CmdStan](https://mc-stan.org/users/interfaces/cmdstan.html), the shell interface to Stan. If you don't have CmdStan installed 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
the `check_cmdstan_toolchain()` function:

```r
check_cmdstan_toolchain()
```

If your toolchain is configured correctly then CmdStan can be installed by calling the
[`install_cmdstan()`](https://mc-stan.org/cmdstanr/reference/install_cmdstan.html) function:

```r
install_cmdstan(cores = 2)
```

You should now be able to follow the remaining instructions on the [Getting Started with CmdStanR page](https://mc-stan.org/cmdstanr/articles/cmdstanr.html) to ensure that Stan models can successfully compile on your machine. A quick way to check this would be to run this script:

```r
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 don't have write access to the folders that CmdStan uses to create model executables](https://discourse.mc-stan.org/t/problem-running-cmdstan-on-computing-cluster/34747/5)
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](https://discourse.mc-stan.org/t/system-command-make-failed-models-wont-compile/30528)
3. [you are using a university- or company-imposed firewall that is aggressively deleting the temporary executable files that CmdStan creates when compiling](https://discourse.mc-stan.org/t/trouble-with-cmdstan-toolchain-with-rtools42-on-windows-10-enterprise/28444)

If you run into any of these issues, it is best to consult with your IT department for support.

## WORKSHOP MATERIALS
[Live questions and code sharing](ESA_timeseries_2024)
[Lecture slides](https://nicholasjclark.github.io/physalia-forecasting-course/day1/lecture_1_slidedeck)
<br>
[Live code example 1](https://raw.githubusercontent.com/nicholasjclark/physalia-forecasting-course/main/day1/live_code_examples/live_1_randomeffects.R)
<br>
[Live code example 1](https://raw.githubusercontent.com/nicholasjclark/physalia-forecasting-course/main/day1/live_code_examples/live_1_randomeffects.R)
Loading

0 comments on commit e8ab716

Please sign in to comment.