Description Usage Arguments Details Value Author(s) Examples
EWMA model to estimate volatility, covariance, and correlation
1 2 |
R |
xts object of asset returns |
lambda |
smoothing parameter, must be greater than 0 or less than 1. If NULL, lambda will be estimated by minimizing the mean squared error between the estimated value and the realized value. |
initialWindow |
initial window of observations used in estimating the initial conditions |
n |
number of periods used to calculate realized volatility, covariance, or correlation. |
type |
estimate volatility, covariance, or correlation. |
If lambda=NULL, the lambda value can be estimated for univariate estimates of volatility, covariance, and correlation by minimizing the mean squared error between the estimated value and realized value.
an EWMA object with the following elements
estimate
EWMA model estimated statistic
model
list with model parameters
data
list with original returns data and realized statistic if applicable
Ross Bennett and Thomas Fillebeen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # data and parameters for EWMA estimate
data(crsp_weekly)
R <- largecap_weekly[, 1:2]
mvR <- largecap_weekly[,1:4]
lambda <- 0.94
initialWindow <- 150
# volatility estimate of univariate data
lambda <- estimateLambdaVol(R[,1], initialWindow, n=10)
vol1 <- EWMA(R[,1], lambda=NULL, initialWindow, n=10, "volatility")
vol1a <- EWMA(R[,1], lambda, initialWindow, n=10, "volatility")
all.equal(vol1$estimate, vol1a$estimate)
vol1
# covariance estimate of bivariate data
lambda <- estimateLambdaCov(R, initialWindow, n=10)
cov1 <- EWMA(R, lambda=NULL, initialWindow, n=10, "covariance")
cov1a <- EWMA(R, lambda, initialWindow, n=10, "covariance")
all.equal(cov1$estimate, cov1a$estimate)
cov1
# correlation estimate of bivariate data
lambda <- estimateLambdaCor(R, initialWindow, n=10)
cor1 <- EWMA(R, lambda=NULL, initialWindow, n=10, "correlation")
cor1a <- EWMA(R, lambda, initialWindow, n=10, "correlation")
all.equal(cor1$estimate, cor1a$estimate)
cor1
# Multivariate EWMA estimate of covariance
lambda <- 0.94
cov_mv <- EWMA(mvR, lambda, initialWindow, type="covariance")
cov_mv
# Multivariate EWMA estimate of correlation
cor_mv <- EWMA(mvR, lambda, initialWindow, type="correlation")
cor_mv
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.