Hello everybody,
I tried to build my first gretl function with no much sucess. The exercise is
very simple: write a function to obtain the theoretical simple correlations
for an AR(2) process, depending only on two parameters phi1 and phi2.
The following script works ok:
---------------
nulldata 20
series y = 1.0
scalar phi1 = 0.4
scalar phi2 = 0.5
scalar rho1 = phi1 / (1-phi2)
genr y[2] = rho1
genr y = phi1*y(-1)+phi2*y(-2)
genr y1 = y(1)
------------
So the series y1 contains the theoretical correlations.
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?
I tried it with official gretl-1.5.0 in mandrivalinux, and also with the
current Windows snapshot. There were no errors or warnings and I obtained
only a series with zeroes.
--
Ignacio Díaz-Emparanza
Dpto. de Economía Aplicada III (Econometría y Estadística)
UPV-EHU