1. Requirements

  • Note: RStan requires R version 3.4.0 or later.

  • Note: RStan requires RTools version 40 or later.

  • Note: It is recommended to use R version 4.0.0 or later.

  • Note: It is recommended to use RStudio version 1.4.x or later.

  • Install R.

  • Install RStudio.

  • Install RTools.

2. Linux

  • Note: Do not install on a headless machine because R and RStudio require a graphical user interface.

2.1. Installation

  • Enter the following commands at a Command Line.

    apt-get install r-cran-rstan

3. Windows

3.2. Uninstallation

  • Start R with administrative privileges.

  • Enter the following commands at the Command Prompt.

    remove.packages("rstan")
    if (file.exists(".RData")) file.remove(".RData")
  • Close R.

3.3. Installation

  • Note: Remove any previous version (see above).

  • Start R with administrative privileges.

  • Enter the following commands at the Command Prompt.

    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")))
    example(stan_model, package = "rstan", run.dontrun = TRUE)
    
    
    # See https://blog.mc-stan.org/2022/04/26/stan-r-4-2-on-windows
    install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
    
    cmdstanr::check_cmdstan_toolchain(fix = TRUE)
    cmdstanr::install_cmdstan()
    # if you already had the latest version of CmdStan install
    # cmdstanr::install_cmdstan(overwrite = TRUE)
    
    fit <- cmdstanr::cmdstanr_example()
    fit
  • Close R.

3.4. Configuration

  • Todo: