detrend function

Projection of a model matrix on the orthogonal complement of a trend or curvature.