[Uwgarp-commits] r102 - in pkg/GARPFRM: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 5 17:21:02 CET 2014


Author: rossbennett34
Date: 2014-03-05 17:21:01 +0100 (Wed, 05 Mar 2014)
New Revision: 102

Modified:
   pkg/GARPFRM/NAMESPACE
   pkg/GARPFRM/R/EWMA.R
Log:
revisions to EWMA and print method

Modified: pkg/GARPFRM/NAMESPACE
===================================================================
--- pkg/GARPFRM/NAMESPACE	2014-03-05 06:38:13 UTC (rev 101)
+++ pkg/GARPFRM/NAMESPACE	2014-03-05 16:21:01 UTC (rev 102)
@@ -15,9 +15,6 @@
 export(monteCarlo)
 export(plot.capm_mlm)
 export(plot.capm_uv)
-export(plot.corEWMA)
-export(plot.covEWMA)
-export(plot.varEWMA)
 export(plotEndingPrices)
 S3method(countViolations,xts)
 S3method(fcstGarch11,DCCfit)
@@ -32,3 +29,7 @@
 S3method(getStatistics,capm_uv)
 S3method(hypTest,capm_mlm)
 S3method(hypTest,capm_uv)
+S3method(plot,corEWMA)
+S3method(plot,covEWMA)
+S3method(plot,varEWMA)
+S3method(print,EWMA)

Modified: pkg/GARPFRM/R/EWMA.R
===================================================================
--- pkg/GARPFRM/R/EWMA.R	2014-03-05 06:38:13 UTC (rev 101)
+++ pkg/GARPFRM/R/EWMA.R	2014-03-05 16:21:01 UTC (rev 102)
@@ -51,6 +51,7 @@
   } else if ((cor == FALSE) & (ncol(R) == 1)){
     class(out) <- c("varEWMA")
   }
+  class(out) <- c("EWMA", class(out))
   return(out)
 }
 
@@ -151,7 +152,8 @@
 }
 
 # EWMA plotting for covar
-#' @export
+#' @method plot covEWMA
+#' @S3method plot covEWMA
 plot.covEWMA <- function(object, ..., assets=c(1, 2), xlab="", ylab="Covariance", main="EWMA Estimate"){
   # Check if asset is a character 
   if(is.character(assets[1]) & is.character(assets[2])){
@@ -172,7 +174,8 @@
 
 
 # EWMA plotting for var
-#' @export
+#' @method plot varEWMA
+#' @S3method plot varEWMA
 plot.varEWMA <- function(object, ..., assets=c(1,2), xlab="", ylab="Covariance", main="EWMA Estimate"){
   tmp = getCov(object, assets[1])
   plot(x=time(as.zoo(tmp)),y=tmp, ...=..., type="l", xlab=xlab, ylab=ylab, main=main)
@@ -182,7 +185,8 @@
 
 
 # EWMA plotting for correlation
-#' @export
+#' @method plot corEWMA
+#' @S3method plot corEWMA
 plot.corEWMA <- function(object, ..., assets=c(1,2), xlab="", ylab="Covariance", main="EWMA Estimate"){
   # Check if asset is a character 
   if(is.character(assets[1]) & is.character(assets[2])){
@@ -200,3 +204,12 @@
   grid()
   abline(h=cor(object$R)[idx1,idx2], lwd=2, col="red")
 }
+
+#' @method print EWMA
+#' @S3method print EWMA
+print.EWMA <- function(x, ...){
+  n <- length(x$EWMA)
+  cat("Final Period EWMA Estimate: ")
+  cat(names(x$EWMA)[n], "\n")
+  print(x$EWMA[[n]])
+}



More information about the Uwgarp-commits mailing list