[Returnanalytics-commits] r3660 - in pkg/Dowd: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 2 20:34:16 CEST 2015


Author: dacharya
Date: 2015-06-02 20:34:16 +0200 (Tue, 02 Jun 2015)
New Revision: 3660

Added:
   pkg/Dowd/R/CdfOfSumUsingGaussianCopula.R
   pkg/Dowd/R/CdfOfSumUsingProductCopula.R
   pkg/Dowd/R/GaussianCopulaVaR.R
   pkg/Dowd/R/ProductCopulaVaR.R
   pkg/Dowd/man/BootstrapVaRFigure.Rd
   pkg/Dowd/man/CdfOfSumUsingGaussianCopula.Rd
   pkg/Dowd/man/CdfOfSumUsingProductCopula.Rd
   pkg/Dowd/man/GaussianCopulaVaR.Rd
   pkg/Dowd/man/ProductCopulaVaR.Rd
Modified:
   pkg/Dowd/NAMESPACE
   pkg/Dowd/R/CdfOfSumUsingGumbelCopula.R
   pkg/Dowd/man/CdfOfSumUsingGumbelCopula.Rd
Log:
GaussianCopulaVaR, ProductCopulaVaR: source and documentation.

Modified: pkg/Dowd/NAMESPACE
===================================================================
--- pkg/Dowd/NAMESPACE	2015-06-01 21:12:22 UTC (rev 3659)
+++ pkg/Dowd/NAMESPACE	2015-06-02 18:34:16 UTC (rev 3660)
@@ -9,9 +9,12 @@
 export(BootstrapVaR)
 export(BootstrapVaRConfInterval)
 export(BootstrapVaRFigure)
+export(CdfOfSumUsingGaussianCopula)
 export(CdfOfSumUsingGumbelCopula)
+export(CdfOfSumUsingProductCopula)
 export(ChristoffersenBacktestForIndependence)
 export(ChristoffersenBacktestForUnconditionalCoverage)
+export(GaussianCopulaVaR)
 export(GumbelCopulaVaR)
 export(HSES)
 export(HSVaR)
@@ -19,3 +22,4 @@
 export(KSTestStat)
 export(KuiperTestStat)
 export(LopezBacktest)
+export(ProductCopulaVaR)

Added: pkg/Dowd/R/CdfOfSumUsingGaussianCopula.R
===================================================================
--- pkg/Dowd/R/CdfOfSumUsingGaussianCopula.R	                        (rev 0)
+++ pkg/Dowd/R/CdfOfSumUsingGaussianCopula.R	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,97 @@
+#' Derives prob ( X + Y < quantile) using Gumbel copula
+#' 
+#' If X and Y are position P/Ls, then the VaR is equal to minus quantile. In
+#' such cases, we insert the negative of the VaR as the quantile, and the
+#' function gives us the value of 1 minus VaR confidence level. In other
+#' words, if X and Y are position P/Ls, the quantile is the negative of the
+#' VaR, and the output is 1 minus the VaR confidence level.
+#' 
+#' @param quantile Portfolio quantile (or negative of Var, if X, Y are position P/Ls)
+#' @param mu1 Mean of Profit/Loss on first position 
+#' @param mu2 Mean of Profit/Loss on second position
+#' @param sigma1 Standard Deviation of Profit/Loss on first position
+#' @param sigma2 Standard Deviation of Profit/Loss on second position
+#' @param rho Correlation between P/Ls on two positions
+#' @param number.steps.in.copula The number of steps used in the copula approximation
+#' @return Probability of X + Y being less than quantile
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+#' News, 2004.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # Prob ( X + Y < q ) using Gaussian Copula for X with mean 2.3 and std. .2
+#'    # and Y with mean 4.5 and std. 1.5 with beta 1.2 at 0.9 quantile
+#'    CdfOfSumUsingGaussianCopula(0.9, 2.3, 4.5, 1.2, 1.5, 0.6, 100)
+#'
+#' @export
+CdfOfSumUsingGaussianCopula <- function(quantile, mu1, mu2, sigma1, sigma2, rho, number.steps.in.copula){
+  
+  # Define w variable
+  w.min <- 0.001
+  w.max <- 0.999 # Specify min and max of w
+  dw <- 0.001 # Specify incremental change in w
+  w <- seq(w.min, w.max, dw) # Define w-variable going from min to max in units of size dw
+  
+  # Obtain 'first' and 'second' sets of copula values corresponding to 
+  # values of w (NB: The difference between the 'first' and 'second' goes 
+  # into the calculation of the approximate copula differential)
+  first.copula <- double(length(w)) # initialize variables
+  second.copula <- double(length(w))
+  approximate.copula.differential <- double(length(w))
+  for (i in 1:length(w)) {
+    first.copula[i] <- GaussianCopula(w[i], 
+                                    pnorm(quantile - qnorm(w[i], mu1, sigma1), mu2, sigma2), 
+                                    0, number.steps.in.copula)
+  }
+  for (i in 2:length(w)) {
+    second.copula[i] <- GaussianCopula(w[i] - dw, 
+                                    pnorm(quantile - qnorm(w[i], mu1, sigma1), mu2, sigma2), 
+                                    0, number.steps.in.copula)
+  }
+  
+  # Obtain approximate copula differentials from the above
+  for (i in 2:length(w)){
+    approximate.copula.differential[i] <- (first.copula[i]-second.copula[i])/dw
+  }
+  
+  y<- sum(approximate.copula.differential) * dw
+  
+}
+
+GaussianCopula <- function(u, v, rho, number.steps){
+  # Derives value of Gaussian Copula
+  # u is value of first marginal for random variable X
+  # v is value of second marginal for random variable Y
+  # rho is correlation coefficient between X and Y
+  # number.steps is used for each of x and y
+  # NB: Applies to bivariate Gaussian copula only
+  
+  # Define x and y
+  # NB: These are hypothetical domains of the cdfs; without loss of generality
+  # we can take these to be standard normal percentiles; this is because we are
+  # only using these to determine double integrals with limits u and v
+  x.min <- -3
+  x.max <- qnorm(u, 0, 1)
+  dx <- (x.max - x.min)/number.steps
+  x <- seq(x.min, x.max, dx)
+  y.min <- -3
+  y.max <- qnorm(v, 0, 1)
+  dy <- (y.max - y.min)/number.steps
+  y <- seq(y.min, y.max, dy)
+  
+  # Obtain copula as approximate double sum, which appriximates the 'true'
+  # double integral
+  term <- double(length(x),length(y))
+  for (i in 1:length(x)) {
+    for (j in 1:length(y)) {
+      term[i, j] <- exp(-(x[i]^2-2*rho*x[i]*y[j]+y[j]^2)/(2*(1-rho^2)))
+    }
+  }
+  
+  y <- sum(term) * dx * dy / (2 * pi * (1 - rho^2)^0.5)
+    
+  return(y)
+}
\ No newline at end of file

Modified: pkg/Dowd/R/CdfOfSumUsingGumbelCopula.R
===================================================================
--- pkg/Dowd/R/CdfOfSumUsingGumbelCopula.R	2015-06-01 21:12:22 UTC (rev 3659)
+++ pkg/Dowd/R/CdfOfSumUsingGumbelCopula.R	2015-06-02 18:34:16 UTC (rev 3660)
@@ -22,7 +22,8 @@
 #' @examples
 #' 
 #'    # Prob ( X + Y < q ) using Gumbel Copula for X with mean 2.3 and std. .2
-#'    # CdfOfSumUsingGumbelCopula(0.9, 2.3, 4.5, 1.2, 1.5, 1.2)
+#'    # and Y with mean 4.5 and std. 1.5 with beta 1.2 at 0.9 quantile
+#'    CdfOfSumUsingGumbelCopula(0.9, 2.3, 4.5, 1.2, 1.5, 1.2)
 #'
 #' @export
 CdfOfSumUsingGumbelCopula <- function(quantile, mu1, mu2, sigma1, sigma2, beta){
@@ -30,6 +31,7 @@
   if (beta <= 1) {
     stop("Beta must be bigger than 1")
   }
+  
   # Define w variable
   w.min <- 0.001
   w.max <- 0.999 # Specify min and max of w
@@ -48,7 +50,7 @@
                                     beta)
   }
   for (i in 2:length(w)) {
-    first.copula[i] <- GumbelCopula(w[i] - dw, 
+    second.copula[i] <- GumbelCopula(w[i] - dw, 
                                     pnorm(quantile - qnorm(w[i], mu1, sigma1), mu2, sigma2), 
                                     beta)
   }
@@ -67,7 +69,6 @@
   # u is value of first marginal for random variable X
   # v is value of second marginal for random variable Y
   # beta parameter for Gumbel Copula
-  y <- exp(-((-log(u))^beta + (-log(v))^beta))^(1/beta);
+  y <- exp(-((-log(u))^beta + (-log(v))^beta))^(1/beta)
   return(y)
-  
 }
\ No newline at end of file

Added: pkg/Dowd/R/CdfOfSumUsingProductCopula.R
===================================================================
--- pkg/Dowd/R/CdfOfSumUsingProductCopula.R	                        (rev 0)
+++ pkg/Dowd/R/CdfOfSumUsingProductCopula.R	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,67 @@
+#' Derives prob ( X + Y < quantile) using Product copula
+#' 
+#' If X and Y are position P/Ls, then the VaR is equal to minus quantile. In
+#' such cases, we insert the negative of the VaR as the quantile, and the
+#' function gives us the value of 1 minus VaR confidence level. In other
+#' words, if X and Y are position P/Ls, the quantile is the negative of the
+#' VaR, and the output is 1 minus the VaR confidence level.
+#' 
+#' @param quantile Portfolio quantile (or negative of Var, if X, Y are position P/Ls)
+#' @param mu1 Mean of Profit/Loss on first position 
+#' @param mu2 Mean of Profit/Loss on second position
+#' @param sigma1 Standard Deviation of Profit/Loss on first position
+#' @param sigma2 Standard Deviation of Profit/Loss on second position
+#' @return Probability of X + Y being less than quantile
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+#' News, 2004.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # Prob ( X + Y < q ) using Product Copula for X with mean 2.3 and std. .2
+#'    # and Y with mean 4.5 and std. 1.5 with beta 1.2 at 0.9 quantile
+#'    CdfOfSumUsingProductCopula(0.9, 2.3, 4.5, 1.2, 1.5)
+#'
+#' @export
+CdfOfSumUsingProductCopula <- function(quantile, mu1, mu2, sigma1, sigma2){
+  
+  # Define w variable
+  w.min <- 0.001
+  w.max <- 0.999 # Specify min and max of w
+  dw <- 0.001 # Specify incremental change in w
+  w <- seq(w.min, w.max, dw) # Define w-variable going from min to max in units of size dw
+  
+  # Obtain 'first' and 'second' sets of copula values corresponding to 
+  # values of w (NB: The difference between the 'first' and 'second' goes 
+  # into the calculation of the approximate copula differential)
+  first.copula <- double(length(w)) # initialize variables
+  second.copula <- double(length(w))
+  approximate.copula.differential <- double(length(w))
+  for (i in 1:length(w)) {
+    first.copula[i] <- ProductCopula(w[i], 
+                                    pnorm(quantile - qnorm(w[i], mu1, sigma1), mu2, sigma2))
+  }
+  for (i in 2:length(w)) {
+    second.copula[i] <- ProductCopula(w[i] - dw, 
+                                     pnorm(quantile - qnorm(w[i], mu1, sigma1), mu2, sigma2))
+  }
+  
+  # Obtain approximate copula differentials from the above
+  for (i in 2:length(w)){
+    approximate.copula.differential[i] <- (first.copula[i]-second.copula[i])/dw
+  }
+  
+  y<- sum(approximate.copula.differential) * dw
+  
+}
+
+ProductCopula <- function(u, v){
+  # Derives value of Product Copula
+  # u is value of first marginal for random variable X
+  # v is value of second marginal for random variable Y
+  # beta parameter for Product Copula
+  y <- u * v
+  return(y)
+}
\ No newline at end of file

Added: pkg/Dowd/R/GaussianCopulaVaR.R
===================================================================
--- pkg/Dowd/R/GaussianCopulaVaR.R	                        (rev 0)
+++ pkg/Dowd/R/GaussianCopulaVaR.R	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,74 @@
+#' Bivariate Gaussian Copule VaR
+#' 
+#' Derives VaR using bivariate Gaussian copula with specified inputs 
+#' for normal marginals.
+#' 
+#' @param mu1 Mean of Profit/Loss on first position 
+#' @param mu2 Mean of Profit/Loss on second position
+#' @param sigma1 Standard Deviation of Profit/Loss on first position
+#' @param sigma2 Standard Deviation of Profit/Loss on second position
+#' @param rho Correlation between Profit/Loss on two positions
+#' @param number.steps.in.copula Number of steps used in the copula approximation
+#' ( approximation being needed because Gaussian copula lacks a closed form solution)
+#' @param cl VaR confidece level
+#' @return Copula based VaR
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+#' News, 2004.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # VaR using bivariate Gumbel for X and Y with given parameters:
+#'    GumbelCopulaVaR(2.3, 4.1, 1.2, 1.5, .6, .95)
+#'
+#' @export
+GaussianCopulaVaR <- function(mu1, mu2, sigma1, sigma2, rho, 
+                              number.steps.in.copula, cl){
+  
+  p <- 1 - cl # p is tail probability or cdf
+  
+  # For comparision, compute analytical normal VaR
+  portfolio.mu <- mu1 + mu2
+  portfolio.variance <- sigma1^2 + 2 * rho * sigma1 * sigma2 + sigma2^2
+  portfolio.sigma <- sqrt(portfolio.variance)
+  analytical.variance.covariance.VaR <- - portfolio.mu - portfolio.sigma * qnorm(p, 0, 1)
+  # Specify bounds arbitrarily (NB: Would need to change manually if these were
+  # inappropriate)
+  L <- -portfolio.mu - 5 * portfolio.sigma
+  fL <- CdfOfSumUsingGaussianCopula(L, mu1, mu2, sigma1, sigma2, 
+                                    rho, number.steps.in.copula) - p
+  sign.fL <- sign(fL)
+  U <- -portfolio.mu + 5 *  portfolio.sigma
+  fU <- CdfOfSumUsingGaussianCopula(U, mu1, mu2, sigma1, sigma2, 
+                                    rho, number.steps.in.copula) - p
+  sign.fU <- sign(fU)
+  
+  if (sign.fL == sign.fU){
+    stop("Assumed bounds do not include answer")
+  }
+  
+  # Bisection Algorithm
+  tol <- 0.0001 # Tolerance level (NM: change manually if desired)
+  while (U - L > tol){
+    x <- (L + U) / 2 # Bisection carried out in terms of P/L quantiles or minus VaR
+    cum.prob <- CdfOfSumUsingGaussianCopula(x, mu1, mu2, sigma1, sigma2, rho, 
+                                            number.steps.in.copula)
+    fx <- cum.prob - p
+    if (sign(fx) == sign(fL)){
+      L <- x
+      fL <- fx
+    } else {
+      U <- x
+      fU <- fx
+    }
+  }
+  
+  y <- -x # VaR is negative of terminal x-value or P/L quantile
+  
+  cat("Analytical Variance Covariance Var: ", analytical.variance.covariance.VaR, "\n")
+  cat("Var using bivariate gaussian copula: ", y, "\n")
+  cat("Error in Copula VaR Estimate: ", analytical.variance.covariance.VaR-y)
+  return(y)
+}
\ No newline at end of file

Added: pkg/Dowd/R/ProductCopulaVaR.R
===================================================================
--- pkg/Dowd/R/ProductCopulaVaR.R	                        (rev 0)
+++ pkg/Dowd/R/ProductCopulaVaR.R	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,63 @@
+#' Bivariate Product Copule VaR
+#' 
+#' Derives VaR using bivariate Product or logistic copula with specified inputs 
+#' for normal marginals.
+#' 
+#' @param mu1 Mean of Profit/Loss on first position 
+#' @param mu2 Mean of Profit/Loss on second position
+#' @param sigma1 Standard Deviation of Profit/Loss on first position
+#' @param sigma2 Standard Deviation of Profit/Loss on second position
+#' @param cl VaR onfidece level
+#' @return Copula based VaR
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+#' News, 2004.
+#'
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # VaR using bivariate Product for X and Y with given parameters:
+#'    ProductCopulaVaR(2.3, 4.1, 1.2, 1.5, .95)
+#'
+#' @export
+ProductCopulaVaR <- function(mu1, mu2, sigma1, sigma2, cl){
+  
+  p <- 1 - cl # p is tail probability or cdf
+  
+  # Compute portfolio mean and sigma (NB: These are used here to help compute
+  # initial bounds automatically)
+  portfolio.mu <- mu1 + mu2
+  portfolio.variance <- sigma1^2+sigma2^2
+  portfolio.sigma <- sqrt(portfolio.variance)
+  
+  # Specify bounds arbitrarily (NB: Would need to change manually if these were
+  # inappropriate)
+  L <- -portfolio.mu - 5 * portfolio.sigma
+  fL <- CdfOfSumUsingProductCopula(L, mu1, mu2, sigma1, sigma2) - p
+  sign.fL <- sign(fL)
+  U <- -portfolio.mu + 5 *  portfolio.sigma
+  fU <- CdfOfSumUsingProductCopula(U, mu1, mu2, sigma1, sigma2) - p
+  sign.fU <- sign(fU)
+  if (sign.fL == sign.fU){
+    stop("Assumed bounds do not include answer")
+  }
+  
+  # Bisection Algorithm
+  tol <- 0.0001 # Tolerance level (NM: change manually if desired)
+  while (U - L > tol){
+    x <- (L + U) / 2 # Bisection carried out in terms of P/L quantiles or minus VaR
+    cum.prob <- CdfOfSumUsingProductCopula(x, mu1, mu2, sigma1, sigma2, beta)
+    fx <- cum.prob - p
+    if (sign(fx) == sign(fL)){
+      L <- x
+      fL <- fx
+    } else {
+      U <- x
+      fU <- fx
+    }
+  }
+  y <- -x # VaR is negative of terminal x-value or P/L quantile
+  
+}
\ No newline at end of file

Added: pkg/Dowd/man/BootstrapVaRFigure.Rd
===================================================================
--- pkg/Dowd/man/BootstrapVaRFigure.Rd	                        (rev 0)
+++ pkg/Dowd/man/BootstrapVaRFigure.Rd	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,33 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/BootstrapVaRFigure.R
+\name{BootstrapVaRFigure}
+\alias{BootstrapVaRFigure}
+\title{Plots figure of bootstrapped VaR}
+\usage{
+BootstrapVaRFigure(Ra, number.resamples, cl)
+}
+\arguments{
+\item{Ra}{Vector corresponding to profit and loss distribution}
+
+\item{cl}{Number corresponding to Value at Risk confidence level}
+
+\item{number.sample}{Number of samples to be taken in bootstrap procedure}
+}
+\description{
+Plots figure for the bootstrapped VaR, for confidence
+level and holding period implied by data frequency.
+}
+\examples{
+# To be modified with appropriate data.
+   # Estimates 90\% confidence interval for bootstrapped VaR for 95\%
+   # confidence interval
+   Ra <- rnorm(1000)
+   BootstrapESFigure(Ra, 500, 0.95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+

Added: pkg/Dowd/man/CdfOfSumUsingGaussianCopula.Rd
===================================================================
--- pkg/Dowd/man/CdfOfSumUsingGaussianCopula.Rd	                        (rev 0)
+++ pkg/Dowd/man/CdfOfSumUsingGaussianCopula.Rd	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,49 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/CdfOfSumUsingGaussianCopula.R
+\name{CdfOfSumUsingGaussianCopula}
+\alias{CdfOfSumUsingGaussianCopula}
+\title{Derives prob ( X + Y < quantile) using Gumbel copula}
+\usage{
+CdfOfSumUsingGaussianCopula(quantile, mu1, mu2, sigma1, sigma2, rho,
+  number.steps.in.copula)
+}
+\arguments{
+\item{quantile}{Portfolio quantile (or negative of Var, if X, Y are position P/Ls)}
+
+\item{mu1}{Mean of Profit/Loss on first position}
+
+\item{mu2}{Mean of Profit/Loss on second position}
+
+\item{sigma1}{Standard Deviation of Profit/Loss on first position}
+
+\item{sigma2}{Standard Deviation of Profit/Loss on second position}
+
+\item{rho}{Correlation between P/Ls on two positions}
+
+\item{number.steps.in.copula}{The number of steps used in the copula approximation}
+}
+\value{
+Probability of X + Y being less than quantile
+}
+\description{
+If X and Y are position P/Ls, then the VaR is equal to minus quantile. In
+such cases, we insert the negative of the VaR as the quantile, and the
+function gives us the value of 1 minus VaR confidence level. In other
+words, if X and Y are position P/Ls, the quantile is the negative of the
+VaR, and the output is 1 minus the VaR confidence level.
+}
+\examples{
+# Prob ( X + Y < q ) using Gaussian Copula for X with mean 2.3 and std. .2
+   # and Y with mean 4.5 and std. 1.5 with beta 1.2 at 0.9 quantile
+   CdfOfSumUsingGaussianCopula(0.9, 2.3, 4.5, 1.2, 1.5, 0.6, 100)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+
+Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+News, 2004.
+}
+

Modified: pkg/Dowd/man/CdfOfSumUsingGumbelCopula.Rd
===================================================================
--- pkg/Dowd/man/CdfOfSumUsingGumbelCopula.Rd	2015-06-01 21:12:22 UTC (rev 3659)
+++ pkg/Dowd/man/CdfOfSumUsingGumbelCopula.Rd	2015-06-02 18:34:16 UTC (rev 3660)
@@ -31,7 +31,8 @@
 }
 \examples{
 # Prob ( X + Y < q ) using Gumbel Copula for X with mean 2.3 and std. .2
-   # CdfOfSumUsingGumbelCopula(0.9, 2.3, 4.5, 1.2, 1.5, 1.2)
+   # and Y with mean 4.5 and std. 1.5 with beta 1.2 at 0.9 quantile
+   CdfOfSumUsingGumbelCopula(0.9, 2.3, 4.5, 1.2, 1.5, 1.2)
 }
 \author{
 Dinesh Acharya

Added: pkg/Dowd/man/CdfOfSumUsingProductCopula.Rd
===================================================================
--- pkg/Dowd/man/CdfOfSumUsingProductCopula.Rd	                        (rev 0)
+++ pkg/Dowd/man/CdfOfSumUsingProductCopula.Rd	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,44 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/CdfOfSumUsingProductCopula.R
+\name{CdfOfSumUsingProductCopula}
+\alias{CdfOfSumUsingProductCopula}
+\title{Derives prob ( X + Y < quantile) using Product copula}
+\usage{
+CdfOfSumUsingProductCopula(quantile, mu1, mu2, sigma1, sigma2)
+}
+\arguments{
+\item{quantile}{Portfolio quantile (or negative of Var, if X, Y are position P/Ls)}
+
+\item{mu1}{Mean of Profit/Loss on first position}
+
+\item{mu2}{Mean of Profit/Loss on second position}
+
+\item{sigma1}{Standard Deviation of Profit/Loss on first position}
+
+\item{sigma2}{Standard Deviation of Profit/Loss on second position}
+}
+\value{
+Probability of X + Y being less than quantile
+}
+\description{
+If X and Y are position P/Ls, then the VaR is equal to minus quantile. In
+such cases, we insert the negative of the VaR as the quantile, and the
+function gives us the value of 1 minus VaR confidence level. In other
+words, if X and Y are position P/Ls, the quantile is the negative of the
+VaR, and the output is 1 minus the VaR confidence level.
+}
+\examples{
+# Prob ( X + Y < q ) using Product Copula for X with mean 2.3 and std. .2
+   # and Y with mean 4.5 and std. 1.5 with beta 1.2 at 0.9 quantile
+   CdfOfSumUsingProductCopula(0.9, 2.3, 4.5, 1.2, 1.5)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+
+Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+News, 2004.
+}
+

Added: pkg/Dowd/man/GaussianCopulaVaR.Rd
===================================================================
--- pkg/Dowd/man/GaussianCopulaVaR.Rd	                        (rev 0)
+++ pkg/Dowd/man/GaussianCopulaVaR.Rd	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,45 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/GaussianCopulaVaR.R
+\name{GaussianCopulaVaR}
+\alias{GaussianCopulaVaR}
+\title{Bivariate Gaussian Copule VaR}
+\usage{
+GaussianCopulaVaR(mu1, mu2, sigma1, sigma2, rho, number.steps.in.copula, cl)
+}
+\arguments{
+\item{mu1}{Mean of Profit/Loss on first position}
+
+\item{mu2}{Mean of Profit/Loss on second position}
+
+\item{sigma1}{Standard Deviation of Profit/Loss on first position}
+
+\item{sigma2}{Standard Deviation of Profit/Loss on second position}
+
+\item{rho}{Correlation between Profit/Loss on two positions}
+
+\item{number.steps.in.copula}{Number of steps used in the copula approximation
+( approximation being needed because Gaussian copula lacks a closed form solution)}
+
+\item{cl}{VaR confidece level}
+}
+\value{
+Copula based VaR
+}
+\description{
+Derives VaR using bivariate Gaussian copula with specified inputs
+for normal marginals.
+}
+\examples{
+# VaR using bivariate Gumbel for X and Y with given parameters:
+   GumbelCopulaVaR(2.3, 4.1, 1.2, 1.5, .6, .95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+
+Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+News, 2004.
+}
+

Added: pkg/Dowd/man/ProductCopulaVaR.Rd
===================================================================
--- pkg/Dowd/man/ProductCopulaVaR.Rd	                        (rev 0)
+++ pkg/Dowd/man/ProductCopulaVaR.Rd	2015-06-02 18:34:16 UTC (rev 3660)
@@ -0,0 +1,40 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/ProductCopulaVaR.R
+\name{ProductCopulaVaR}
+\alias{ProductCopulaVaR}
+\title{Bivariate Product Copule VaR}
+\usage{
+ProductCopulaVaR(mu1, mu2, sigma1, sigma2, cl)
+}
+\arguments{
+\item{mu1}{Mean of Profit/Loss on first position}
+
+\item{mu2}{Mean of Profit/Loss on second position}
+
+\item{sigma1}{Standard Deviation of Profit/Loss on first position}
+
+\item{sigma2}{Standard Deviation of Profit/Loss on second position}
+
+\item{cl}{VaR onfidece level}
+}
+\value{
+Copula based VaR
+}
+\description{
+Derives VaR using bivariate Product or logistic copula with specified inputs
+for normal marginals.
+}
+\examples{
+# VaR using bivariate Product for X and Y with given parameters:
+   ProductCopulaVaR(2.3, 4.1, 1.2, 1.5, .95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+
+Dowd, K. and Fackler, P. Estimating VaR with copulas. Financial Engineering
+News, 2004.
+}
+



More information about the Returnanalytics-commits mailing list