Polynomial
Regression within R is done the same way as with multiple regression, so for
the residual analysis refer to Section
14.3. In order to do a polynomial regression in R, following the Example 1
within Section 14.5, entering the data as follows:
Temperature <- c(-1.5, 0, 2.5, 5, 7, 10, 12, 15, 17, 20, 22, 25, 27)
Efficiency <- c(33, 46, 55, 80, 87, 93, 95, 91, 89, 77, 72, 54, 46)
In
order to do a polynomial linear regression that is quadratic in temperature,
enter the code
lm(Efficiency ~ poly(Temperature,2, raw = T))
##
## Call:
## lm(formula = Efficiency ~ poly(Temperature, 2, raw = T))
##
## Coefficients:
## (Intercept) poly(Temperature, 2, raw = T)1
## 45.3253 7.3328
## poly(Temperature, 2, raw = T)2
## -0.2767
The
second value in the coefficient output will be the value for the linear term
and the third will be the quadratic term. It’s also possible to change the
polynomial value to a higher degree by adjusting the “2” value within the poly
function.