macro autoreg y x.1-x.p mconstant p ny i rho k se rhomin kmin mcolumn x.1-x.p y yl Yp xl.1-xl.p Xp.1-Xp.p sse crho let ny=n(y) let kmin=1 brief 0 do i=1:19 let rho=i/20 let crho(i)=rho let yl=y-rho*lag(y) do k=1:p let xl.k=x.k-rho*lag(x.k) enddo regr yl p xl.1-xl.p; mse se. let sse(i)=se*(ny-p-2) enddo plot sse*crho; symbol; Axis 1; label "Rho"; Axis 2; label "SSE". brief 2 let kmin=sum(((sse-lag(sse)) lt 0))+1 let rhomin=crho(kmin) print rhomin let Yp=y-rhomin*lag(y) do k=1:p let Xp.k=x.k-rhomin*lag(x.k) enddo note note This is the regression of Y(t)' on X(t)' regr Yp p Xp.1-Xp.p endmacro