/* MA(q) */ new; cls; theta={0.5,-0.3,0.2,-0.1}; s2=0.1; n=1000; x=masim(theta,s2,n); library pgraph; graphset; title("MA(q)"); t=seqa(1,1,n); xy(t,x); proc masim(theta,s2,n); local cutn,q,e,x,t; cutn=100; /* first some data to cut off */ q=rows(theta); print/lz "q=" rows(theta); e=rndn(cutn+n,1)*sqrt(s2); x=zeros(cutn+n,1); t=q+1; do while t<=cutn+n; x[t]=e[t]+rev(-theta)'e[t-q:t-1]; t=t+1; endo; x=x[cutn+1:cutn+n]; retp(x); endp;