Learn R Programming

AutoSEARCH (version 1.01)

ewma: Equally Weighted Moving Average (EWMA) of the pth. exponentiated residuals

Description

Returns an Equally Weighted Moving Average (EWMA) of the pth. exponentiated residuals lagged. As a volatility model, this is also know as the 'historical' model or as an integrated ARCH model where the ARCH coefficients all have the same value with sum equal to one. In the log-volatility specification the lag of EWMA is used as a volatility proxy. Admittedly, it is an imperfect volatility proxy compared with high-frequency data (which can be included as regressors anyway in the log-volatility specification). However, it is always available and easy to compute

Usage

ewma(x, length=20, lag=1, start=1, p=2)

Arguments

x
numeric vector, time-series or zoo object. Note that missing values in the beginning or at the end of the series is allowed, as they are removed with the na.trim command from the zoo package
length
integer equal to or greater than 1. The length of the moving window of averages. Default: length=20
lag
integer equal to or greater than 0. If 0, then the moving average is not lagged. Default: lag=1
start
integer equal to or greater than 1. Where to start the moving window of averages. Default: start=1 (the first observation)
p
numeric greater than zero. The exponent or p in abs(x)^p. Default: p=2

Value

  • ewmanumeric vector, time series or zoo object (depending on the properties of x, the input) containing the values of the moving average

Details

As a volatility model, the lag of an equally weighted moving average of the squared residuals where each average is made up of m observations, is equivalent to an integrated ARCH(m) model where all the m ARCH-coefficients are equal. For the properties of integrated ARCH models, see Engle and Bollerslev (1986). For further details on the use of log(EWMA) as a volatility proxy, see Sucarrat and Escribano (2011)

See Also

sm, gets.mean, gets.vol

Examples

Run this code
#Generate an iid normal series:
set.seed(123)
x <- rnorm(200)

#compute lag of EWMA(20) of x^2:
ewma(x)

#compute lag of EWMA(30) of abs(x)^1:
ewma(x, length=30, p=1)

Run the code above in your browser using DataLab