Skip to contents

Helper to construct views on expected returns.

Usage

view_on_mean(x, mean)

# S3 method for default
view_on_mean(x, mean)

# S3 method for matrix
view_on_mean(x, mean)

# S3 method for xts
view_on_mean(x, mean)

# S3 method for tbl_df
view_on_mean(x, mean)

Arguments

x

An univariate or a multivariate distribution.

mean

A double for the target location parameter of the series in x.

Value

A list of the view class.

Examples

library(ggplot2)

# Invariant
ret <- diff(log(EuStockMarkets))
n   <- nrow(ret)

# View on expected returns (here is 2% for each asset)
mean <- rep(0.02, 4)

# Prior probabilities (usually equal weight scheme)
prior <- rep(1 / n, n)

# View
views <- view_on_mean(x = ret, mean = mean)
views
#> # ffp view
#> Type:  View On Mean
#> 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)


# Probabilities are twisted in such a way that the posterior
# `mu` match's exactly with previously stated beliefs
ffp_moments(x = ret, p = ep)$mu
#>        DAX        SMI        CAC       FTSE 
#> 0.02000001 0.02000001 0.02000000 0.02000000