function p = bicpic(z);
dz=z(2:end)-z(1:end-1);
bigt=length(dz);
y=dz(13:bigt);
x=ones(bigt-12,1);
for j=1:12; x=[x dz(13-j:bigt-j)]; end;
for j=1:13; 
    xx=double(x(:,1:j)); 
    bhat=inv(xx'*xx)*xx'*y;
    res=y-(xx*bhat);
    sigs=mean(res.^2);
    bigt=length(res);
    bic(j)=log(sigs)+(j*log(bigt)/bigt);
end;
[bicmin,p]=min(bic);
p=p-1;