Hi Filip,
thanks for this contribution. As it turns out, there is already a linear regression function in WarpScript, except its documentation was missing! Basically if you call LR instead of your LINEARREGRESSION function and swap the resulting levels of the stack, you will obtain the same result.
We'll fix the missing doc asap.