Creating a loop in the Portsim

I'm working on a retirement portfolio problem. The code below essentially calculates 100 simulations of 15 years of portfolio returns for 126 different portfolio combinations. The output matrix is 15x126x100 in dimensions. What I am trying to do is to add a loop that calculates the results for different portfolio durations. I have to test the 126 portfolio combinations for 15,20,25,30,35 years but I am unable to loop that in. I keep getting an error regarding RetIntervals input in the Portsim code. Can someone help me with this?
NumObs = 15; %Duration of the portfolio
NumSim = 100; %Number of simulations
RetIntervals = 1;
NumAssets = 5; %Number of assets
rng('default');
RetExact = portsim(ExpRet, ExpCov, NumObs, ... RetIntervals, NumSim, 'Exact');
M = assetallocations(5,5); %Returns 126 combinations if weights of 5 assets
m = size(M,1);
for i=1:NumSim
for j = 1:m
PortRetComb(:,j,i) = RetExact(:,:,i)* M(j,:)'; %multiplies the simulated returns to each combination to get portfolio returns%
end
end

Antworten (0)

Kategorien

Mehr zu Portfolio Optimization and Asset Allocation finden Sie in Hilfe-Center und File Exchange

Gefragt:

sm
am 3 Sep. 2016

Bearbeitet:

sm
am 4 Sep. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by