Hi Lucas, You may find some of these examples useful (towards the end):
http://elkhartgroup.com/rmodels.php For example in your case you could be using b splines instead of an 11th order polynomial, or use thin plate regression splines from the mgcv package. I will also humbly suggest that ggplot2 overlaying observed values with predicted lines is a more elegant way to visualize the data and the results. Cheers, Josh On Sat, Apr 27, 2013 at 8:48 AM, Lucas Holland <hollandlu...@gmail.com>wrote: > 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! > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://joshuawiley.com/ Senior Analyst - Elkhart Group Ltd. http://elkhartgroup.com [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.