[R] Polynomial Regression and NA coefficients in R

Lucas Holland hollandlucas at gmail.com
Sat Apr 27 17:48:17 CEST 2013


Hey all,

I'm performing polynomial regression. I'm simulating x values using runif() and y values using a deterministic function of x and rnorm(). 

When I perform polynomial regression like this:

fit_poly <- lm(y ~ poly(x,11,raw = TRUE))

I get some NA coefficients. I think this is due to the high correlation between say x and x^2 if x is distributed uniformly on the unit interval (as is the case in my example). However, I'm still able to plot a polynomial fit like this:

points(x, predict(fit_poly), type="l", col="green", lwd=2)

What I'm interested in finding out is, how R handles the NA values I get for some coefficients (and how that affects the polynomial I see plotted).

Thanks!



More information about the R-help mailing list