dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
arch <- ifelse(R.version$arch == "aarch64", "arm64", "x86_64")
cat(paste("\nCXX14FLAGS += -O3 -mtune=native -arch", arch, "-ftemplate-depth-256"),
    file = M, sep = "\n", append = FALSE)How to Install rstan and brms
For Mac Users
- Make sure R is up-to-date > 4.2
 - Configural C++ Toolchain
- Set up the C++ Toolchain using the macOS R toolchain installer
 - To improve estimation speed, you can copy the following syntax to the R console
 
 
- To install 
rstan, in the R console- Remove all old 
rstanfiles, if they exist 
 - Remove all old 
 
remove.packages("rstan")
if (file.exists(".RData")) file.remove(".RData")- Restart R
 - Install 
StanHeadersandrstan 
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))- Verify installation (details)
 
remove.packages("rstan")
if (file.exists(".RData")) file.remove(".RData")
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))- Install brms (details)
 
install.packages("brms")You’re all set!
For Windows Users
- Make sure R is up-to-date > 4.2
 - Configural C++ Toolchain (follow steps for R 4.2)
 - To install 
rstan, in the R console- Remove all old 
rstanfiles, if they exist 
 - Remove all old 
 
remove.packages("rstan")
if (file.exists(".RData")) file.remove(".RData")- Restart R
 - Install 
StanHeadersandrstan 
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))- Verify installation (details)
 
remove.packages("rstan")
if (file.exists(".RData")) file.remove(".RData")
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))- Install brms (details)
 
install.packages("brms")You’re all set!