createLags function - Hows does it compute ?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!