Error when optimizing PortfolioCVaR Object based on Simulated Returns

조회 수: 2 (최근 30일)
Carolin Brueckmann
Carolin Brueckmann 2015년 5월 17일
답변: Sharon He 2018년 12월 17일
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
Simone
Simone 2015년 10월 23일
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!

댓글을 달려면 로그인하십시오.

답변 (1개)

Sharon He
Sharon He 2018년 12월 17일
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

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by