**Also available as eBook on:**

*A Hands-On Way to Learning Data Analysis*

Part of the core of statistics, linear models are used to make predictions and explain the relationship between the response and the predictors. Understanding linear models is crucial to a broader competence in the practice of statistics. **Linear Models with R, Second Edition** explains how to use linear models in physical science, engineering, social science, and business applications. The book incorporates several improvements that reflect how the world of R has greatly expanded since the publication of the first edition.

**New to the Second Edition**

- Reorganized material on interpreting linear models, which distinguishes the main applications of prediction and explanation and introduces elementary notions of causality
- Additional topics, including QR decomposition, splines, additive models, Lasso, multiple imputation, and false discovery rates
- Extensive use of the ggplot2 graphics package in addition to base graphics

Like its widely praised, best-selling predecessor, this edition combines statistics and R to seamlessly give a coherent exposition of the practice of linear modeling. The text offers up-to-date insight on essential data analysis topics, from estimation, inference, and prediction to missing data, factorial models, and block designs. Numerous examples illustrate how to apply the different methods using R.

**Introduction **Before You Start

Initial Data Analysis

When to Use Linear Modeling

History

**Estimation **Linear Model

Matrix Representation

Estimating b

Least Squares Estimation

Examples of Calculating ˆb

Example

QR Decomposition

Gauss–Markov Theorem

Goodness of Fit

Identifiability

Orthogonality

**Inference **Hypothesis Tests to Compare Models

Testing Examples

Permutation Tests

Sampling

Confidence Intervals for b

Bootstrap Confidence Intervals

**Prediction **Confidence Intervals for Predictions

Predicting Body Fat

Autoregression

What Can Go Wrong with Predictions?

**Explanation **Simple Meaning

Causality

Designed Experiments

Observational Data

Matching

Covariate Adjustment

Qualitative Support for Causation

**Diagnostics **Checking Error Assumptions

Finding Unusual Observations

Checking the Structure of the Model

Discussion

**Problems with the Predictors **Errors in the Predictors

Changes of Scale

Collinearity

**Problems with the Error **Generalized Least Squares

Weighted Least Squares

Testing for Lack of Fit

Robust Regression

**Transformation **Transforming the Response

Transforming the Predictors

Broken Stick Regression

Polynomials

Splines

Additive Models

More Complex Models

**Model Selection **Hierarchical Models

Testing-Based Procedures

Criterion-Based Procedures

Summary

**Shrinkage Methods **Principal Components

Partial Least Squares

Ridge Regression

Lasso

**Insurance Redlining—A Complete Example **Ecological Correlation

Initial Data Analysis

Full Model and Diagnostics

Sensitivity Analysis

Discussion

**Missing Data **Types of Missing Data

Deletion

Single Imputation

Multiple Imputation

**Categorical Predictors **A Two-Level Factor

Factors and Quantitative Predictors

Interpretation with Interaction Terms

Factors with More than Two Levels

Alternative Codings of Qualitative Predictors

**One Factor Models **The Model

An Example

Diagnostics

Pairwise Comparisons

False Discovery Rate

**Models with Several Factors **Two Factors with No Replication

Two Factors with Replication

Two Factors with an Interaction

Larger Factorial Experiments

**Experiments with Blocks **Randomized Block Design

Latin Squares

Balanced Incomplete Block Design

**Appendix: About R **

Bibliography

Index

### Biography

Julian J. Faraway

"After 10 years, a new edition of Faraway’s excellent

Linear Models with Ris now available.. . There are several major changes in this edition. The material on interpreting linear models has been reorganized to emphasize the distinction between prediction and explanation; this was done with the addition of two new chapters . . . Several other chapters benefit from the addition of new material. . . Finally, most chapters conclude with more exercises than in the previous edition."—The American Statistician, 2016"This book is a must-have tool for anyone interested in understanding and applying linear models. The logical ordering of the chapters is well thought out and portrays Faraway’s wealth of experience in teaching and using linear models. … The reorganization of the material in this second edition presents linear models with R in a coherent and easy-to-follow way. In summary, this book provides an excellent basis for understanding and applying linear models. It lays down the material in a logical and intricate manner and makes linear modeling appealing to researchers from virtually all fields of study."

—Biometrical Journal, 2015"The book provides an excellent introduction of the various aspects of linear models with many interesting examples.

The explanations are clear enough for beginners with little statistical background and are accompanied by worked examples with associated R code. This is an important contribution since it provides readers/students an opportunity to replicate the analyses and results of an example. There are many books written on the topic of linear models, but this book takes an applied approach and explains the concepts intuitively using graphical explanations and examples.

Overall, this is a nicely written book, which can lay a strong foundation for senior undergraduate and beginning graduate students. This book can be recommended as a textbook for computational linear regression courses. It will also be useful for practitioners who want to get started on applying regression models for studying associations among different variables, estimation of regression coefficients, and prediction. It offers insightful interpretations and discussions with examples worked using the R software."

—MAA Reviews, January 2015

Praise for the First Edition:"One danger with applied books such as this is that they become recipe lists of the kind 'press this key to get that result.' This is not so with Faraway's book. Throughout, it gives plenty of insight on what is going on, with comments that even the seasoned practitioner will appreciate. Interspersed with R code and the output that it produces one can find many little gems of what I think is sound statistical advice, well epitomized with the examples chosen…I read it with delight and think that the same will be true with anyone who is engaged in the use or teaching of linear models…I find this book a valuable buy for anyone who is involved with R and linear models, and it is essential in any university library where those topics are taught."

-Journal of the Royal Statistical Society

"Linear Models with Ris well written and, given the increasing popularity of R, it is an important contribution."

-Technometrics, Vol. 47, No. 3, August 2005

"There are many books on regression and analysis of variance on the market, but this one is unique and has a novel approach to these statistical methods. The author uses R throughout the text to teach data analysis…The text also contains a wealth of references for the reader to pursue on related issues. This book is recommended for all who wish to use R for statistical investigations."

-Short Book Reviews of the International Statistical Institute

"The book is very comprehensibly written and can therefore be recommended for beginners in linear models. It is clearly and simply explained how to use R and which packages are necessary to analyze linear models. …All in all, this book is recommendable as a textbook for computational linear regression courses and therefore for students and lecturers, but also for applied statisticians who want to get started on regression analysis using the software R."

-Biometrics

"Dr. Faraway uses many examples and graphical procedures to illustrate the methods. This is a great strength of the book. …Linear Models with Ris one of several books appearing to make R more accessible by bringing together functions from a number of packages and illustrating their use. From this perspective alone it is an important contribution. …I feel this book does a nice job of describing the methods available in linear modeling and illustrating the realistic implementation of these methods in a careful data analysis. …"

-Statistics in Medicine, 2006