I'm trying to perform logical operation through if-then statement but since my matrix has some value sas zero it fails to perform the operation correctly Start M_1(y);
p=13;
outarray_M=j(nrow(y),ncol(y),.);
outarray_01=j(nrow(y),ncol(y),.);
do i=14 to (nrow(y)-1);
idx= max(2,i-p+1):i;
unit= mad(y[idx,],"nmad");
outarray_M[i,]=unit;
if all(outarray_M[i,] ^= 0) then outarray_01[i+1,] = abs((y[i+1,]-median(y[idx,])))/mad(y[idx,],"nmad");
else outarray_01[i+1,]= choose(y[i+1,] =0, 0, 9999);
end;
return(outarray_01);
finish;
... View more