Helper to construct constraints on the entire distribution.
Usage
view_on_joint_distribution(x, simul, p)
# S3 method for default
view_on_joint_distribution(x, simul, p)
# S3 method for matrix
view_on_joint_distribution(x, simul, p)
# S3 method for xts
view_on_joint_distribution(x, simul, p)
# S3 method for tbl_df
view_on_joint_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.
Details
simul
must have the same number of columns thanx
p
should have the same number of rows thatsimul
.
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_joint_distribution(x = ret, simul = simul, p = prior)
views
#> # ffp view
#> Type: View On Joint Distribution
#> Aeq : Dim 14 x 1859
#> beq : Dim 14 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.0002862887 0.0005163121 -0.0002013750 0.0001175073
# 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.074705e-04 7.205167e-05 8.176366e-05 5.131337e-05
#> SMI 7.205167e-05 9.235423e-05 6.598208e-05 4.403098e-05
#> CAC 8.176366e-05 6.598208e-05 1.196482e-04 5.440638e-05
#> FTSE 5.131337e-05 4.403098e-05 5.440638e-05 6.150596e-05