I have no experience with the cadf function. But it seems that the value of tmp.adf is not the one you need. Check the cadf function and see how to get the results of a cointegration test. Test it outside a loop for difference prices. The loop itself looks alright to me.
problem for loop matrix
1 次查看(过去 30 天)
显示 更早的评论
this is my code:
n=size(prices,2);
M_coint=zeros(n,n);
for i=1:n;
j=1:n;
tmp=cadf(prices(:,i),prices(:,j),0,1)
M_coint(i,j)=tmp.adf
end
but obtain a nxn matrix in which I have the same value in each row.
I have a matrix, in which in the each columns I have the single stocks, and in the row the time serie price. For example
IBM JPM C
p11 p12 p13
p21 p22 p23
...........
pn1 pn2 pn3
I want obtain a output as a var-cov matrix, but in place of the covariance the score of cointegration test, as the following table.
ibm jpm c
ibm - -3.2 -4.2
jpm -1.2 - -2.1
c -2.3 -4.3 -
I can not generate a code suitable to my needs
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!