library(ggplot2)
# Invariant (stationarity)
ret <- diff(log(EuStockMarkets))
# Expectations for location and dispersion parameters
mean <- colMeans(ret) # No active expectations for returns
cor <- matrix(0, ncol = 4, nrow = 4) # diagonal covariance matrix
diag(cor) <- 1 # diagonal covariance matrix
sds <- apply(ret, 2, sd) # diagonal covariance matrix
covs <- diag(sds) %*% cor %*% diag(sds) ## diagonal covariance matrix
# prior probabilities (usually equal weight scheme)
prior <- rep(1 / nrow(ret), nrow(ret))
# Views
views <- view_on_covariance(x = ret, mean = mean, sigma = covs)
views
# Optimization
ep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver = "nlminb")
autoplot(ep)
# original covariance matrix
stats::cov(ret)
# Posterior covariance matrix
ffp_moments(x = ret, p = ep)$sigma
Run the code above in your browser using DataLab