The function eqwma
returns an Equally Weighted Moving Average (EqWMA) of the pth. exponentiated values lagged k
times (the default of k
is 1). Optionally, the absolute values are computed before averaging if abs=TRUE
, and the natural log of the values is returned if log=TRUE
. The function leqwma
is a wrapper to eqwma
with abs=TRUE
and log=TRUE
.
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.
eqwma(x, length=5, k=1, p=1, abs=FALSE, log=FALSE, as.vector=FALSE,
lag=NULL, start=NULL)
leqwma(x, length=5, k=1, p=2, as.vector=FALSE, lag=NULL, start=NULL)
numeric matrix, vector or zoo
object
numeric vector, time-series or zoo
object
integer or vector of integers each equal to or greater than 1. The length or lengths of the moving window or windows of averages
integer that determines how many periods the term(s) should be lagged. If 0 (or smaller), then the moving averages are not lagged
numeric value. The exponent p in x^p when abs=FALSE
, and in abs(x)^p when abs=TRUE
logical with default FALSE
. If TRUE
, then the logarithm of the moving average is returned
logical with default FALSE
. If TRUE
, then x is transformed to absolute values before x is exponentiated
logical with default FALSE
. If TRUE
, and if length(length)==1
, then the result is returned as a vector. Otherwise the returned value is always a matrix
deprecated
deprecated
Genaro Sucarrat, https://www.sucarrat.net/
The intended primary use of eqwma
is to construct mixed frequency regressors for the mean specification of an arx
model.
The intended primary use of leqwma
is to construct volatility proxies for the log-variance specification in an arx
model. In the latter case, 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).
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
Pretis, Felix, Reade, James and Sucarrat, Genaro (2018): 'Automated General-to-Specific (GETS) Regression Modeling and Indicator Saturation for Outliers and Structural Breaks'. Journal of Statistical Software 86, Number 3, pp. 1-44
zoo
, arx
, getsm
, getsv
##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