createLags function - Hows does it compute ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jan Morawietz
le 25 Nov 2014
Réponse apportée : Jan Morawietz
le 25 Nov 2014
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 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!