[Returnanalytics-commits] r3903 - pkg/Dowd/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 4 00:56:11 CEST 2015
Author: dacharya
Date: 2015-08-04 00:56:10 +0200 (Tue, 04 Aug 2015)
New Revision: 3903
Modified:
pkg/Dowd/R/LogNormalESPlot3D.R
pkg/Dowd/R/LogNormalVaRPlot3D.R
pkg/Dowd/R/LogtESPlot3D.R
pkg/Dowd/R/LogtVaRPlot3D.R
pkg/Dowd/R/NormalESPlot3D.R
pkg/Dowd/R/NormalVaRPlot3D.R
Log:
Perspective, shading and various parameters of 3D plot were adjusted to make plots look like that of MMRII Toolbox
Modified: pkg/Dowd/R/LogNormalESPlot3D.R
===================================================================
--- pkg/Dowd/R/LogNormalESPlot3D.R 2015-08-03 20:14:19 UTC (rev 3902)
+++ pkg/Dowd/R/LogNormalESPlot3D.R 2015-08-03 22:56:10 UTC (rev 3903)
@@ -26,10 +26,10 @@
#'
#' # Plots VaR against confidene level given geometric return data
#' data <- runif(5, min = 0, max = .2)
-#' LogNormalESPlot3D(returns = data, investment = 5, cl = seq(.85,.99,.01), hp = 60:90)
+#' LogNormalESPlot3D(returns = data, investment = 5, cl = seq(.9,.99,.01), hp = 1:100)
#'
#' # Computes VaR against confidence level given mean and standard deviation of return data
-#' LogNormalESPlot3D(mu = .012, sigma = .03, investment = 5, cl = seq(.85,.99,.02), hp = 40:80)
+#' LogNormalESPlot3D(mu = .012, sigma = .03, investment = 5, cl = seq(.9,.99,.01), hp = 1:100)
#'
#'
#' @export
@@ -124,7 +124,9 @@
v <- v/n
# Plotting
- persp(x=cl, y=hp, t(VaR), xlab = "Confidence Level",
- ylab = "Holding Period", zlab = "VaR",
- main = "Log-t ES against confidence level")
+ persp(x=cl, y=hp, t(v), xlab = "Confidence Level",
+ ylab = "Holding Period", zlab = "ES", border=NA,
+ theta = -45, phi = 40, shade = .75, ltheta = 120,
+ col = "lightgray", ticktype = "detailed", nticks = 5,
+ main = "Log-Normal ES against CL and HP")
}
Modified: pkg/Dowd/R/LogNormalVaRPlot3D.R
===================================================================
--- pkg/Dowd/R/LogNormalVaRPlot3D.R 2015-08-03 20:14:19 UTC (rev 3902)
+++ pkg/Dowd/R/LogNormalVaRPlot3D.R 2015-08-03 22:56:10 UTC (rev 3903)
@@ -27,11 +27,11 @@
#' @examples
#'
#' # Plots VaR against confidene level given geometric return data
-#' data <- runif(5, min = 0, max = .2)
-#' LogNormalVaRPlot3D(returns = data, investment = 5, cl = seq(.85,.99,.01), hp = 60:90)
+#' data <- rnorm(5, .09, .03)
+#' LogNormalVaRPlot3D(returns = data, investment = 5, cl = seq(.9,.99,.01), hp = 1:100)
#'
#' # Computes VaR against confidence level given mean and standard deviation of return data
-#' LogNormalVaRPlot3D(mu = .012, sigma = .03, investment = 5, cl = seq(.85,.99,.02), hp = 40:80)
+#' LogNormalVaRPlot3D(mu = .012, sigma = .03, investment = 5, cl = seq(.9,.99,.01), hp = 1:100)
#'
#'
#' @export
@@ -114,7 +114,8 @@
VaR <- investment - exp( sigma[1,1] * sqrt(hp) %*% qnorm(1 - cl, 0, 1) + mu[1,1] * hp %*% matrix(1,cl.row,cl.col) + log(investment)) # VaR
# Plotting
persp(x=cl, y=hp, t(VaR), xlab = "Confidence Level",
- ylab = "Holding Period", zlab = "VaR",
- main = "Log Normal VaR against confidence level and holding period")
-
+ ylab = "Holding Period", zlab = "VaR", border=NA,
+ theta = -45, phi = 35, shade = .75, ltheta = 90, cex.axis=.85, cex.lab=.85,
+ col = "lightgray", ticktype = "detailed", nticks = 5,
+ main = "Log Normal VaR against CL and HP")
}
Modified: pkg/Dowd/R/LogtESPlot3D.R
===================================================================
--- pkg/Dowd/R/LogtESPlot3D.R 2015-08-03 20:14:19 UTC (rev 3902)
+++ pkg/Dowd/R/LogtESPlot3D.R 2015-08-03 22:56:10 UTC (rev 3903)
@@ -29,11 +29,11 @@
#' @examples
#'
#' # Plots ES against confidene level given geometric return data
-#' data <- runif(5, min = 0, max = .2)
-#' LogtESPlot3D(returns = data, investment = 5, df = 6, cl = seq(.85,.99,.01), hp = 60:90)
+#' data <- rnorm(5, .09, .03)
+#' LogtESPlot3D(returns = data, investment = 5, df = 6, cl = seq(.9,.99,.01), hp = 1:100)
#'
#' # Computes ES against confidence level given mean and standard deviation of return data
-#' LogtESPlot3D(mu = .012, sigma = .03, investment = 5, df = 6, cl = seq(.85,.99,.02), hp = 40:80)
+#' LogtESPlot3D(mu = .012, sigma = .03, investment = 5, df = 6, cl = seq(.9,.99,.01), hp = 1:100)
#'
#'
#' @export
@@ -132,7 +132,10 @@
v <- v/n
# Plotting
- persp(x=cl, y=hp, t(VaR), xlab = "Confidence Level",
- ylab = "Holding Period", zlab = "VaR",
- main = "Log-t ES against confidence level")
+ persp(x=cl, y=hp, t(v), xlab = "Confidence Level",
+ ylab = "Holding Period", zlab = "ES", border=NA,
+ theta = -45, phi = 35, shade = .75, ltheta = 90, cex.axis=.85, cex.lab=.85,
+ col = "lightgray", ticktype = "detailed", nticks = 5,
+ main = "Log-t ES against CL and HP")
+
}
Modified: pkg/Dowd/R/LogtVaRPlot3D.R
===================================================================
--- pkg/Dowd/R/LogtVaRPlot3D.R 2015-08-03 20:14:19 UTC (rev 3902)
+++ pkg/Dowd/R/LogtVaRPlot3D.R 2015-08-03 22:56:10 UTC (rev 3903)
@@ -30,10 +30,10 @@
#'
#' # Plots VaR against confidene level given geometric return data
#' data <- runif(5, min = 0, max = .2)
-#' LogtVaRPlot3D(returns = data, investment = 5, df = 6, cl = seq(.85,.99,.01), hp = 60:90)
+#' LogtVaRPlot3D(returns = data, investment = 5, df = 6, cl = seq(.9,.99,.01), hp = 1:100)
#'
#' # Computes VaR against confidence level given mean and standard deviation of return data
-#' LogtVaRPlot3D(mu = .012, sigma = .03, investment = 5, df = 6, cl = seq(.85,.99,.02), hp = 40:80)
+#' LogtVaRPlot3D(mu = .012, sigma = .03, investment = 5, df = 6, cl = seq(.9,.99,.01), hp = 1:100)
#'
#'
#' @export
@@ -117,7 +117,8 @@
VaR <- investment - exp( ((df-2)/df) * sigma[1,1] * sqrt(hp) %*% qt(1 - cl, df) + mu[1,1] * hp %*% matrix(1,cl.row,cl.col) + log(investment)) # VaR
# Plotting
persp(x=cl, y=hp, t(VaR), xlab = "Confidence Level",
- ylab = "Holding Period", zlab = "VaR",
- main = "Log-t VaR against confidence level")
-
+ ylab = "Holding Period", zlab = "VaR", border=NA,
+ theta = -45, phi = 35, shade = .75, ltheta = 90, cex.axis=.85, cex.lab=.85,
+ col = "lightgray", ticktype = "detailed", nticks = 5,
+ main = "Log-t VaR against CL and HP")
}
Modified: pkg/Dowd/R/NormalESPlot3D.R
===================================================================
--- pkg/Dowd/R/NormalESPlot3D.R 2015-08-03 20:14:19 UTC (rev 3902)
+++ pkg/Dowd/R/NormalESPlot3D.R 2015-08-03 22:56:10 UTC (rev 3903)
@@ -25,10 +25,10 @@
#'
#' # Plots VaR against confidene level given geometric return data
#' data <- runif(5, min = 0, max = .2)
-#' NormalESPlot3D(returns = data, cl = seq(.85,.99,.01), hp = 60:90)
+#' NormalESPlot3D(returns = data, cl = seq(.9,.99,.01), hp = 1:100)
#'
#' # Computes VaR against confidence level given mean and standard deviation of return data
-#' NormalESPlot3D(mu = .012, sigma = .03, cl = seq(.85,.99,.02), hp = 40:80)
+#' NormalESPlot3D(mu = .012, sigma = .03, cl = seq(.9,.99,.01), hp = 1:100)
#'
#'
#' @export
@@ -110,10 +110,12 @@
VaR <- - sigma[1,1] * sqrt(hp) %*% qnorm(1 - cl, 0, 1) + mu[1,1] * hp %*% matrix(1,cl.row,cl.col) # VaR
# ES estimation
- es <-NormalES(mu = mu ,sigma = sigma, cl = cl, hp = hp)
+ ES <-NormalES(mu = mu ,sigma = sigma, cl = cl, hp = hp)
# Plotting
- persp(x=cl, y=hp, t(VaR), xlab = "Confidence Level",
- ylab = "Holding Period", zlab = "VaR",
- main = "Normal ES against confidence level")
+ persp(x=cl, y=hp, t(ES), xlab = "Confidence Level",
+ ylab = "Holding Period", zlab = "ES", border=NA,
+ theta = -45, phi = 40, shade = .75, ltheta = 120, cex.axis=.85, cex.lab=.85,
+ col = "lightgray", ticktype = "detailed", nticks = 5,
+ main = "Normal ES against CL and HP")
}
Modified: pkg/Dowd/R/NormalVaRPlot3D.R
===================================================================
--- pkg/Dowd/R/NormalVaRPlot3D.R 2015-08-03 20:14:19 UTC (rev 3902)
+++ pkg/Dowd/R/NormalVaRPlot3D.R 2015-08-03 22:56:10 UTC (rev 3903)
@@ -24,11 +24,11 @@
#' @examples
#'
#' # Plots VaR against confidene level given geometric return data
-#' data <- runif(5, min = 0, max = .2)
-#' NormalVaRPlot3D(returns = data, cl = seq(.85,.99,.01), hp = 60:90)
+#' data <- rnorm(5, .07, .03)
+#' NormalVaRPlot3D(returns = data, cl = seq(.9,.99,.01), hp = 1:100)
#'
#' # Computes VaR against confidence level given mean and standard deviation of return data
-#' NormalVaRPlot3D(mu = .012, sigma = .03, cl = seq(.85,.99,.02), hp = 40:80)
+#' NormalVaRPlot3D(mu = .012, sigma = .03, cl = seq(.9,.99,.01), hp = 1:100)
#'
#'
#' @export
@@ -109,7 +109,9 @@
VaR <- - sigma[1,1] * sqrt(hp) %*% qnorm(1 - cl, 0, 1) - mu[1,1] * hp %*% matrix(1,cl.row,cl.col) # VaR
# Plotting
persp(x=cl, y=hp, t(VaR), xlab = "Confidence Level",
- ylab = "Holding Period", zlab = "VaR",
- main = "Normal VaR against confidence level and holding period")
+ ylab = "Holding Period", zlab = "VaR", border=NA,
+ theta = -45, phi = 40, shade = .75, ltheta = 120, cex.axis=.85, cex.lab=.85,
+ col = "lightgray", ticktype = "detailed", nticks = 5,
+ main = "Normal VaR against CL and HP")
}
More information about the Returnanalytics-commits
mailing list