With method 2, the problem is simply that the expression
y+0.5*y-0.5*lag(y)+e;
is to be understood as
y+(0.5*y-0.5*lag(y)+e);
which in the first iteration will set Y to 0 (the SUM statement, "Y+..." will initialize Y to 0, retain Y, and add whatever is after the plus sign, like
retain y 0;
y=sum(y,0.5*y-0.5*lag(y)+e);
But the second parameter evaluates to a missing value, meaning that Y stays 0 in the first iteration.
The method 1 calculation, on the other hand, is equivalent to
retain x 0;
x=sum(x,0.5*x,-0.5*lag(x),e);
which will set X to E on the first iteration.
In method 3, the problem is that you calculate Z before taking the LAG2 function the first two times, but after the LAG2 call the remaining times. Method 3 can be rewritten as e.g.
retain z;
lag2_z=lag(z);
if _n_=1 then z=e;
else if _n_=2 then z=1.5*z+e;
else z=1.5*z-0.5*lag2_z+e;
Note that I changed from LAG2 to LAG, as the LAG call now always comes first.
... View more