set.seed(1234)
df <- data.frame(x=runif(500, min=-1, max=1)*pi)
df$y <- sin(df$x)*20 + rnorm(nrow(df), mean=0, sd=10)
plot(df, xlim=c(-4, 4))
dfl1 <- ssr(df)
lines(dfl1)
xx <- c(-4, -1, 0, 1, 4)
yy <- ssr_predict(dfl1, xx)
points(xx,yy, pch='+', col='red', cex=2)
Run the code above in your browser using DataLab