Calculate 10y returns out of monthly data
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Markus
am 23 Okt. 2014
Bearbeitet: Andrei Bobrov
am 24 Okt. 2014
hey guys,
i have monthly returns (1mil. simulations). Now i want to calculate corresponding 10 year returns. for example vextor x: 0.05 0.02 0.03 0.4 -0.21 ...
what matlab should do now is to calculate: ((1+r(1))*(1+r(2))*...(1+r(120)))-1 and ((1+r(121))*(1+r(122))*...(1+r(240)))-1 and so on...
thx for your help
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 24 Okt. 2014
Bearbeitet: Andrei Bobrov
am 24 Okt. 2014
out = prod(1 + reshape(x,120,[])) - 1;
or
out = accumarray(ceil((1:numel(x))'/120),x(:),[],@(x)prod(1+x)-1);
0 Kommentare
Weitere Antworten (1)
Roger Wohlwend
am 24 Okt. 2014
y = exp(filter(ones(120,1),1,log(1+r)))-1;
y = y(120:end);
2 Kommentare
Roger Wohlwend
am 24 Okt. 2014
Oh, my mistake.
y = exp(filter(ones(120,1),1,log(1+r)))-1;
y = y(120:120:end);
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!