-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.qmd
57 lines (39 loc) · 1.61 KB
/
setup.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
title: Setup
---
You will need to have a running R environment - R can be downloaded for
Linux, Mac, and Windows from [here](https://cran.r-project.org/).
We use [renv](https://rstudio.github.io/renv/index.html) to manage package
dependencies. Installing `renv` and running `renv::restore()` should provide you with an
environment suitable for running this model.
```{r}
#| eval: false
install.packages('renv')
renv::restore()
```
We use the [targets](https://docs.ropensci.org/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](https://books.ropensci.org/targets/)
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.
```{r}
#| eval: false
cmdstanr::install_cmdstan()
```
Once `cmdstan` is installed you can run the pipeline
```r
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.
```r
tar_load(polls)
tar_load(model2023_summary_model2023)
```
All the targets are defined on the [pipeline page](pipeline.qmd).
We also make use of the [stantargets](https://docs.ropensci.org/stantargets/index.html).
The [`tar_stan_mcmc` function](https://docs.ropensci.org/stantargets/reference/tar_stan_mcmc.html)
creates a few different automatically named targets - including `model2023_summary_model2023`.