High frequency large time-series matrix: Split in months
Mostrar comentarios más antiguos
Hi! I have a dataset of about 3000 samples with each having about 2 years of daily return data. Now I want to calculate monthly Sharpe Ratios, i.e. as far as I understood I need 24 matrices with monthly data.
Now: How can I have the matrix split in months considering that every month has a different amount of days (i.e. each new small matrix will have different size)?
Additionally: Would it be somehow possible to filter the small matrices even further, i.e. include only specific datasets out of the total amount of samples? I am thinking somehow using another matrix "samples"x"months" indicating 1 or 0 for being included or not.
THank you for every hint on either the first or the second or both of my questions!
Respuesta aceptada
Más respuestas (1)
Andrei Bobrov
el 14 de Sept. de 2012
data = randi(456,800,15); % 15 samples and 800 daily data for example.
datainitial = '2009-07-13';
[y,m,d] = datevec(datainitial);
[y2,m2] = datevec(datenum(y,m,(d:d+size(data,1)-1)'));
[c,c,c] = unique([y2,m2],'rows');
[i1,i2] = ndgrid(c,1:size(data,2));
out = accumarray([i1(:),i2(:)],data(:),[],@(x){x});
Categorías
Más información sobre Time Series en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!