view_on_copula: Views on Copulas

View source: R/views.R

view_on_copulaR Documentation

Views on Copulas

Description

Helper to construct constraints on copulas for entropy programming.

Usage

view_on_copula(x, simul, p)

## Default S3 method:
view_on_copula(x, simul, p)

## S3 method for class 'matrix'
view_on_copula(x, simul, p)

## S3 method for class 'xts'
view_on_copula(x, simul, p)

## S3 method for class 'tbl_df'
view_on_copula(x, simul, p)

Arguments

x

A multivariate copula.

simul

A simulated target copula.

p

An object of the ffp class.

Value

A list of the view class.

Examples


  set.seed(1)
  library(ggplot2)

  # Invariants
  ret <- diff(log(EuStockMarkets))
  u <- apply(ret, 2, stats::pnorm) # assuming normal copula
  n <- nrow(u)

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

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

  # Copulas derived from the simulated margins
  simul_cop <- apply(simul_marg, 2, stats::pnorm) # assuming normal copula

  views <- view_on_copula(x = u, simul = simul_cop, p = prior)
  views

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


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