createLags function - Hows does it compute ?

1 view (last 30 days)
I'm currently trying to understand a matlab code of trend following. At some point, the code uses Matlab's "createLages" function. Can someone please explain me how this function works?
If I follow the official Matlab example, the function gives me:
x = [1 2 3 4; -1 -2 -3 -4]';
y = createLags(x, [-1 0 2]);
y =
2 -2 1 -1 NaN NaN
3 -3 2 -2 NaN NaN
4 -4 3 -3 1 -1
NaN NaN 4 -4 2 -2
For explanation, "Matlab-file-help" example says:
"predictorMatrix (outcome) is a numObs-by-numDim*numLags matrix of the shifted versions of the input matrix"
However, if I follow this approach I'd get something like
t = [(x-1) (x-0) (x+2)]
0 -2 1 -1 3 1
1 -3 2 -2 4 0
2 -4 3 -3 5 -1
3 -5 4 -4 6 -2
... which of course I can't multiply with x anymore..
Any advice greatly appreciated!
Best

Accepted Answer

Jan Morawietz
Jan Morawietz on 25 Nov 2014

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!