I am building a quadratic model with lm in R:
y <- data[[1]] x <- data[[2]] x2 <- x^2 quadratic.model = lm(y ~ x + x2)
Now I wan
You need order():
order()
P <- predict(quadratic.model) plot(y~x) reorder <- order(x) lines(x[reorder], P[reorder])
My answer here is related: Problems displaying LOESS regression line and confidence interval