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)
Run the code above in your browser using DataLab