In the previous section, we adopted an algebraic approach to calculating the regression line. More generally, to create a linear regression model, we use the lm() function. This function creates a LinearModel object. The object of class lm has a series of properties that can be immediately viewed by simply clicking on it. These types of objects can be used for residual analysis and regression diagnosis.Â
LinearModel is an object comprised of data, model description, diagnostic information, and fitted coefficients for a linear regression.
Models for the lm() function are specified symbolically. In fact, the first argument of the function is an object of class formula. A typical formula object has the following form:
response ~ terms
response represents the (numeric) response vector and terms is a series of terms specifying a linear...