Each session in this course uses R code for demonstration. All the content is self-contained within a software package designed for the course. To get the most out of this course, you will need to use R and the following instructions to interact with the course material.

Getting R

  • R is used as the main programming language. Please install at least version: R-4.2.0.
  • RStudio is a popular graphic user interface (GUI). Its Visual Editor provides the best experience of going through this course. Please make sure you update RStudio to the latest version.

Installing additional requirements

Before you get started with the course, you will first need to install the following software.

Installation of the nfidd package

To install the packages needed in the course, including the nfidd package that contains data files and helper functions used throughout, you can use the pak package:

install.packages("pak")
pak::pak("nfidd/nfidd", dependencies = "all", upgrade = TRUE)

Then you can check that the installation completed successfully by loading the package into your R session:

library("nfidd")

Installing cmdstan

The course relies on running stan through the cmdstanr R package, which itself uses the cmdstan software. This requires a separate installation step:

cmdstanr::install_cmdstan()
Note

This may take a few minutes. Also you’re likely to see lots of warnings and other messages printed to your screen - don’t worry, this is normal and doesn’t mean there is a problem.

If there are any problems with this, you can try (on Windows) to fix them using

cmdstanr::check_cmdstan_toolchain(fix = TRUE)

You can test that you have a working cmdstanr setup using

cmdstanr::cmdstan_version()
[1] "2.35.0"

For more details, and for links to resources in case something goes wrong, see the Getting Started with CmdStanr vignette of the package.

Accessing the course

To be able to use the code in each session, you will need a local copy of the course material.

  • Directly download the course material:

    Tip
  • Alternatively, if you are familiar with git you can clone the repo.

  • If you prefer, you can also view each session on the website, and copy-paste the code into your own R script. In that case you don’t need to download the material.

    • Tip: if you hover over each code chunk on the website you can use a “Copy” button at the top right corner.

Interacting with a local copy of the course material

A benefit of downloading or cloning all the material is that you can interact with the session files directly.

In this course, all content is written using R Notebooks. This means that we can combine text with code and see the output directly. The notebooks are then directly reproduced on the course website (for example, this page).

To interact with each session in the course, we recommend opening the RStudio Project file (nfidd.RProj) in the nfidd folder you have just downloaded. Then you can choose to:

  • View each session on the website, and copy-paste the code into your own R script.
    • Tip: if you hover over each code chunk on the website you can use a “Copy” button at the top right corner.
  • Open the R Notebook for each session.
    • Each notebook is saved in nfidd/sessions/ as a .qmd file.
    • Execute code with the single green “play” button at the top-right corner of each code chunk (“Run current chunk”). You can also execute code line-by-line using Ctrl/Cmd + Enter.
    • We suggest using “Visual” view for a better experience (top-left of the RStudio pane).