Setup

You will need to have a running R environment - R can be downloaded for Linux, Mac, and Windows from here.

We use renv to manage package dependencies. Installing renv and running renv::restore() should provide you with an environment suitable for running this model.

install.packages('renv')
renv::restore()

We use the targets package to manage the computational pipeline. Targets essentially ensures that computations are only repeated when downstream dependencies or code are changed. For an introduction take a look at the targets manual

You may also need to install cmdstan - it will be installed via renv::restore but there it needs an additional step to install the toolchain.

cmdstanr::install_cmdstan()

Once cmdstan is installed you can run the pipeline

library(targets)
tar_make()

This will take 15 or so minutes - the modelling portion will spit out a lot of warnings.

When the pipeline is complete you can load individual targets using tar_load(), e.g.

tar_load(polls)
tar_load(model2023_summary_model2023)

All the targets are defined on the pipeline page.

We also make use of the stantargets. The tar_stan_mcmc function creates a few different automatically named targets - including model2023_summary_model2023.