Error using mvregress : Covariance is not positive-definite. AND Error in varm/estimate : sigma(solve,solve), logL] = mvregress(D, R, 'covtype' , 'full' , 'varformat', 'beta' , ...
5 次查看(过去 30 天)
显示 更早的评论
Hello there
I am trying to calculate the betas and alphas from the CAPM model, for 62 stocks, using a var model but i get this error message. I tested the model for less stocks and i found out that it works for 32 or less. I tried to exclude the 32th or 33th stock but it didnt make any differance. i also checked if there are any negative values at the cov matrix but there were not. Any suggestions?
X = GSPC-rf;
[T,n] = size(Y1); %Y1(36x62) = matrix with monthly returns of 62 stocks for 36 months
Mdl = varm(n,0);
[EstMdl,EstCoeffSEMdl] = estimate(Mdl,Y1,'X',X);
results = summarize(EstMdl);
% looking at variance - covariance matrix
R = cov(Y1);
len=length(R);
for i=1:len
if R(i,i)<0
disp(i)
end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Atomic, Molecular & Optical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!