function f = arforcd(z,p,h);
%Version with dummies
dz=z(2:end)-z(1:end-1);
bigt=length(dz);
y=dz(p+1:bigt);
x=ones(bigt-p,1);
for i=1:11;
    o1=zeros(12,1); o1(i)=1; o2=kron(ones(60,1),o1); x(:,i+1)=o2(p+1:bigt); xf(:,i)=o2(bigt+1:bigt+12);
end;
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 xf(j,:) flipud(y(end-p+1:end))']*bhat;
    y=[y;fy];
end;
f=sum(y(end-h+1:end));
    
