Problem getting brms and Stan working on Windows 10 networked computers

We think we have a solution (a set of steps). There may well be some redundancies in here, but I post the instructions I will sending out to attendees of my workshop in case it is useful for anyone else. I can confirm these steps have worked on one networked Windows 10 computer but we have not yet managed to test it on another.

If you have a Windows laptop with a network drive (i.e., most Windows computers provided by the university), you will need to take some special steps to get R, RStudio, brms and associated packages all working together. These steps are necessary to ensure that everything is installed on your computer’s internal drive rather than on the network, and that R.

Uninstall your current (and possibly out-of-date) versions of R and RStudio.

Download the latest version of R from https://cran.r-project.org/bin/windows/base/. Install it by right-clicking on the file and choosing “run as administrator” (this will install it on your internal drive).

Download the latest version of RStudio from https://rstudio.com/products/rstudio/download/#download. Install it by right-clicking on the file and choosing “run as administrator” (this will install it on your internal drive).

Download RTools35 from https://cran.r-project.org/bin/windows/Rtools/. Install it by right-clicking on the file and choosing “run as administrator” (this will install it on your internal drive).

Create a folder called “R" on the C drive, and within that a subfolder called “library”.

Open Control Panel (not Settings), then System and Security > System > Advanced system settings > Environment variables. Click New… and enter R_LIBS_USER as the Variable name, and C:/R/library as the Variable value.

Open RStudio and run .libPaths(). If it returns C:/R/library as the first, or only, listed path, everything is good. If it does not, run .libPaths("C:/R/library”).

Close RStudio and re-open. Install the following packages by running:

install.packages(“brms”)
install.packages(“tidyverse”)
install.packages(“car”)
install.packages(“bayesplot”)
install.packages(“rstan”)
install.packages(“lme4”)

Then load those packages with:

library(brms)
library(tidyverse)
library(car)
library(bayesplot)
library(rstan)
library(lme4)

To check that brms and Stan are working correctly, run the following in RStudio’s console:

bprior1 <- prior(student_t(5,0,10), class = b) +
  prior(cauchy(0,2), class = sd)
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
            data = epilepsy, family = poisson(), prior = bprior1)
fit1