How it works...

The algorithm works using penalized spline smoothing. Very detailed material on this package can be found in its official PDF documentation: 

The intuition behind this technique is to find a set of knots and weights that can help in capturing the non-linear relationship. However, this is dangerous from an overfitting perspective, as more knots will produce more overfitting. Penalized splines attempt to mitigate the impact of overfitting, by intelligently penalizing the weights (not allowing them to be as big as they would be without intervention). 

Get R Statistics Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.