Installation of the rstan Package for Laptops Running Mac OS X


  1. Some of these instructions may only work in ordinary R and graphical user interfaces such as R studio may cause problems.
    Therefore, it is recommended to use ordinary R for these instructions (although R studio users could try first with that interface
    and revert to ordinary R if problems arise).

    The version of Mac OS X may affect whether these instructions work as intended. They have been
    tested on recent versions such as Ventura but not on older versions of Mac OS X.


  2. 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.


  3. 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.2.1 (2023-06-16) -- "Beagle Scouts" which can be installed
    from the Comprehensive R Archive Network.


  4. Install the R package rstan and the other R packages on which it depends.
    This can be done by making sure that your laptop has an Internet connection,
    starting an R session and then issuing the commands:

    options(repos = "http://cran.r-project.org")
    install.packages(c("rstan","BH"), dependencies = TRUE)

  5. However, rstan also requires Mac OS X Developer Tools to be installed on your laptop,
    if they are not already there. This is discussed in the next step.

  6. Test whether the rstan package and Mac OS X Developer Tools 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 Mac OS X Developer Tools

    If the source("rstanTest.R") command failed then you will need to install XCode from the Mac OS X App Store.
    To do this, make sure that your laptop has an Internet connection and then click on the magnifying glass
    symbol in the top right-hand corner of your screen. Type the words App Store in the search box. Select App Store from the
    drop-down menu. This gives a new window with another magnifying glass symbol and search box in the top right-hand corner.
    Type Xcode into this search box and hit Enter. An icon for Xcode Developer Tools should appear. Then click on the GET button
    of the icon and select INSTALL APP.

    Once the Mac OS X Developer Tools have been installed, try the

    source("rstanTest.R")

    test again.

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.