[Returnanalytics-commits] r3774 - in pkg/Dowd: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 2 23:01:35 CEST 2015
Author: dacharya
Date: 2015-07-02 23:01:35 +0200 (Thu, 02 Jul 2015)
New Revision: 3774
Added:
pkg/Dowd/R/PCAESPlot.R
pkg/Dowd/man/PCAESPlot.Rd
Log:
Plot for PCA ES added.
Added: pkg/Dowd/R/PCAESPlot.R
===================================================================
--- pkg/Dowd/R/PCAESPlot.R (rev 0)
+++ pkg/Dowd/R/PCAESPlot.R 2015-07-02 21:01:35 UTC (rev 3774)
@@ -0,0 +1,32 @@
+#' ES plot
+#'
+#' Estimates ES 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 ES
+#' Ra <- matrix(rnorm(15*20),15,20)
+#' position.data <- rnorm(20)
+#' PCAESPlot(Ra, position.data)
+#'
+#' @export
+PCAESPlot <- function(Ra, position.data){
+ # Check that inputs have correct dimensions
+ return.data<-as.matrix(Ra)
+ pcaes.95 <- double(10)
+ pcaes.99 <- double(10)
+ for (i in 1:10) {
+ pcaes.95[i] <- PCAES(return.data, position.data, i, .95)
+ pcaes.99[i] <- PCAES(return.data, position.data, i, .99)
+ }
+ t <- 1:10
+ par(mfrow=c(2,1))
+ plot(t, pcaes.99, type="l")
+ plot(t, pcaes.95, type="l")
+
+}
\ No newline at end of file
Added: pkg/Dowd/man/PCAESPlot.Rd
===================================================================
--- pkg/Dowd/man/PCAESPlot.Rd (rev 0)
+++ pkg/Dowd/man/PCAESPlot.Rd 2015-07-02 21:01:35 UTC (rev 3774)
@@ -0,0 +1,29 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/PCAESPlot.R
+\name{PCAESPlot}
+\alias{PCAESPlot}
+\title{ES plot}
+\usage{
+PCAESPlot(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 ES plot using principal components analysis
+}
+\examples{
+# Computes PCA ES
+ Ra <- matrix(rnorm(15*20),15,20)
+ position.data <- rnorm(20)
+ PCAESPlot(Ra, position.data)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+
More information about the Returnanalytics-commits
mailing list