Page 357 - Applied Statistics with R
P. 357

14.2. PREDICTOR TRANSFORMATION                                    357


                      coef(lm(y ~ x + I(x ^ 2), data = quad_data))


                      ## (Intercept)             x      I(x^2)
                      ##    3.0649446  -0.5108131    5.0739805

                      coef(lm(y ~ x + x:x, data = quad_data))



                      ## (Intercept)             x
                      ##    -18.32715    24.87163

                      coef(lm(y ~ x * x, data = quad_data))


                      ## (Intercept)             x
                      ##    -18.32715    24.87163

                      coef(lm(y ~ x ^ 2, data = quad_data))



                      ## (Intercept)             x
                      ##    -18.32715    24.87163

                      coef(lm(y ~ x + x ^ 2, data = quad_data))


                      ## (Intercept)             x
                      ##    -18.32715    24.87163

                      coef(lm(y ~ I(x + x), data = quad_data))



                      ## (Intercept)     I(x + x)
                      ##    -18.32715    12.43582

                      coef(lm(y ~ x + x, data = quad_data))



                      ## (Intercept)             x
                      ##    -18.32715    24.87163


                      14.2.7    Data Example
   352   353   354   355   356   357   358   359   360   361   362