An R Introduction to Statistics

Multiple Coefficient of Determination

The coefficient of determination of a multiple linear regression model is the quotient of the variances of the fitted values and observed values of the dependent variable. If we denote yi as the observed values of the dependent variable, ¯y as its mean, and yˆi as the fitted value, then the coefficient of determination is:

     ∑        2
R2 = ∑-(yˆi --¯y)
       (yi - ¯y)2

Problem

Find the coefficient of determination for the multiple linear regression model of the data set stackloss.

Solution

We apply the lm function to a formula that describes the variable stack.loss by the variables Air.Flow, Water.Temp and Acid.Conc. And we save the linear regression model in a new variable stackloss.lm.

> stackloss.lm = lm(stack.loss ~ 
+     Air.Flow + Water.Temp + Acid.Conc., 
+     data=stackloss)

Then we extract the coefficient of determination from the r.squared attribute of its summary.

> summary(stackloss.lm)$r.squared 
[1] 0.91358

Answer

The coefficient of determination of the multiple linear regression model for the data set stackloss is 0.91358.

Note

Further detail of the r.squared attribute can be found in the R documentation.

> help(summary.lm)