Germán Rodríguez
Generalized Linear Models Princeton University

Logs

The "R Logs" collect the transcripts of six sessions using R, a free software environment for statistical computing and graphics. Each session reproduces the results of (practically) all the analyses in one of the Chapters of my lecture notes on Generalized Linear Models.

The material is organized by Chapters and Sections using exactly the same numbering system as the notes, so section 2.8 of the logs deals with the analysis of covariance models described in section 2.8 of the notes. Use the Table of Contents to jump directly to any section.

The transcripts are formatted versions of R input and output obtained by running version 3.1.1. The text boxes set in a typewriter font contain R function calls, followed by the resulting output. You can tell the input lines because they are preceded by R's prompt, a greater than sign (>), or the continuation prompt, a plus sign (+). The rest of the text set in the standard font represents comments or annotations, except for references to R functions or packages, which are also set in a typewriter-style font.

The best way to use these transcripts is sitting by a computer, typing in the code as you read along, probably with a printed copy of the notes by the side. I also recommend that you try to answer the few questions and exercises posed along the way.

While interactive use is probably good for learning, for more serious work I recommend that you prepare an R script collecting all your code and then run it, ideally sending the output to a file. These logs were all produced using R scripts.

The purpose of these notes is to illustrate the use of R in statistical analysis, not to provide a primer or tutorial. I have, however, written a short tutorial that you can find at data.princeton.edu/R. Please consult the R online help and documentation for more details.

To get started download R for free from the R project home page at www.r-project.org. You will be asked to select a mirror site and will then be able to download binaries for Linux, Mac OS X, or Windows. You can also download the source code if you are interested in looking under the hood.

I recommend that you also download R Studio, an excellent Integrated Development Environment (IDE) for R, from it's home at RStudio.com. This is not strictly necesary, but it makes editing and running R scripts much easier. R Studio is free and works on Linux, Mac OS X, and Windows.

P.S. The note on robust standard errors in R is here.