Undefined function or variable 'nearestSPD'.

조회 수: 2 (최근 30일)
SOO HEON KIM
SOO HEON KIM 2018년 1월 15일
답변: Sruthi Geetha 2018년 1월 24일
Hi, all! Below is a part of my code for optimization. But I got this error message:
Undefined function or variable 'nearestSPD'.
Error in Optimization__Engine_Multiple_Assets_Input_170204_flexible (line 66) covariances = nearestSPD(covariances_org);
I can't find the reason. Would someone please help me out?
Cheers,
----------------------------------- [rows columns]=size(num);
%Asset Returns, Volatility and Correlation
mu=num(:,1); sigma=num(:,2); rho_org=num(1:rows,6:columns); covariances_org = corr2cov(sigma,rho_org);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Validation: Check whether Covariance Matrix id positive semi-definite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Calculates nearest SPD-Variance-Covariance Matrix - Difference are typically minor covariances = nearestSPD(covariances_org);
%Calculates adjusted correlation matrix and [ExpSigma, ExpCorrC] = cov2corr(covariances); rho=ExpCorrC;
diffcov=covariances-covariances_org diffcor=rho-rho_org;

답변 (2개)

SOO HEON KIM
SOO HEON KIM 2018년 1월 18일
Can someone help me??

Sruthi Geetha
Sruthi Geetha 2018년 1월 24일
I don't see the variable 'nearestSPD' defined anywhere in the code.If you have defined it somewhere, please send that code snippet.

카테고리

Help CenterFile Exchange에서 Risk Management Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!