2nd Edition

# Extending the Linear Model with R Generalized Linear, Mixed Effects and Nonparametric Regression Models, Second Edition

**Also available as eBook on:**

*Start Analyzing a Wide Range of Problems *

Since the publication of the bestselling, highly recommended first edition, R has considerably expanded both in popularity and in the number of packages available. **Extending the Linear Model with R: Generalized Linear, Mixed Effects and Nonparametric Regression Models, Second Edition** takes advantage of the greater functionality now available in R and substantially revises and adds several topics.

*New to the Second Edition*

- Expanded coverage of binary and binomial responses, including proportion responses, quasibinomial and beta regression, and applied considerations regarding these models
- New sections on Poisson models with dispersion, zero inflated count models, linear discriminant analysis, and sandwich and robust estimation for generalized linear models (GLMs)
- Revised chapters on random effects and repeated measures that reflect changes in the lme4 package and show how to perform hypothesis testing for the models using other methods
- New chapter on the Bayesian analysis of mixed effect models that illustrates the use of STAN and presents the approximation method of INLA
- Revised chapter on generalized linear mixed models to reflect the much richer choice of fitting software now available
- Updated coverage of splines and confidence bands in the chapter on nonparametric regression
- New material on random forests for regression and classification
- Revamped R code throughout, particularly the many plots using the ggplot2 package
- Revised and expanded exercises with solutions now included

*Demonstrates the Interplay of Theory and Practice*

This textbook continues to cover a range of techniques that grow from the linear regression model. It presents three extensions to the linear framework: GLMs, mixed effect models, and nonparametric regression models. The book explains data analysis using real examples and includes all the R commands necessary to reproduce the analyses.

**Introduction **

**Binary Response**

Heart Disease Example

Logistic Regression

Inference

Diagnostics

Model Selection

Goodness of Fit

Estimation Problems

**Binomial and Proportion Responses**

Binomial Regression Model

Inference

Pearson’s *χ*^{2} Statistic

Overdispersion

Quasi-Binomial

Beta Regression

**Variations on Logistic Regression**

Latent Variables

Link Functions

Prospective and Retrospective Sampling

Prediction and Effective Doses

Matched Case-Control Studies

**Count Regression**

Poisson Regression

Dispersed Poisson Model

Rate Models

Negative Binomial

Zero Inflated Count Models

**Contingency Tables **Two-by-Two Tables

Larger Two-Way Tables

Correspondence Analysis

Matched Pairs

Three-Way Contingency Tables

Ordinal Variables

**Multinomial Data**

Multinomial Logit Model

Linear Discriminant Analysis

Hierarchical or Nested Responses

Ordinal Multinomial Responses

**Generalized Linear Models**

GLM Definition

Fitting a GLM

Hypothesis Tests

GLM Diagnostics

Sandwich Estimation

Robust Estimation

**Other GLMs**

Gamma GLM

Inverse Gaussian GLM

Joint Modeling of the Mean and Dispersion

Quasi-Likelihood GLM

Tweedie GLM

**Random Effects **

Estimation

Inference

Estimating Random Effects

Prediction

Diagnostics

Blocks as Random Effects

Split Plots

Nested Effects

Crossed Effects

Multilevel Models

**Repeated Measures and Longitudinal Data**

Longitudinal Data

Repeated Measures

Multiple Response Multilevel Models

**Bayesian Mixed Effect Models**

STAN

INLA

Discussion

**Mixed Effect Models for Nonnormal Responses**

Generalized Linear Mixed Models

Inference

Binary Response

Count Response

Generalized Estimating Equations

**Nonparametric Regression**

Kernel Estimators

Splines

Local Polynomials

Confidence Bands

Wavelets

Discussion of Methods

Multivariate Predictors

**Additive Models **Modeling Ozone Concentration

Additive Models Using mgcv

Generalized Additive Models

Alternating Conditional Expectations

Additivity and Variance Stabilization

Generalized Additive Mixed Models

Multivariate Adaptive Regression Splines

**Trees **Regression Trees

Tree Pruning

Random Forests

Classification Trees

Classification Using Forests

**Neural Networks **Statistical Models as NNs

Feed-Forward Neural Network with One Hidden Layer

NN Application

Conclusion

**Appendix A: Likelihood Theory ****Appendix B: About R **

Bibliography

Index

### Biography

**Julian J. Faraway** is a professor of statistics in the Department of Mathematical Sciences at the University of Bath. His research focuses on the analysis of functional and shape data with particular application to the modeling of human motion. He earned a PhD in statistics from the University of California, Berkeley.

"What I liked most with this book was the comprehensive treatment of the practical application of GLMs, covering most outcomes an applied statistician will encounter, and at the same time presenting just enough of the necessary theoretical basis for the discussed methods. Combined with the thorough discussion of the R output, the text will serve as a useful guide for the reader when applying the methods to his or her own data set."

—Psychometrika,2018"The second edition of book ‘Extending the linear model with R’ by Julian Faraway is an easily readable and relatively thorough (without being theory heavy) sequel of the earlier ‘Linear Models with R’ by the same author. The book itself is written in a self-paced tutorial style in easily digestible chunks integrating descriptions of underlying methodology, with data analysis and R code. The organization of the book is well thought through. The flow of the book is problem driven rather than driven by the underlying statistical theory . . . the second edition is more polished in terms of the figures used, R code and output display and a crisper typesetting of equations."

—John T. Ormerod,University of Sydney

Praise for the First Edition:"… well-written and the discussions are easy to follow … very useful as a reference book for applied statisticians and would also serve well as a textbook for students graduating in statistics."

—Computational Statistics, April 2009, Vol. 24"The text is well organized and carefully written … provides an overview of many modern statistical methodologies and their applications to real data using software. This makes it a useful text for practitioners and graduate students alike."

—Journal of the American Statistical Association, December 2007, Vol. 102, No. 480"I enjoyed this text as much as [Faraway’s

Linear Models with R]. The book is recommended as a textbook for a computational statistical and data mining course including GLMs and non-parametric regression, and will also be of great value to the applied statistician whose statistical programming environment of choice is R."

—Journal of Applied Statistics, July 2007, Vol. 34, No. 5"This is a very pleasant book to read. It clearly demonstrates the different methods available and in which situations each one applies. It covers almost all of the standard topics beyond linear models that a graduate student in statistics should know. It also includes discussion of topics such as model diagnostics, rarely addressed in books of this type. The presentation incorporates an abundance of well-chosen examples … this book is highly recommended …"

—Biometrics, December 2006"It has been a great pleasure to review this book, which delivers both a readily accessible and reader-friendly account of a wide range of statistical models in the context of R software. Since the publication of the very well received first edition of the book, R has considerably expanded both in popularity and in the number of packages available. The second editionof the book takes advantage of the greater functionality available now in R, and substantially revises and adds several new topics."

—Andrzej Galecki,The International Biometric Society