Regression measures the linear relation between two timeseries.

In Matlab/Octave:

[alpha;beta]=[1, r_X]  \ r_kn;
residuals = r_kn - ([1,r_X]*[alpha;beta]);
sigma_res = std(residuals);
alpha_adj = alpha ./ sigma_res;

Some wordings:

explained sum of squares

residual sum of squares

total sum of squares

Goodness of fit (R2):

adjusted R2 by loss of degree of freedom (k variables, T observations):