How to run a regression with multiple powers of x

I want to run regression y = b0 + b1x + b2x^2 + u, but I'm not sure how to do this. I've tried lm(y~x), but I don't get an estimate for the coefficient of x^2.
How can I run this regression so that when I summarize the results R gives me an estimate for bot b1 and b2?

coef(lm(y ~ poly(x, 2, raw = TRUE)))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.