On Thu, 8 Nov 2018, oleg_komashko(a)ukr.net wrote:
> it is the angle of the root
The matter is in that it is a
function of the angle
I have failed to guess what
the function it is. That's why
Hansl code to replicate what gretl prints for the modulus and
frequency of ARMA roots.
<hansl>
function scalar atan2 (scalar y, scalar x)
if x > 0
ret = atan(y/x)
elif x < 0 && y >= 0
ret = atan(y/x) + $pi
elif x < 0 && y < 0
ret = atan(y/x) - $pi
elif x == 0 && y > 0
ret = $pi/2
elif x == 0 && y < 0
ret = -$pi/2
else
ret = NA
endif
return ret
end function
open <your data>
arma <your specification>
matrix R = $model.roots
loop i=1..rows(R) -q
re = R[i,1]
im = R[i,2]
if im == 0
mod = abs(re)
else
mod = sqrt(re*re + im*im)
endif
frq = atan2(im, re) / (2*$pi)
printf "%10.4f %10.4f %10.4f %10.4f\n", re, im, mod, frq
endloop
</hansl>
Maybe we should offer atan2 as a built-in function?
Allin