library(ggplot2)
# Invariant
ret <- diff(log(EuStockMarkets))
n <- nrow(ret)
# Expected a volatility 30% higher than historical average
vol <- apply(ret, 2, stats::sd) * 1.3
# Prior Probabilities
prior <- rep(1 / n, n)
# Views
views <- view_on_volatility(x = ret, vol = vol)
views
# Optimization
ep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver = "nlminb")
autoplot(ep)
# Desired volatility
vol
# Posterior volatility matches very closely with the desired volatility
sqrt(diag(ffp_moments(x = ret, p = ep)$sigma))
Run the code above in your browser using DataLab