Helper to construct views on volatility.
Usage
view_on_volatility(x, vol)
# S3 method for default
view_on_volatility(x, vol)
# S3 method for matrix
view_on_volatility(x, vol)
# S3 method for xts
view_on_volatility(x, vol)
# S3 method for tbl_df
view_on_volatility(x, vol)
Arguments
- x
An univariate or a multivariate distribution.
- vol
A
double
for the target volatility structure of the series inx
.
Examples
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
#> # ffp view
#> Type: View On Volatility
#> Aeq : Dim 4 x 1859
#> beq : Dim 4 x 1
# Optimization
ep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver = "nlminb")
autoplot(ep)
# Desired volatility
vol
#> DAX SMI CAC FTSE
#> 0.01339109 0.01202505 0.01434014 0.01034505
# Posterior volatility matches very closely with the desired volatility
sqrt(diag(ffp_moments(x = ret, p = ep)$sigma))
#> DAX SMI CAC FTSE
#> 0.01341064 0.01204973 0.01434835 0.01033864