R, Machine Learning, Nonlinear Regression.
automatically. For generalized additive models, the “gam” function should be used in R. R codes are shown below: model<-gam(medv~s(lstat),data=train.data) predictions<-model %>% predict(test.data) data.frame( RMSE=RMSE(predictions,test.data$medv), R2=R2(predictions,test.data$medv) ) RMSE R2 1