view_on_volatility: Views on Volatility

View source: R/views.R

view_on_volatilityR Documentation

Views on Volatility

Description

Helper to construct views on volatility.

Usage

view_on_volatility(x, vol)

## Default S3 method:
view_on_volatility(x, vol)

## S3 method for class 'matrix'
view_on_volatility(x, vol)

## S3 method for class 'xts'
view_on_volatility(x, vol)

## S3 method for class '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 in x.

Value

A list of the view class.

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

# 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))

ffp documentation built on Sept. 29, 2022, 5:10 p.m.