/* Brown's one-Prameter quadratric */ new; cls; let data[12,1]= 23 25 36 31 26 28 48 36 31 42 53 43 ; nahead=10; t=seqa(1,1,rows(data)+nahead); library pgraph; graphset; _pltype=6; _plegctl=1; _plegstr="actual\000predicted"; title("QUAD"); alpha=0.2; xy(t,(data|miss(zeros(nahead,1),0))~quad(data,alpha,nahead)); proc quad(x,alpha,nahead); local n,m1,m2,m3,m,mp,i,b,c,t; n=rows(x); m1=zeros(n,1); m1[1]=x[1]; i=2; do while i<=n; m1[i]=alpha*x[i-1]+(1-alpha)*m1[i-1]; i=i+1; endo; m2=zeros(n,1); m2[1]=m1[1]; i=2; do while i<=n; m2[i]=alpha*m1[i-1]+(1-alpha)*m2[i-1]; i=i+1; endo; m3=zeros(n,1); m3[1]=m2[1]; i=2; do while i<=n; m3[i]=alpha*m2[i-1]+(1-alpha)*m3[i-1]; i=i+1; endo; m=3*m1-3*m2+m3; b=alpha^2/(2*(1-alpha)^2)*((6-5*alpha)*m1[n]-(10-8*alpha)*m2[n]+(4-3*alpha)*m3[n]); c=alpha^2/((1-alpha)^2)*(m1[n]-2*m2[n]+m3[n]); t=seqa(0,1,nahead+1); mp=miss(zeros(n-1,1),0)|m[n]+0.5*b*t+c*t^2; m=m|miss(zeros(nahead,1),0); retp(m~mp); endp;