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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 23 11:22:58 CEST 2015


Author: dacharya
Date: 2015-06-23 11:22:57 +0200 (Tue, 23 Jun 2015)
New Revision: 3718

Modified:
   pkg/Dowd/R/MEFPlot.R
   pkg/Dowd/man/MEFPlot.Rd
Log:
Error in loop corrected from 1:n-1 to 1:(n-1).

Modified: pkg/Dowd/R/MEFPlot.R
===================================================================
--- pkg/Dowd/R/MEFPlot.R	2015-06-23 08:26:43 UTC (rev 3717)
+++ pkg/Dowd/R/MEFPlot.R	2015-06-23 09:22:57 UTC (rev 3718)
@@ -1,33 +1,34 @@
-#' Mean Excess Function Plot
-#'
-#' Plots mean-excess function values of the data set.
-#'
-#' @param Ra Vector data
-#' 
-#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
-#' 
-#' @author Dinesh Acharya
-#' @examples
-#' 
-#'    # Plots 
-#'    Ra <- rnorm(1000)
-#'    MEFPlot(Ra)
-#'
-#' @export
-MEFPlot <- function(Ra){
-  data <- as.vector(Ra)
-  if (!is.vector(data)) {
-    stop("Input should be a vector data.")
-  }
-  u <- data
-  n <- length(u)
-  mef <- double(n-1)
-  for (i in 1:n - 1) {
-    data <- data[which(data > u[i])]
-    mef[i] <- mean(data) - u[i]
-  }
-  u <- u[!u==max(u)]
-  plot(u, mef, type = "l", xlab = "Threshold", ylab = "e(u)", 
-       main = "Empirical Mean Excess Function")
-  
-} 
+#' Mean Excess Function Plot
+#'
+#' Plots mean-excess function values of the data set.
+#'
+#' @param Ra Vector data
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # Plots mean-excess function values
+#'    Ra <- rnorm(1000)
+#'    MEFPlot(Ra)
+#'
+#' @export
+MEFPlot <- function(Ra){
+  data <- as.vector(Ra)
+  if (!is.vector(data)) {
+    stop("Input should be a vector data.")
+  }
+  data <- sort(data)
+  u <- data
+  n <- length(u)
+  mef <- double(n-1)
+  for (i in 1:(n-1)) {
+    data <- data[which(data > u[i])]
+    mef[i] <- mean(data) - u[i]
+  }
+  u <- u[!u == max(u)]
+  plot(u, mef, type = "l", xlab = "Threshold", ylab = "e(u)", 
+       main = "Empirical Mean Excess Function")
+  
+} 

Modified: pkg/Dowd/man/MEFPlot.Rd
===================================================================
--- pkg/Dowd/man/MEFPlot.Rd	2015-06-23 08:26:43 UTC (rev 3717)
+++ pkg/Dowd/man/MEFPlot.Rd	2015-06-23 09:22:57 UTC (rev 3718)
@@ -13,7 +13,7 @@
 Plots mean-excess function values of the data set.
 }
 \examples{
-# Plots
+# Plots mean-excess function values
    Ra <- rnorm(1000)
    MEFPlot(Ra)
 }



More information about the Returnanalytics-commits mailing list