Helper to construct views on the correlation matrix.
view_on_correlation(x, cor)## Default S3 method:view_on_correlation(x, cor)## S3 method for class 'matrix'view_on_correlation(x, cor)## S3 method for class 'xts'view_on_correlation(x, cor)## S3 method for class 'tbl_df'view_on_correlation(x, cor)
Arguments
x: An univariate or a multivariate distribution.
cor: A matrix for the target correlation structure of the series in x.
Returns
A list of the view class.
Examples
library(ggplot2)# Invariantret <- diff(log(EuStockMarkets))# Assume that a panic event throws all correlations to the roof!co <- matrix(0.95,4,4)diag(co)<-1co
# Prior probability (usually the equal-weight setting)prior <- rep(1/ nrow(ret), nrow(ret))# Viewviews <- view_on_correlation(x = ret, cor = co)views
# Optimizationep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver ="nlminb")autoplot(ep)# prior correlation structurestats::cor(ret)# posterior correlation structure matches the initial view very closelystats::cov2cor(ffp_moments(x = ret, p = ep)$sigma)