help movavg
-------------------------------------------------------------------------------

Title

movavg -- MATA based Moving Average generator

Syntax

movavg newvar =varname [if] [, lags(#) replace]

by is allowed for 1 varname.

options Description ------------------------------------------------------------------------- lags(#) Number of time periods (observations) to be considered in the window. replace Same behavior as in generate. -------------------------------------------------------------------------

Description

movavg performs high speed Moving Average calculation using MATA base computations.

In the case of "by", efficiency gains are very high, in terms of computation speed, as a contrast of loop based algorithms as this implementations uses matrix algebra instead.

Examples

Setup . sysuse auto . sort rep78

Computes the moving average of price over a 3 period window . movavg ma3lags = price, lags(3)

Computes the moving average of price by rep78 over a 3 period window . by rep78: movavg ma3lags_by = price, lags(3)

Author

George Vega Yon, Superindentencia de Pensiones. mailto:gvega@spensiones.cl