On Wed, 8 Feb 2006, Ignacio Díaz-Emparanza wrote:
I wrote the following script, based on the information of the
manual, but the function does not work:
nulldata 20
# function definition
function corrAR2 (scalar phi1, scalar phi2)
series y = 1.0
scalar rho1 = phi1 / (1-phi2)
genr y[2] = rho1
genr y = phi1*y(-1)+phi2*y(-2)
genr y2 = y(1)
return series y2
end function
# function call
(y1) = corrAR2 0.4 0.5
Which is the problem?
Sorry, this was a numeric locale bug. The parameters to your
function were being read as 0 and 0, when running in a locale that
uses ',' as decimal separator. I have now fixed this in CVS.
A workaround is to define the parameters as scalar variables:
# function call
scalar arg1 = 0.4
scalar arg2 = 0.5
(y1) = corrAR2 arg1 arg2
But this workaround will not be necessary with the CVS fix.
Allin.