function f = arforc(z,p,h);
dz=z(2:end)-z(1:end-1);
bigt=length(dz);
y=dz(p+1:bigt);
x=ones(bigt-p,1);
for j=1:p; x=[x dz(p+1-j:bigt-j)]; end;
bhat=inv(x'*x)*x'*y;
for j=1:h; 
    fy=[1;flipud(y(end-p+1:end))]'*bhat;
    y=[y;fy];
end;
f=sum(y(end-h+1:end));