Book Image

Mastering Scientific Computing with R

Book Image

Mastering Scientific Computing with R

Overview of this book

Table of Contents (17 chapters)
Mastering Scientific Computing with R
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Extending the linear framework


As discussed in the previous chapter, the basic idea underlying linear regression is that some variables' values can be predicted by the following equation describing a line:

Here, the dependent variable Y has a linear relationship with a set of X values (that is, X values that are all raised to the power of 1). Of course, the various X values themselves can be nonlinear functions of other predictor variables; thus, by performing linear regression on nonlinear transformations of predictor variables we will be able to model nonlinear relationships in between variables.

Polynomial regression

The simplest way to extend the linear framework to nonlinear relationships is through polynomial regression. The idea here is that some of the predictor variables are squared or cubed, and the squares or cubes of these predictor variables are themselves treated as distinct predictors. For example, let's say that we want to fit a second degree polynomial, as shown by the equation...