[Gretl-users] Exponential moving average

Sven Schreiber svetosch at gmx.net
Tue Jul 25 10:00:53 EDT 2006


Johannes Fichtinger schrieb:
> Hi all,
> first of all thank you for this powerful und useful piece of software, its 
> great!
> 
> Now I have a little question: I have a time series variable p and want to 
> creat a new variable called r with the exponential moving average of p, so
> r = \alpha*r_{t-1}+(1-\alpha)*p_{t-1}.
> 
> Any idea how to create this r? Thanks a lot.

This script is actually tested in teaching, and since you seem to speak
German...:

#Statt "Variablenname" gewünschte Variable eintragen, und alpha
raw = colgpa
scalar alpha = 0.9
#Ende Benutzereingabe

series forecast=mean(raw)
forecast = alpha * forecast(-1) + (1-alpha)*raw
delete raw
delete alpha




More information about the Gretl-users mailing list