Learn R Programming

AutoSEARCH (version 1.5)

eqwma: Equally Weighted Moving Average (EqWMA) of the pth. exponentiated values

Description

The function eqwma returns an Equally Weighted Moving Average (EqWMA) of the pth. exponentiated values lagged. Optionally, the absolute values are computed before averaging, and the log of is returned. The function leqwma is essentially a wrapper to eqwma in which the absolute values are used and the logarithm is applied.

If x is financial return (possibly mean-corrected) and p=2, then this gives the socalled 'historical' model, also known as an integrated ARCH model where the ARCH coefficients all have the same value with sum equal to one. In the log-variance specification the lag of log(EqWMA) is thus a financial volatility proxy. It may be an imperfect proxy compared with high-frequency data (which can also be included as regressors), but - in contrast to high-frequency data - is always available and easy to compute

Usage

eqwma(x, length = 5, lag = 1, start = 1, p = 1, log = FALSE, abs = FALSE, as.vector = TRUE) leqwma(x, length = 5, lag = 1, start = 1, p = 2, as.vector=FALSE)

Arguments

x
numeric vector, time-series or zoo object. Missing values in the beginning and/or at the end of the series is allowed, as they are removed with the na.trim command
length
integer or vector of integers each equal to or greater than 1. The length or lengths of the moving window or windows of averages
lag
integer equal to or greater than 0. If 0, then the moving averages are not lagged
start
integer equal to or greater than 1 (default: start=1, i.e. the first observation). Where to start the moving windows of averages
p
numeric value greater than zero. The exponent p in x^p for eqwma and in abs(x)^p for leqwma
log
logical. If TRUE, then the logarithm of the moving average is returned. If FALSE (default), then the logarithm is not applied
abs
logical. If TRUE, then x is transformed to absolute values before x is exponentiated
as.vector
logical. If TRUE, then a univariate series is returned as a vector. If FALSE, then a univariate series is returnes as a matrix. Note: multivariate series are always returned as a matrix

Value

zoo object

Details

The intended primary use of eqwma is to construct mixed frequency regressors for the mean specification.

The intended primary use of leqwma is to construct volatility proxies in for the log-variance specification. The default is the lagged log of an equally weighted moving average of the squared residuals, where each average is made up of m observations. This is equivalent to an integrated ARCH(p) model where the p coefficients are all equal. For further details on the use of log(EqWMA) as a volatility proxy, see Sucarrat and Escribano (2012)

References

Genaro Sucarrat and Alvaro Escribano (2012): 'Automated Financial Model Selection: General-to-Specific Modelling of the Mean and Volatility Specifications', Oxford Bulletin of Economics and Statistics 74, Issue no. 5 (October), pp. 716-735

See Also

zoo, sm, gets.mean, gets.vol

Examples

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

##compute lag of EqWMA(20) for x^2:
eqwma(x, p=2)

##compute lag of EqWMA(5) and lag of EqWMA(10) for x:
eqwma(x, length=c(5,10))

##compute lag of log(EqWMA(20)) for x^2:
leqwma(x)

#compute lag of log(EqWMA(5)) and lag of log(EqWMA(8))
#for abs(x)^2:
leqwma(x, length=c(4,8))

Run the code above in your browser using DataLab