Hello
I am working on a number of price series (daily returns) and need to calculate the 90 day standard deviations and correlation with another price series. I have written this code with a for loop to calculate the standard deviation
window = 90;
T = size(Aseries,1);
condstdAseries = zeros(T-window+1,1);
for t = 1:1:T-window+1;
condstdAseries(t,1) = std(Aseries(t:t+window-1,1));
end
datecondste = ddatenumbers(window:end);
But have not managed to work out a similar solution, guess it should be a matter only to add another line of code to solve it but no success so far.
Any suggestion?

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 13 de Jul. de 2017
Editada: Andrei Bobrov el 13 de Jul. de 2017

0 votos

Use function movstd if you have MATLAB R2016a or later.
rst = movstd(Aseries(:,1),[0 window]);
condstdAseries = rst(1:end - window + 1);

1 comentario

Salvatore Miserendino
Salvatore Miserendino el 16 de Jul. de 2017
Thank you Andrei. This makes the calculation of the moving standard deviation definately easier but any idea on how to calculate the moving correlation?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by