Skip to contents

Helper to construct constraints on the marginal distribution.

Usage

view_on_marginal_distribution(x, simul, p)

# S3 method for default
view_on_marginal_distribution(x, simul, p)

# S3 method for matrix
view_on_marginal_distribution(x, simul, p)

# S3 method for xts
view_on_marginal_distribution(x, simul, p)

# S3 method for tbl_df
view_on_marginal_distribution(x, simul, p)

Arguments

x

An univariate or a multivariate distribution.

simul

An univariate or multivariate simulated panel.

p

An object of the ffp class.

Value

A list of the view class.

Details

  • simul must have the same number of columns than x

  • p should have the same number of rows that simul.

Examples

set.seed(1)
library(ggplot2)

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

#' Prior probability distribution
prior <- rep(1 / n, n)

# Simulated marginals
simul <- bootstrap_scenarios(ret, as_ffp(prior), as.double(n))

views <- view_on_marginal_distribution(x = ret, simul = simul, p = prior)
views
#> # ffp view
#> Type:  View On Marginal Distribution
#> Aeq :  Dim 8 x 1859 
#> beq :  Dim 8 x 1 

ep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver = "nlminb")
autoplot(ep)


# location matches
colMeans(simul)
#>           DAX           SMI           CAC          FTSE 
#>  0.0002882227  0.0005169526 -0.0001995663  0.0001186610 
ffp_moments(x = ret, p = ep)$mu
#>           DAX           SMI           CAC          FTSE 
#>  0.0002882228  0.0005169526 -0.0001995663  0.0001186609 

# dispersion matches
cov(simul)
#>               DAX          SMI          CAC         FTSE
#> DAX  1.073869e-04 7.191219e-05 8.163091e-05 5.193336e-05
#> SMI  7.191219e-05 9.252845e-05 6.601878e-05 4.387011e-05
#> CAC  8.163091e-05 6.601878e-05 1.191442e-04 5.479092e-05
#> FTSE 5.193336e-05 4.387011e-05 5.479092e-05 6.188198e-05
ffp_moments(x = ret, p = ep)$sigma
#>               DAX          SMI          CAC         FTSE
#> DAX  1.073792e-04 7.070163e-05 8.346904e-05 5.239964e-05
#> SMI  7.070163e-05 9.253669e-05 6.508528e-05 4.444309e-05
#> CAC  8.346904e-05 6.508528e-05 1.191358e-04 5.574772e-05
#> FTSE 5.239964e-05 4.444309e-05 5.574772e-05 6.192666e-05