detrend a matrix
[resid]=detrend(y,p)
y = input matrix (or vector) of time-series (nobs x nvar)
p = trend degree
* p = 0, subtracts mean
* p = 1, constant plus trend model
* p > 1, higher order polynomial model
* p = -1, returns y
resid = residuals from the detrending regression
x=grand(15,1,'nor',0,0.1)+[1:15]' xdt=detrend(x,0) // simply demeans x xdt=detrend(x,1) // detrends it by a linear trend r0t = detrend(trimr(dx,grocer_k,0),f) (see johansen.sci) // taken from the function johansen detrends variable trimr(dx,grocer_k,0) by a trend of order f.