Yes! That was exactly what I was attempting. This solution works great! You should consider making it into a new function and publishing it as an independent file. Maybe instead of an input vector w, the input could be a string with different methods of weight generators. Anyway, thanks a lot again for your submission and your quick help!
I'm sorry. I messed up the input on my question. simsp500 and simcdax are both 6143x1 vectors, hence the input matrix [simsp500 simcdax]. The first time I tried the function, I also created a weights vector (6143x1) w, where all entries were 0.96. I would like to create a time series of the ewma correlation between this two simulated indexes with exponential smoothing of the weights for each of the 6143 periods of time. What I don't understand is if all the entries in the vector w are the same (0.96), will the function adjust and perform the smoothing automatically? Or should I program the vector w to already account for the smoothing by itself? In that case, should I use the exponential decay weights from one of the examples of the function? Is a weight vector where all entries are 0.94 useless? And finally, how could I achieve for the function to deliver a 3D matrix structure [2x2x6143] where every 2x2 matrix is the ewma correlation at each time period?
I hope the main question is clearer now. Thank you very much for your quick response! I really really appreciate the help!
This delivers only one matrix. I assume its the correlation at the last time period. A correlation matrix for each time period would be much more useful. I attempted to calculate this with the following:
I only get NaN. Could you lend some guidance to use your function to get the ewma correlation at each time period?