This is a generalization of Isolating coefficients from polynomial fit in r (which does not cover the case of polynomials) and (in a sense) a duplicate of Isolating coefficients from polynomial fit in r (which, after 4 years, only has a partial answer/"workaround"; see my remark about raw = TRUE
below).
Suppose I have a polynomial fit:
l <- lm(mpg ~ poly(cyl, disp, hp, degree = 2), mtcars)
summary(l)
Is there an easy way to obtain the polynomial formula behind it?
I understand that poly
works with orthogonal polynomials and that the option raw = TRUE
will work with monomials. Thus, with raw = TRUE
it is much easier to extract a formula. However, I have been told that raw = TRUE
will, in general, give a different (worse?) fit.