/* Percent Difference Smoothing(another version) */ /* (Forecast Smoothing) Criteria: MSE */ 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("Percent Difference Smoothing"); nperiod=4; xy(t,data~pdiff2MAD(data)); proc pdiff2MAD(x); local n,m,e,i,j,nperiod,nperiodstar,MAD,MAD_1; n=rows(x); MAD_1=1e+8; j=1; do while j<=floor((n-1)/2); nperiod=j; m=zeros(n,1); i=nperiod*2+1; do while i<=n; m[i]=x[i-nperiod]*(x[i-nperiod]/x[i-nperiod*2]); i=i+1; endo; e=x[nperiod*2+1:n]-m[nperiod*2+1:n]; MAD=sumc(abs(e))/rows(e); if MAD