Installation of the rstan Package for Laptops Running Windows


If you do not have full administrative rights on your laptop then a person who does have such rights may
need to assist you with this preparation.

  1. These instructions have been tested more thoroughly in ordinary R rather than R studio. However, it you are using R studio
    then the following action may help with this process: when lauching R studio choose: "running it as an administrator".

  2. Make sure that your laptop has a recent version of R. The current version at the time that this web-site
    was last updated is R version 4.3.1 (2023-06-16) -- "Beagle Scouts" which can be installed from the
    Comprehensive R Archive Network.

  3. If you are using R studio then make sure the version of R studio version is current.
    This can be achieved from the menu at the top of R studio and using the commands
    Help and then Check for Updates.

  4. Download rtools 4.3 via the web-page given below. After getting to the web-page click on Rtools43 installer.
    The web-page for this step may be reached from this link.

  5. To install the R package rstan and the other R packages on which it depends
    start an R session and issue the command:

    remove.packages(c("rstan","StanHeaders"))
    Ignore any error message that may be produced from this last command.

    Next, enter the commands:

    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")))

    These commands take several minutes to run.


  6. Test whether the rstan package and Rtools are installed properly on your laptop.
    This involves the R script rstanTest.R. Start an R session, ensuring that rstanTest.R is in the current working
    directory of your R session and then issue the command:

    source("rstanTest.R")

    The script may take close to a minute to run if there are no errors.
    Ignore all warning messages printed to the screen.

    If the script runs without errors and produces a figure that looks like the one here then this indicates that you have installed
    the rstan package correctly and the required Rtools are on your laptop. If you cannot get the script to
    run then e-mail the lecturer/presenter via matt.wand@uts.edu.au as soon as possible.

If you experience any problems with the above then the lecturer/presenter will try his best to help you
via e-mail. His address is matt.wand@uts.edu.au.