Time Series Analysis (TSA) Module for the ECDC EPIET & EUPHEM Program

Welcome

Welcome to the Time Series Analysis (TSA) module webpage of the ECDC EPIET & EUPHEM Program.

Here you will find the Practical Sessions 3-7, 9 and 10 of the TSA module 2025, including the instructions, guide and solution of the proposed exercises. Sessions 8 and 11 will be provided as stand-alone exercises

How to prepare for the module

Install R, Rtools and Rstudio

Participants need to have R, RTools, and RStudio installed in their computer. Preferably, the installation of these applications should be done in the stated order: R >> RTools >> RStudio. If you don’t have these applications installed yet, please do so following the instructions below:

  • R should be installed in the participants’ computer. You can download it from here, on the section “Download and Install R”. Select the adequate version to your computer’s operating system.

    • Latest version available is 4.5.2 (31st Oct 2025). You don’t need the latest version installed. However, it’s highly recommended to stay updated on at least the ‘major version’ (4.x.x) and not too many ‘minor versions’ (x.5.x) away, as packages tend to update to each of them. A warning message might show when using p_load if your R version is older than a package’s last update; however, it will work fine.

    • Multiple versions of R can be installed in one’s computer. R usually can be installed without administrative rights. If you have more than one R version installed on your computer, please make sure that you select the specific version 4.2.3. when running RStudio (Top Menu: Settings > Global Options > Left Panel > R)

  • RTools at the same R version you are using should also be installed in the participants’ computer. You can download the necessary files by clicking here and selecting the corresponding operating system in your computer.

    • For MacOS, RTools installation comprises the minimal installation of clang and gfortran as listed in the hyperlinked website. Please note that preferably only one version of RTools version 4.2 or below should be installed in one’s computer. RTools version 4.3 can be installed simultaneously with RTools version 4.2. or below in one’s computer.
  • RStudio can be used with previous versions without creating conflict with packages or R versions safely. Try to keep updated if possible.

Libraries

The following R packages have to be installed. Open RStudio, copy the highlighted code below into the R Console pane and press enter. This process might take several minutes.

Show the code
# Install pacman if not installed already, and activate it
if (!require("pacman")) install.packages("pacman")

# Install, update and activate libraries
pacman::p_load(
  here, 
  rio, 
  skimr,
  tsibble,
  ISOweek,
  slider,
  pander,
  season,
  lmtest,
  TSA,
  ciTools,
  gtsummary,
  patchwork,
  AER,
  MASS,
  sjPlot,
  tidyverse
)


## packages to be installed for outbreak detection / loaded by pacman
pacman::p_load(devtools)
devtools::install_github("United4Surveillance/signal-detection-tool")


## packages to be installed for multilevel / loaded by pacman
pacman::p_load(devtools)
devtools::install_github("goodekat/redres")

Frequent problems you may encounter during the SignalDetectionTool installation:

  • Please start a new R session before the installation by going in Rstudio to Session 

    • Solution: RStudio menu bar > Session > New Session
  • In case you get an error message that some package with version x.x.x. is already loaded in the namespace, but a higher version is requested, you should try:

    • Make a new R session

    • If 1) did not work, then manually install_packages(package_with_problem).

    • Install the SignalDetectionTool again

In case you have troubles accessing Github check below

Installation Instructions for the SignalDetectionTool in case of problems with GitHub access

  1. Save the file signal-detection-tool-0.8.0.tar.gz on your computer

  2. Open RStudio and run install.packages("remotes")

  3. Install all dependencies for the SignalDetectionTool by running and filling in your path to the stored .tar.gz with the command remotes::install_deps("your_path_to_signal-detection-tool-0.8.0.tar.gz"

  4. Install the SignalDetectionTool by running install.packages("your_path_to_signal-detection-tool-0.8.0.tar.gz", repos = NULL, type = "source")

Data

To download all neccessary datasets and files for this practicals, click in this link and then save the zip file in the data folder of your project