/* Double Exponential Smoothing where parameter alpha is automatically chosen. */ /* (Forecast Smoothing) Criteria: MAPE */ new; cls; let data[12,1]= 23 25 36 31 26 28 48 36 31 42 53 43 ; t=seqa(1,1,rows(data)); library pgraph; graphset; _pltype=6; _plegctl=1; _plegstr="actual\000predicted"; title("Double Exponential Smoothing"); prec=0.01; xy(t,data~desMAPE(data,prec)); proc desMAPE(x,prec); local n,m,m2,e,i,j,alpha,alphastar,count,MAPE,MAPE_1; n=rows(x); MAPE_1=1e+8; count=1; j=1; do while j<=(1/prec); alpha=prec*(j-1); m=zeros(n,1); m[1]=x[1]; i=2; do while i<=n; m[i]=alpha*x[i-1]+(1-alpha)*m[i-1]; i=i+1; endo; m2=zeros(n,1); m2[1]=m[1]; i=2; do while i<=n; m2[i]=alpha*m[i-1]+(1-alpha)*m2[i-1]; i=i+1; endo; e=x[2:n]-(2*m[2:n]-m2[2:n]); MAPE=sumc(abs(e)./x[2:n]*100)/rows(e); if MAPE