[Uwgarp-commits] r203 - in pkg/GARPFRM: R man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 1 23:29:01 CEST 2014


Author: tfillebeen
Date: 2014-07-01 23:29:00 +0200 (Tue, 01 Jul 2014)
New Revision: 203

Modified:
   pkg/GARPFRM/R/riskMetricsAndHedges.R
   pkg/GARPFRM/man/plot.PCA.Rd
   pkg/GARPFRM/vignettes/HedgeMetrics.lyx
Log:
plot PCA function improved

Modified: pkg/GARPFRM/R/riskMetricsAndHedges.R
===================================================================
--- pkg/GARPFRM/R/riskMetricsAndHedges.R	2014-07-01 20:07:28 UTC (rev 202)
+++ pkg/GARPFRM/R/riskMetricsAndHedges.R	2014-07-01 21:29:00 UTC (rev 203)
@@ -210,23 +210,34 @@
 #' @param number specify the nunber of loadings
 #' @param \dots passthrough parameters to \code{\link{plot}}.
 #' @param main a main title for the plot
+#' @param separate if TRUE plot of same, and if FALSE plot separately
 #' @author Thomas Fillebeen
 #' @method plot PCA
 #' @S3method plot PCA
-plot.PCA <- function(x, y, ..., main="Beta from PCA regression"){
+plot.PCA <- function(x, y, ..., main="Beta from PCA regression",separate=TRUE){
  if(ncol(x$loading)> 3) warning("Only first 3 loadings will be graphically displayed")
   # Plot the first three factors
  if (ncol(x$loading) >= 3){
+   if(separate){
    plot(x$loading[,1], type="l", main = main, 
         xlab="Maturity/Items", ylab="Loadings")
    lines(x$loading[,2], col="blue",lty=2)
    lines(x$loading[,3], col="red",lty=2)
    legend("topleft",legend=c("PCA1","PCA2","PCA3"),bty="n",lty=c(1,2,2),col=c("black","blue","red"), cex=0.8)
+   }else{
+     plot.zoo(pca$loading[,1:3], type="l", main = main, 
+          xlab="Maturity/Items")
+   }
  }else if(ncol(x$loading) == 2){
+   if(separate){
    plot(x$loading[,1], type="l", main = main, 
         xlab="Maturity/Items", ylab="Loadings")
    lines(x$loading[,2], col="blue",lty=2)
    legend("topleft",legend=c("PCA1","PCA2"),bty="n",lty=c(1,2),col=c("black","blue"), cex=0.8)
+   }else{
+     plot.zoo(pca$loading[,1:2], type="l", main = main, 
+              xlab="Maturity/Items")
+   }
  }else{
    plot(x$loading[,1], type="l", main = main, 
         xlab="Maturity/Items", ylab="Loadings")

Modified: pkg/GARPFRM/man/plot.PCA.Rd
===================================================================
--- pkg/GARPFRM/man/plot.PCA.Rd	2014-07-01 20:07:28 UTC (rev 202)
+++ pkg/GARPFRM/man/plot.PCA.Rd	2014-07-01 21:29:00 UTC (rev 203)
@@ -3,7 +3,8 @@
 \alias{plot.PCA}
 \title{Plotting method for PCA}
 \usage{
-\method{plot}{PCA}(x, y, ..., main = "Beta from PCA regression")
+\method{plot}{PCA}(x, y, ..., main = "Beta from PCA regression",
+  separate = TRUE)
 }
 \arguments{
 \item{x}{a PCA object created by \code{\link{PCA}}}
@@ -15,6 +16,8 @@
 \item{\dots}{passthrough parameters to \code{\link{plot}}.}
 
 \item{main}{a main title for the plot}
+
+\item{separate}{if TRUE plot of same, and if FALSE plot separately}
 }
 \description{
 Plot a fitted PCA object

Modified: pkg/GARPFRM/vignettes/HedgeMetrics.lyx
===================================================================
(Binary files differ)



More information about the Uwgarp-commits mailing list