I am trying to fit smooth curve to my dataset; is there is any better smoothing curve than I produced using the following codes:
x <- seq(1, 10, 0.5)
y <-
I think perhaps you're looking for an interpolated smooth line, which in the case of R is probably most easily accomplished by fitting an interpolation spline? As the other answers discuss, that's not what statistical fitting is about, but there are many contexts where you want a smooth interpolated curve -- I think your terminology may have thrown people off.
Splines are more numerically stable than polynomials.
x <- seq(1, 10, 0.5)
y <- c(1, 1.5, 1.6, 1.7, 2.1,
2.2, 2.2, 2.4, 3.1, 3.3,
3.7, 3.4, 3.2, 3.1, 2.4,
1.8, 1.7, 1.6, 1.4)
library(splines)
isp <- interpSpline(x,y)
xvec <- seq(min(x),max(x),length=200) ## x values for prediction
png("isp.png")
plot(x,y)
## predict() produces a list with x and y components
lines(predict(isp,xvec),col="red")
dev.off()