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

Title

movavg-- MATA based Moving Average generator

Syntax

movavgnewvar=varname[if] [,lags(#)replace]

byis allowed for 1 varname.

optionsDescription -------------------------------------------------------------------------lags(#)Number of time periods (observations) to be considered in the window.replaceSame behavior as ingenerate. -------------------------------------------------------------------------

Description

movavgperforms 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.

ExamplesSetup

. sysuse auto. sort rep78Computes the moving average of

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

pricebyrep78over a 3 period window. by rep78: movavg ma3lags_by = price, lags(3)

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