ccor: Conditional correlations

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/conditional_correlations.R

Description

Computes conditional correlations based on multivariate volatility models. Currently only implemented for objects of class MultiEWMA.

Usage

1
2
3
ccor(object, ...)
## S3 method for class 'MultiEWMA'
ccor(object, diagonal = TRUE, duplicates = TRUE, ...)

Arguments

object

Object of class MultiEWMA.

diagonal

Whether diagonal elements should be kept or not. TRUE (the default) or FALSE.

duplicates

Whether duplicate off-diagonal elements should be kept or not. TRUE (the default) or FALSE.

...

Arguments passed to methods.

Details

Depending on the application, diagonal elements may be deleted, since they are always equal to one. Likewise, duplicated off-diagonal elements may be deleted due to the symmetry of the variance-covariance matrix. However, keep in mind that both diagonal elements as well as duplicated off-diagonal elements may be necessary to compute the variance-covariance matrix.

Value

rho

A zoo object containing the conditional correlations between the volatilities of the corresponding assets. Each row of the output object represents the correlation matrix (or elements thereof) of the corresponding day.

Note

Note that the function is currently only implemented for objects of class MultiEWMA. Implementation for other multivariate volatility models may be added in future releases.

Author(s)

Bernhard Eder

References

Danielsson (2011). Financial Risk Forecasting. Wiley. Chichester.
Jorion (2007). Value at Risk, 3rd. McGraw-Hill. New York.
Ruppert and Matteson (2015). Statistics and Data Analysis for Financial Engineering, 2nd. Springer. New York.

See Also

MultiEWMA, varcov, vola, ccor.

Examples

 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
library("zoo")

# Load returns
data("CRSPday_zoo")
y <- CRSPday_zoo

# Compute multivariate EWMA model (RiskMetrics)
EWMA <- MultiEWMA(y, center = TRUE)

# Compute conditional correlations
EWMAcor <- ccor(EWMA, duplicates = TRUE, diagonal = TRUE)
head(EWMAcor)

# Compute conditional variance-covariance matrix
  # Compute relevant volatilities
  EWMAvola <- vola(EWMA, duplicates = TRUE, offdiagonal = FALSE)
  
  # Initialize output object
  TT <- dim(EWMAcor)[1]
  c <- sqrt(dim(EWMAcor)[2])
  VarCov <- matrix(NA, dim(EWMAcor)[1], dim(EWMAcor)[2])

# Compute conditional variance-covariance matrix
  for(i in 1:TT){
    VarCov[i, ] <- c(diag(as.numeric(EWMAvola[i, ])) 
                      %*% matrix(as.numeric(EWMAcor[i, ]), c, c,  byrow = TRUE) 
                      %*% diag(as.numeric(EWMAvola[i, ]))
                      )
  }
  
# Format output
VarCov <- zoo(VarCov, order.by = index(EWMAvola))

# Compare conditional variance-covariance matrices
head(VarCov)
head(EWMA$Variances)

LFUrmutils documentation built on Jan. 3, 2020, 3 a.m.