Error when optimizing PortfolioCVaR Object based on Simulated Returns

1 view (last 30 days)
I'm trying to optimize a PortfolioCVaR object based on simulated return data that comes in the form of a 12x10x19 matrix (i.e. 19 return series simulated 10 different asset paths over a horizon of 12 months). The optimization code looks like this:
pmc = PortfolioCVaR; pmc = pmc.setAssetList(IndexList); % select index names pmc = pmc.setScenarios(Z); % select return series pmc = pmc.setProbabilityLevel(0.95); % cVaR confidence level pmc = pmc.setDefaultConstraints; % Constraint 1: only positive weights that sum to 1 pmc = pmc.setBounds(0.01, 0.1); % Constraint 2: min/max weights However, I obtain the folowing error:
Error using PortfolioCVaR/setScenarios (line 93) AssetScenarios must be a matrix with either finite or NaN values. The simulated return variable Z is calculated based on the following code:
%% 4.5 Monte Carlo Simulation
s = RandStream.getGlobalStream(); reset(s)
nTrials = 10; % # of independent random trials horizon = 12; % VaR forecast horizon
Z = zeros(horizon, nTrials, nIndices); % standardized residuals array U = copularnd('t', R, DoF, horizon * nTrials); % t copula simulation
for j = 1:nIndices Z(:,:,j) = reshape(icdf(tails{j}, U(:,j)), horizon, nTrials); end Does anyone have a suggestions on how to overcome this error?
Thanks a lot! Carolin
  1 Comment
Simone
Simone on 23 Oct 2015
Dear Carolin I have exactly the same issue and haven't figured it out. Do you found a solution to include the simulated return series? Thanks!

Sign in to comment.

Answers (1)

Sharon He
Sharon He on 17 Dec 2018
Hi Carolin,
The error is thrown from the command pmc = pmc.setScenarios(Z). This is because Z in your code is a 3-dimensional matrix (it is in the form of 12x10x19), but the input to the function setScenarios can only be a 2-dimensional matrix. In my understanding, with the matrix Z you provided, you have 19 assets, 10 scenarios for each of them in each month. So essentially, you have 19 assets and 120 scenarios (10x12). To get around the issue, try the following code:
Z = reshape(Z,120,19); % the new variable Z has 120 rows and 19 columns; each row is a scenario for the 19 assets;
Then execute the rest of your workflow for PortfolioCVaR. It should not throw the error. Let me know if you have other questions.
Thanks,
Sharon

Categories

Find more on Portfolio Optimization and Asset Allocation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!