An R Companion to Applied Regression, Third Edition

John Fox and Sanford Weisberg

Sage Publications (2019)



The files on this page can also be conveniently downloaded by the carWeb() function in the car package: see ?carWeb for details.

Chapter Scripts

Getting Started with R and RStudio
Reading and Manipulating Data
Exploring and Transforming Data
Fitting Linear Models
Standard Errors, Confidence Intervals, and Tests
Fitting Generalized Linear Models
Fitting Mixed-Effects Models
Regression Diagnostics
Drawing Graphs
An Introduction to R Programming


Appendix Scripts

Bayesian estimation of regression models
appendix-bootstrapping.R Bootstrapping regression models
Cox regression for survival data
Fitting regression models to survey data
Multiple imputation of missing data
Multivariate linear models
appendix-nonlinear.R Nonlinear regression
Nonparametric regression
Robust regression
Time-series regression


Data Files

Duncan.csv Duncan's occupational-prestige data in CSV format
Duncan.txt Duncan's occupational-prestige data in whitespace-separated format
Duncan.xlsx Duncan's occupational-prestige data in an Excel file
Hamlet.txt Text of the "to-be-or-not-to-be" soliloquy
Rossi.txt Rossi et al.'s recidivism data (for the Cox regression appendix)


Other Downloadable Files

Duncan.Rmd R Markdown file for Duncan's occupational-prestige regression
RMarkdownTest.Rmd Example R Markdown file
zipmod.R Programming example
zipmodBugged.R Example for debugging
zipmod-generic.R Object-oriented programming example