El vie, 12-02-2010 a las 12:47 -0500, Allin Cottrell escribió:
On Fri, 12 Feb 2010, Ignacio Diaz-Emparanza wrote:
> I am teaching on these days a very basic course on forecasting.
> A part of the course is about smoothing models so I was looking at
> exponential smoothing and today I was also preparing a script about the
> Brown models for linear and quadratic local trends.
>
> I would like to report some small problems I found:
>
> 1- The exponential moving average exist only at the GUI but there is not
> an equivalent command script for that. I had to prepare a user function.
Yes, we should probably add a built-in function for that -- or
maybe extend the current movavg function to accept a fractional
second argument to produce an EMA?
Yes, I expected this second alternative.
> 2- When I finished to prepare a first version of this function I noticed
> that it only worked for quarterly data ( I suppose monthly as well ) but
> not for annual data. The problem was about the different behaviour of
> the 'obs' function with annual data (I saw this in the manual for
> 'genr'). If you use, for example,
>
> series s1 = (obs=1) ? y[1] : delta*y+ (1-delta)*s1(-1)
>
> this will work for quarterly or monthly data, but not in the same way
> for annual data. Finally I found a solution, but it implied that my
> script grew up in 10 lines!
>
> Don't you think that 'obs' should work in the same way, idependently of
> the value of $pd?
Hmm, what does the dataset look like? The following works
correctly here:
<script>
open data3-6
series y = Ct
series s1 = y[1]
scalar d = 0.5
s1 = (obs=1) ? y[1] : d*y+ (1-d)*s1(-1)
print y s1 -o
</script>
Oh! you got it by accident. Try this other initial value for s1:
<script>
open data3-6
series y = Ct
series s1 = 0
scalar d = 0.5
s1 = (obs=1) ? y[1] : d*y+ (1-d)*s1(-1)
print y s1 -o
</script>
> 3- Finally I saved my Brown function as a function package ( I
> uploaded it to the server as well), but I see another small
> problem: my main function returns a list and if one wants the
> package to work ok this list is mandatory, but the dialog box
> says "Assign return value (optional)". ¿is there any way to
> change this to 'required'?
What happens if the user doesn't assign the return value?
I suppose internally gretl makes the calculus, but the user obtains
nothing.
I suppose there may be many functions that don't do anything
useful (or even visible) if the return value is not assigned,
while others might print something of interest. Perhaps we should
add a field in the function package definition that indicates
whether or not there's any point in running the function without
assignment.
Yes, this is a possibility.
--
Ignacio Diaz-Emparanza
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)
UPV/EHU
Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.ea3.ehu.es