Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. library(mgcv)
  2. n=500
  3. x<-matrix(sort(runif(n,0,150)),ncol=1)
  4. y_true<-(-20 + 10*x + 30*sin(0.3*x) - 0.05*x^2)/15
  5. y<-rnorm(n,y_true,sd=2)
  6. colnames(x)<-"x"
  7. x<-data.frame(x)
  8. plot(x$x,y)
  9. lines(x$x,y_true,lwd=5,lty=2)
  10. m<-gam(y ~ s(x,bs="ps",k=50),data=x)
  11. lines(data$x,predict(m,x),col="red",lwd=5)
  12. m3<-gam(y ~ s(x,bs="gp"),data=x) # this doesnt work on my laptop and produces the error
  13. lines(x$x,predict(m,x),col="red",lwd=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement