Error SIGMA must be a symmetric positive semi-definite matrix

5 ビュー (過去 30 日間)
Shakib Ishfaq
Shakib Ishfaq 2019 年 7 月 17 日
コメント済み: Shakib Ishfaq 2019 年 7 月 20 日
So I'm calculating CVAR of a portfolio of conventional bonds and Sukuk. I'm trying to simulate asset scenarios, using the Normal/Gaussian and Emprical (T) method.
My dataset, contains assets with varying starting dates, and therefore my dataset contains a number of zeros. When I run the code, I am running into this error.
This is my current code:
clear;
close all;
rng(0);
T = readtable('pak.xlsx');
symbol = {'PAK2014BOND','PAK2015BOND','PAKSUKUK2014'};
nAsset = numel(symbol);
ret = tick2ret(T{:,symbol});
plotAssetHist(symbol,ret)
nScenario = 2000;
simulationMethod = 'Normal';
switch simulationMethod
case 'Normal'
AssetScenarios = mvnrnd(mean(ret),cov(ret),nScenario);
case 'Empirical'
AssetScenarios = simEmpirical(ret,nScenario);
end
When I have zeros in my data, I'm getting this error.
Can someone please shed some light, on how I can overcome this?
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 7 月 17 日
Is your ret matrix all zeros or only partly zero?
Shakib Ishfaq
Shakib Ishfaq 2019 年 7 月 20 日
Partly zero. Start dates/years differ.

サインインしてコメントする。

回答 (1 件)

the cyclist
the cyclist 2019 年 7 月 18 日
This issue will arise when you get pairwise asset correlations that are inconsistent. (The zeros are not necessarily the problem.)
For example, suppose you have the following data (possibly from different sources):
  • Asset 1 and Asset 2 have a correlation coefficient of 0.9
  • Asset 1 and Asset 3 have a correlation coefficient of 0.9
  • Asset 2 and Asset 3 have a correlation coefficient of -0.3
Now, these can't all be true, because they are mutually contradictory. (Such a strong positive correlation between 1&2 and 1&3 means that 2&3 must be positively correlated.) Maybe the measurements were taken over different periods of time, or using different methodologies.
If you try to use that correlation matrix, you'll get the "must be symmetric positive semi-definite matrix" error. You need to figure out how to fix your correlation matrix.
  2 件のコメント
Shakib Ishfaq
Shakib Ishfaq 2019 年 7 月 18 日
I thought this also, but then when I generate number in place of the zeros, my code works fine. Also, when I try different datasets.
the cyclist
the cyclist 2019 年 7 月 18 日
OK. But often very small (close to -- or equal to -- 0) and very high (close to -- or equal to -- 1) are exactly the correlations that cause the problem I am talking about. They are matrix entries that cause inconsistencies with other entries.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePortfolio Optimization and Asset Allocation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by