[Returnanalytics-commits] r2318 - pkg/PerformanceAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jan 28 23:56:57 CET 2013
Author: peter_carl
Date: 2013-01-28 23:56:57 +0100 (Mon, 28 Jan 2013)
New Revision: 2318
Modified:
pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R
pkg/PerformanceAnalytics/R/chart.RollingMean.R
Log:
- added fill parameter to roxygen
Modified: pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R 2013-01-28 22:40:13 UTC (rev 2317)
+++ pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R 2013-01-28 22:56:57 UTC (rev 2318)
@@ -13,6 +13,9 @@
#' center.
#' @param colorset color palette to use, set by default to rational choices
#' @param \dots any other passthru parameters
+#' @param fill a three-component vector or list (recycled otherwise) providing
+#' filling values at the left/within/to the right of the data range. See the
+#' fill argument of \code{\link{na.fill}} for details.
#' @details The previous parameter \code{na.pad} has been replaced with \code{fill}; use \code{fill = NA} instead of
#' \code{na.pad = TRUE}, or \code{fill = NULL} instead of \code{na.pad = FALSE}.
#' @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/chart.RollingMean.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingMean.R 2013-01-28 22:40:13 UTC (rev 2317)
+++ pkg/PerformanceAnalytics/R/chart.RollingMean.R 2013-01-28 22:56:57 UTC (rev 2318)
@@ -8,12 +8,14 @@
#' @param width number of periods to apply rolling function window over
#' @param xaxis if true, draws the x axis
#' @param ylim set the y-axis limit, same as in \code{\link{plot}}
-#' @param na.pad TRUE/FALSE If TRUE it adds any times that would not otherwise
-#' have been in the result with a value of NA. If FALSE those times are
-#' dropped.
#' @param lwd set the line width, same as in \code{\link{plot}}. Specified in
#' order of the main line and the two confidence bands.
#' @param \dots any other passthru parameters
+#' @param fill a three-component vector or list (recycled otherwise) providing
+#' filling values at the left/within/to the right of the data range. See the
+#' fill argument of \code{\link{na.fill}} for details.
+#' @details The previous parameter \code{na.pad} has been replaced with \code{fill}; use \code{fill = NA} instead of
+#' \code{na.pad = TRUE}, or \code{fill = NULL} instead of \code{na.pad = FALSE}.
#' @author Peter Carl
#' @keywords ts multivariate distribution models hplot
#' @examples
@@ -23,7 +25,7 @@
#'
#' @export
chart.RollingMean <-
-function (R, width = 12, xaxis = TRUE, ylim = NULL, lwd=c(2,1,1), ...)
+function (R, width = 12, xaxis = TRUE, ylim = NULL, lwd=c(2,1,1), ..., fill = NA)
{ # @author Peter Carl
# DESCRIPTION:
@@ -42,10 +44,9 @@
columnnames = colnames(x)
# Calculate
+ x.mean = rollapply(x[,1,drop=FALSE], width = width, FUN = "mean", fill=fill, align = "right")
+ x.stdev = rollapply(x[,1,drop=FALSE], width = width, FUN = "sd.xts", fill=fill, align = "right")
- x.mean = rollapply(na.omit(x[,1,drop=FALSE]), width = width, FUN = "mean", fill = if(na.pad) NA, align = "right")
- x.stdev = rollapply(na.omit(x[,1,drop=FALSE]), width = width, FUN = "sd.xts", fill = if(na.pad) NA, align = "right")
-
# @todo: allow user to set confidence interval
# @todo: add chart for StdDev w confidence bands: x.stdev +- 2* x.stdev/sqrt(2*n)
lower.band = x.mean - 2 * x.stdev/sqrt(width)
@@ -55,9 +56,8 @@
# Set ylim correctly to allow for confidence bands
if(is.null(ylim[1]))
- ylim = range(result,na.rm=TRUE)
+ ylim = range(result, na.rm=TRUE)
-
freq = periodicity(R)
switch(freq$scale,
@@ -73,7 +73,7 @@
main = paste(columnnames[1], " Rolling ",width,"-",freq.lab," Performance",sep="")
# The first row is the annualized returns
- chart.TimeSeries(result, ylim = ylim, xaxis = xaxis, ylab = "Return", lty = c(1,2,2), colorset = c("black","darkgray","darkgray"), main=main , ...)
+ chart.TimeSeries(result, ylim = ylim, xaxis = xaxis, ylab = "Return", lty = c(1,2,2), colorset = c("black","darkgray","darkgray"), main=main, ... = ...)
}
More information about the Returnanalytics-commits
mailing list