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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 2 23:01:58 CEST 2015


Author: dacharya
Date: 2015-07-02 23:01:58 +0200 (Thu, 02 Jul 2015)
New Revision: 3775

Added:
   pkg/Dowd/R/PCAVaRPlot.R
   pkg/Dowd/man/PCAVaRPlot.Rd
Log:
Plot for PCA VaR added.

Added: pkg/Dowd/R/PCAVaRPlot.R
===================================================================
--- pkg/Dowd/R/PCAVaRPlot.R	                        (rev 0)
+++ pkg/Dowd/R/PCAVaRPlot.R	2015-07-02 21:01:58 UTC (rev 3775)
@@ -0,0 +1,32 @@
+#' VaR plot
+#' 
+#' Estimates VaR plot using principal components analysis
+#' 
+#' @param Ra Matrix return data set where each row is interpreted as a set of daily observations, and each column as the returns to each position in a portfolio
+#' @param position.data Position-size vector, giving amount invested in each position
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # Computes PCA VaR
+#'    Ra <- matrix(rnorm(15*20),15,20)
+#'    position.data <- rnorm(20)
+#'    PCAVaRPlot(Ra, position.data)
+#'
+#' @export
+PCAVaRPlot <- function(Ra, position.data){
+  # Check that inputs have correct dimensions
+  return.data<-as.matrix(Ra)
+  pcavar.95 <- double(10)
+  pcavar.99 <- double(10)
+  for (i in 1:10) {
+    pcavar.95[i] <- PCAVaR(return.data, position.data, i, .95)
+    pcavar.99[i] <- PCAVaR(return.data, position.data, i, .99)
+  }
+  t <- 1:10
+  par(mfrow=c(2,1))
+  plot(t, pcavar.99, type="l")
+  plot(t, pcavar.95, type="l")
+  
+}
\ No newline at end of file

Added: pkg/Dowd/man/PCAVaRPlot.Rd
===================================================================
--- pkg/Dowd/man/PCAVaRPlot.Rd	                        (rev 0)
+++ pkg/Dowd/man/PCAVaRPlot.Rd	2015-07-02 21:01:58 UTC (rev 3775)
@@ -0,0 +1,29 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/PCAVaRPlot.R
+\name{PCAVaRPlot}
+\alias{PCAVaRPlot}
+\title{VaR plot}
+\usage{
+PCAVaRPlot(Ra, position.data)
+}
+\arguments{
+\item{Ra}{Matrix return data set where each row is interpreted as a set of daily observations, and each column as the returns to each position in a portfolio}
+
+\item{position.data}{Position-size vector, giving amount invested in each position}
+}
+\description{
+Estimates VaR plot using principal components analysis
+}
+\examples{
+# Computes PCA VaR
+   Ra <- matrix(rnorm(15*20),15,20)
+   position.data <- rnorm(20)
+   PCAVaRPlot(Ra, position.data)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+



More information about the Returnanalytics-commits mailing list