Learn R Programming

PerformanceAnalytics (version 2.0.4)

EWMAMoments: Functions for calculating EWMA comoments of financial time series

Description

calculates exponentially weighted moving average covariance, coskewness and cokurtosis matrices

Usage

M2.ewma(R, lambda = 0.97, last.M2 = NULL, ...)

M3.ewma(R, lambda = 0.97, last.M3 = NULL, as.mat = TRUE, ...)

M4.ewma(R, lambda = 0.97, last.M4 = NULL, as.mat = TRUE, ...)

Arguments

R

an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns (with mean zero)

lambda

decay coefficient

last.M2

last estimated covariance matrix before the observed returns R

any other passthru parameters

last.M3

last estimated coskewness matrix before the observed returns R

as.mat

TRUE/FALSE whether to return the full moment matrix or only the vector with the unique elements (the latter is advised for speed), default TRUE

last.M4

last estimated cokurtosis matrix before the observed returns R

Details

The coskewness and cokurtosis matrices are defined as the matrices of dimension p x p^2 and p x p^3 containing the third and fourth order central moments. They are useful for measuring nonlinear dependence between different assets of the portfolio and computing modified VaR and modified ES of a portfolio.

EWMA estimation of the covariance matrix was popularized by the RiskMetrics report in 1996. The M3.ewma and M4.ewma are straightforward extensions to the setting of third and fourth order central moments

References

JP Morgan. Riskmetrics technical document. 1996.

See Also

CoMoments ShrinkageMoments StructuredMoments MCA

Examples

Run this code
# NOT RUN {
data(edhec)

# EWMA estimation
# 'as.mat = F' would speed up calculations in higher dimensions
sigma <- M2.ewma(edhec, 0.94)
m3 <- M3.ewma(edhec, 0.94)
m4 <- M4.ewma(edhec, 0.94)

# compute equal-weighted portfolio modified ES 
mu <- colMeans(edhec)
p <- length(mu)
ES(p = 0.95, portfolio_method = "component", weights = rep(1 / p, p), mu = mu, 
    sigma = sigma, m3 = m3, m4 = m4)

# compare to sample method
sigma <- cov(edhec)
m3 <- M3.MM(edhec)
m4 <- M4.MM(edhec)
ES(p = 0.95, portfolio_method = "component", weights = rep(1 / p, p), mu = mu, 
    sigma = sigma, m3 = m3, m4 = m4)

# }

Run the code above in your browser using DataLab