createLags function - Hows does it compute ?
조회 수: 3 (최근 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!