Learn R Programming

gets (version 0.1)

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

Description

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. 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)
leqwma(x, length = 5, 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 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, then the logarithm is not applied
abs
logical. If TRUE, then x is transformed to absolute values before averages are computed

Value

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

Details

The intended primary use of eqwma is to construct socalled 'mixed frequency regressors' for the mean specification. The intended primary use of leqwma is to construct socalled volatility proxies in logarithms for inclusion in 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(m) model where all the m ARCH-coefficients are equal. For further details on the use of log(EqWMA) as a volatility proxy, see Sucarrat and Escribano (2012)

See Also

zoo, arx, getsm, getsv

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