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