View source: R/gets-base-source.R
eqwma | R Documentation |
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)
x |
numeric vector, time-series or |
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 |
k |
integer that determines how many periods the term(s) should be lagged. If 0 (or smaller), then the moving averages are not lagged |
p |
numeric value. The exponent p in x^p when |
log |
logical with default |
abs |
logical with default |
as.vector |
logical with default |
lag |
deprecated |
start |
deprecated |
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).
numeric matrix, vector or zoo
object
Genaro Sucarrat, https://www.sucarrat.net/
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.