On Mon, Feb 28, 2011 at 08:41:02AM -0800, knut-o wrote: > Hi > I have a x-list and a y-list and I'm trying to make a line that goes ca. > through the dots. I want to find a, b and c in ax^2 + bx + c. > How to do?
Hi. Try the following x <- rnorm(100) y <- 4*x^2 + 3*x + 2 + 0.2*rnorm(100) z <- poly(x, degree=2, raw=TRUE) lm(y ~ z)$coefficients (Intercept) z1 z2 2.000131 3.013591 4.000884 or also x2 <- x^2 lm(y ~ x + x2)$coefficients with the same result. Hope this helps. Petr Savicky. ______________________________________________ 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.