load data[3089, 2] = lunwen\99201.txt;@讀入數據@
datr = data[2:3089, 2]:
@計算個數@
obv = (int((rows(datr)-1)/100)*100)+2;
print obv;
@通計算對數回報率@
datn = (ln(datr[2:obvl./datr[l:obv-1]));
obv = obv-1;
@計算AR(1)@
yi = datn[2:obv];
xi = datn[l:obv-1];
xi2 = xi^2;
ybar = meanc(yi);
xbar = meanc(xi);
xly = yi.*xi;
sxx = obv*sumc(xi2) - (sumc(xi))_2;
sxy = obv*(sumc(xly)) - sumc(xi)*sumc(yi):
slope = sxy/sxx; const = ybar-slope*xbar;
datx = datn[2:obv] - (const + slope*datn[l:obv-1]):
clear datn; obv = rows(datx);
@計算R/S值@
I = 4;
do while i<obv-1;
i = i+l; n = floor(obv/i); num = (obv/i):
if n<num:
goto repeat;
endif;
x1 = reshape(datx, n, i);
mu = meanc(xl);
xl = xl - mu;
sig = stdc (xl);
sum = cumsumc(xl);
max = maxc(sum); min = minc(sum):
r=max-min;
rs=r/sig;
a=log(meanc(rs)); b=log(i);
c=a^b^i;
c;repeat:endo;