Computing

R

Course notes and primary examples are based on R. I used the following version of R to build the course notes

R.version$version.string
[1] "R version 4.5.2 (2025-10-31 ucrt)"

It is best to be using the latest version of R.

Rstudio

Current versions of RStudio support editing and preview of Quarto documents.

To efficiently use Quarto within RStudio it is strongly recommended that you use the latest release of RStudio. You need to be using RStudio (v2023.06) or later.

You can download RStudio from https://posit.co/download/rstudio-desktop/.

Quarto

Quarto is a multi-language, next generation version of R Markdown from RStudio, with many new features and capabilities. Like R Markdown, Quarto uses Knitr to execute R code, and is therefore able to render most existing Rmd files without modification.

To use Quarto with R, you should install the rmarkdown R package:

install.packages("rmarkdown")

Installation of the rmarkdown package will also install the knitr package so you will have everything required to render documents containing R code.

R packages

There are many ways to achieve the same results in R. To create the notes, I utilize base R and a variety of different packages that provide one way of obtaining the results. The packages needed used to create the notes are listed at the beggining of each set of notes.

If you do not have the packages I used installed, they will need to be installed first to recreate the analyses in the notes. The packages I use and demonstrate may not be unique. Other packages may do something similar and allow you to arrive at the same final answer.

Installing and loading R packages

The simplest way to install an R packages is to use the install.package function. For example,

install.packages("rms")

After installation, you can load the package

library("rms")

Some packages install smoothly, others can generate errors if necessary dependencies are not installed. I will add known issues and solutions to this document as needed throughout the course.

Stata

Stata also should be able to conduct all of these analyses necessary for this course. The main advantage to Stata is that its syntax is relatively straightforward. It also has a menu system that can be used to create code and make the analysis reproducible through .do files.

UCLA Statistical Methods and Data Analytics maintain a good website for those interested in learning more about the capabilities of Stata

There is a Statamarkdown package under development that allows for Stata code to be used in Quarto. I do not have wide experience with this package, but more information is available at https://github.com/hemken/Statamarkdown. It is of no use if you do not have Stata installed.