view_on_correlation {ffp} | R Documentation |
Views on Correlation Structure
Description
Helper to construct views on the correlation matrix.
Usage
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 |
Value
A list
of the view
class.
Examples
library(ggplot2)
# Invariant
ret <- diff(log(EuStockMarkets))
# Assume that a panic event throws all correlations to the roof!
co <- matrix(0.95, 4, 4)
diag(co) <- 1
co
# Prior probability (usually the equal-weight setting)
prior <- rep(1 / nrow(ret), nrow(ret))
# View
views <- view_on_correlation(x = ret, cor = co)
views
# Optimization
ep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver = "nlminb")
autoplot(ep)
# prior correlation structure
stats::cor(ret)
# posterior correlation structure matches the initial view very closely
stats::cov2cor(ffp_moments(x = ret, p = ep)$sigma)
[Package ffp version 0.2.2 Index]