/* Single Exponential Smoothing */ /* (n periods ahead: flat) */ new; cls; let data[12,1]= 23 25 36 31 26 28 48 36 31 42 53 43 ; nahead=4; t=seqa(1,1,rows(data)+nahead); library pgraph; graphset; _pltype=6; _plegctl=1; _plegstr="actual\000predicted\000n ahead"; title("Single Exponential"); alpha=0.5; xy(t,(data|miss(zeros(nahead,1),0))~sesf(data,alpha,nahead)); proc sesf(x,alpha,nahead); local n,m,mp,i; n=rows(x); 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; mp=miss(zeros(n-1,1),0)|m[n]*ones(nahead+1,1); m=m|miss(zeros(nahead,1),0); retp(m~mp); endp;