4
$\begingroup$

I've tried reading several resources on poly(), I'm not able to see an answer to my question. My question pertains how I might present my fitted linear model in a way that the coefficients are interpretable (if possible).

What does the R function poly really do?

poly function | R Documentation

poly() in lm(): difference between raw vs. orthogonal

I have the following data:

y      x
87.4   16
17.8   7
22.0   8
16.8   10
49.2   13
16.1   5
34.2   11

I fit this as a quadratic model. If I do this simply using I(x^2), the interpretability of the coefficients is straightforward.

easy_model <- lm('y ~ I(x) + I(x^2)', data=renamed_data)
summary(easy_model)

Call: lm(formula = "y ~ I(x) + I(x^2)", data = renamed_data)

Residuals:
     13       4       5       7      10       2       8 
 0.1679  1.8821  4.6964 -8.1786  0.4500 -1.9500  2.9321 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  51.9845    16.8946   3.077  0.03704 *  
I(x)        -10.8732     3.4366  -3.164  0.03405 *  
I(x^2)        0.8173     0.1615   5.062  0.00717 **
--- 
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.126 on 4 degrees of freedom 
Multiple R-squared:  0.9744,    Adjusted R-squared:  0.9616  
F-statistic: 76.03 on 2 and 4 DF,  p-value: 0.000657

So I would write the above fitted models as $\hat{y} = 51.9845-10.8732x+0.8173x^2$, and in the context of my data I can explain how these coefficients make sense.

If I do this using poly(), however, I'm not clear on how I might interpret the coefficients, or how I might write my fitted model in the context of my data.

odd_model <- lm('y ~ poly(x, 2)', data=renamed_data)
summary(odd_model)

Call:
lm(formula = "y ~ poly(x, 2)", data = renamed_data)

Residuals:
     13       4       5       7      10       2       8 
 0.1679  1.8821  4.6964 -8.1786  0.4500 -1.9500  2.9321 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   34.786      1.938  17.953 5.66e-05 ***
poly(x, 2)1   57.642      5.126  11.244 0.000356 ***
poly(x, 2)2   25.947      5.126   5.062 0.007173 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.126 on 4 degrees of freedom
Multiple R-squared:  0.9744,    Adjusted R-squared:  0.9616 
F-statistic: 76.03 on 2 and 4 DF,  p-value: 0.000657

Now I understand that this model is the same as the one above, and both yield the same predictions.

> predict.lm(easy_model)
      13        4        5        7       10        2        8 
87.23214 15.91786 17.30357 24.97857 48.75000 18.05000 31.26786 
> predict.lm(odd_model)
      13        4        5        7       10        2        8 
87.23214 15.91786 17.30357 24.97857 48.75000 18.05000 31.26786

My conundrum is that I can't write $\hat{y} = 34.7896+57.642x+25.947x^2$ from the lm output, this gives different values than what the model would actually predict.

Could someone help me understand how I might interpret the coefficients for my model that uses poly(), and how I might present this fitted model in written form?

$\endgroup$
2
  • 1
    $\begingroup$ poly by default creates "orthogonal polynomials", which means the design matrix is not what you assume there. Set raw = TRUE if you want raw polynomials. Also: stats.stackexchange.com/a/249202/11849 $\endgroup$
    – Roland
    Commented Jul 22, 2019 at 8:34
  • $\begingroup$ Did you figure out how to interpret the coefficients? I have the same confusion with poly. $\endgroup$
    – SanMelkote
    Commented Jun 27, 2020 at 11:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.