Partition function in Matlab - is there something missing in my code? -
can see if there wrong in matlab code? objective replicate formula:
q can take value 1,2,3 , 5. constructed vector xt each element cumulative sum of log(1+return) @ each time (t) - stock returns - first element normalized log(1).
then compute each element sq(t,delta t) 4 values of q matlab code:
for j=1:length(dt); e=xt(1:dt(j):end); ee=diff(e(2:end)); eee=diff(e(1:end-1)); sqone(j)=sum(abs(ee-eee).^1); sqtwo(j)=sum(abs(ee-eee).^2); sqthree(j)=sum(abs(ee-eee).^3); sqfive(j)=sum(abs(ee-eee).^5); end; is there wrong in code above? asking because know there wrong since not getting expected results. convinced due code posted above.
the vector dt vector goes 1 high number - depending on size of xt. vector dt not problem.
thank help!
you taking difference twice. once using diff , once using ee-eee. correct code is:
for j=1:length(dt); e=xt(1:dt(j):end); ee=abs(diff(e)); sqone(j)=sum(ee.^1); sqtwo(j)=sum(ee.^2); sqthree(j)=sum(ee.^3); sqfive(j)=sum(ee.^5); end;
Comments
Post a Comment