Azzera filtri
Azzera filtri

problem for loop matrix

3 visualizzazioni (ultimi 30 giorni)
fede
fede il 22 Set 2015
Risposto: Thorsten il 22 Set 2015
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

Risposte (1)

Thorsten
Thorsten il 22 Set 2015
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.

Community Treasure Hunt

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

Start Hunting!

Translated by