From noreply at r-forge.r-project.org Mon Apr 1 18:17:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Apr 2013 18:17:43 +0200 (CEST) Subject: [Returnanalytics-commits] r2333 - pkg/PortfolioAnalytics/sandbox Message-ID: <20130401161744.01FF8184CE5@r-forge.r-project.org> Author: braverock Date: 2013-04-01 18:17:43 +0200 (Mon, 01 Apr 2013) New Revision: 2333 Removed: pkg/PortfolioAnalytics/sandbox/attribution/ Log: - delete attribution directory after move to pkg/ dire and rename to PortfolioAttribution From noreply at r-forge.r-project.org Mon Apr 1 18:57:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Apr 2013 18:57:25 +0200 (CEST) Subject: [Returnanalytics-commits] r2334 - in pkg/PerformanceAnalytics: R man Message-ID: <20130401165725.85BC2184FFB@r-forge.r-project.org> Author: braverock Date: 2013-04-01 18:57:25 +0200 (Mon, 01 Apr 2013) New Revision: 2334 Modified: pkg/PerformanceAnalytics/R/ActivePremium.R pkg/PerformanceAnalytics/R/CAPM.alpha.R pkg/PerformanceAnalytics/R/CAPM.beta.R pkg/PerformanceAnalytics/R/table.CAPM.R pkg/PerformanceAnalytics/man/ActivePremium.Rd pkg/PerformanceAnalytics/man/CAPM.alpha.Rd pkg/PerformanceAnalytics/man/CAPM.beta.Rd pkg/PerformanceAnalytics/man/table.CAPM.Rd Log: - add SFM aliases to CAPM fns, thanks to Doug Martin for the suggestion - update docs Modified: pkg/PerformanceAnalytics/R/ActivePremium.R =================================================================== --- pkg/PerformanceAnalytics/R/ActivePremium.R 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/R/ActivePremium.R 2013-04-01 16:57:25 UTC (rev 2334) @@ -1,4 +1,4 @@ -#' Active Premium +#' Active Premium or Active Return #' #' The return on an investment's annualized return minus the benchmark's #' annualized return. @@ -6,6 +6,7 @@ #' Active Premium = Investment's annualized return - Benchmark's annualized #' return #' +#' Also commonly referred to as 'active return'. #' #' @param Ra return vector of the portfolio #' @param Rb return vector of the benchmark asset @@ -24,12 +25,10 @@ #' ActivePremium(managers[,1,drop=FALSE], managers[,8,drop=FALSE]) #' ActivePremium(managers[,1:6], managers[,8,drop=FALSE]) #' ActivePremium(managers[,1:6], managers[,8:7,drop=FALSE]) -#' -#' @export -#' -#' - -ActivePremium <- function (Ra, Rb, scale = NA) +#' @rdname ActivePremium +#' @aliases ActivePremium, ActiveReturn +#' @export +ActiveReturn <- ActivePremium <- function (Ra, Rb, scale = NA) { # @author Peter Carl # FUNCTION Modified: pkg/PerformanceAnalytics/R/CAPM.alpha.R =================================================================== --- pkg/PerformanceAnalytics/R/CAPM.alpha.R 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/R/CAPM.alpha.R 2013-04-01 16:57:25 UTC (rev 2334) @@ -6,7 +6,10 @@ #' portion of the managers returns that are not attributable to "Beta", or the #' portion of performance attributable to a benchmark. #' -#' +#' While the classical CAPM has been almost completely discredited by the +#' literature, it is an example of a simple single factor model, +#' comparing an asset to any arbitrary benchmark. +#' #' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of #' asset returns #' @param Rb return vector of the benchmark asset Modified: pkg/PerformanceAnalytics/R/CAPM.beta.R =================================================================== --- pkg/PerformanceAnalytics/R/CAPM.beta.R 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/R/CAPM.beta.R 2013-04-01 16:57:25 UTC (rev 2334) @@ -21,12 +21,16 @@ #' Alternatively, \code{CAPM.beta.bear} provides the calculation on negative #' market returns. #' -#' The \code{TimingRatio} can help assess whether the manager is a good timer +#' The \code{TimingRatio} may help assess whether the manager is a good timer #' of asset allocation decisions. The ratio, which is calculated as #' \deqn{TimingRatio =\frac{\beta^{+}}{\beta^{-}}}{Timing Ratio = beta+/beta-} #' is best when greater than one in a rising market and less than one in a #' falling market. #' +#' While the classical CAPM has been almost completely discredited by the +#' literature, it is an example of a simple single factor model, +#' comparing an asset to any arbitrary benchmark. +#' #' @aliases CAPM.beta CAPM.beta.bull CAPM.beta.bear TimingRatio #' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of #' asset returns Modified: pkg/PerformanceAnalytics/R/table.CAPM.R =================================================================== --- pkg/PerformanceAnalytics/R/table.CAPM.R 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/R/table.CAPM.R 2013-04-01 16:57:25 UTC (rev 2334) @@ -1,7 +1,7 @@ -#' Asset-Pricing Model Summary: Statistics and Stylized Facts +#' Single Factor Asset-Pricing Model Summary: Statistics and Stylized Facts #' -#' Takes a set of returns and relates them to a market benchmark. Provides a -#' set of measures related to the excess return single index model, or CAPM. +#' Takes a set of returns and relates them to a benchmark return. Provides a +#' set of measures related to an excess return single factor model, or CAPM. #' #' This table will show statistics pertaining to an asset against a set of #' benchmarks, or statistics for a set of assets against a benchmark. @@ -21,24 +21,18 @@ #' @examples #' #' data(managers) -#' table.CAPM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) +#' table.SFM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) #' -#' result = table.CAPM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) +#' result = table.SFM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) #' textplot(result, rmar = 0.8, cmar = 1.5, max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1) -#' title(main="CAPM-Related Statistics") +#' title(main="Single Factor Model Related Statistics") #' -#' +#' @rdname table.CAPM +#' @aliases table.CAPM, table.SFM #' @export -table.CAPM <- function (Ra, Rb, scale = NA, Rf = 0, digits = 4) +table.SFM <- table.CAPM <- function (Ra, Rb, scale = NA, Rf = 0, digits = 4) {# @author Peter Carl - # DESCRIPTION: - # Asset-Pricing Model Summary: Statistics and Stylized Facts - # - # Takes a set of returns and relates them to a market benchmark. - # Provides a set of measures related to the excess return single index - # model, or CAPM. - # Inputs: # Ra: a vector of returns to test, e.g., the asset to be examined # Rb: a matrix, data.frame, or timeSeries of benchmarks to test the asset Modified: pkg/PerformanceAnalytics/man/ActivePremium.Rd =================================================================== --- pkg/PerformanceAnalytics/man/ActivePremium.Rd 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/man/ActivePremium.Rd 2013-04-01 16:57:25 UTC (rev 2334) @@ -1,8 +1,9 @@ -\name{ActivePremium} -\alias{ActivePremium} -\title{Active Premium} +\name{ActiveReturn} +\alias{ActivePremium,} +\alias{ActiveReturn} +\title{Active Premium or Active Return} \usage{ - ActivePremium(Ra, Rb, scale = NA) + ActiveReturn(Ra, Rb, scale = NA) } \arguments{ \item{Ra}{return vector of the portfolio} @@ -19,6 +20,8 @@ \details{ Active Premium = Investment's annualized return - Benchmark's annualized return + + Also commonly referred to as 'active return'. } \examples{ data(managers) Modified: pkg/PerformanceAnalytics/man/CAPM.alpha.Rd =================================================================== --- pkg/PerformanceAnalytics/man/CAPM.alpha.Rd 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/man/CAPM.alpha.Rd 2013-04-01 16:57:25 UTC (rev 2334) @@ -20,6 +20,11 @@ measuring the portion of the managers returns that are not attributable to "Beta", or the portion of performance attributable to a benchmark. + + While the classical CAPM has been almost completely + discredited by the literature, it is an example of a + simple single factor model, comparing an asset to any + arbitrary benchmark. } \examples{ # First we load the data Modified: pkg/PerformanceAnalytics/man/CAPM.beta.Rd =================================================================== --- pkg/PerformanceAnalytics/man/CAPM.beta.Rd 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/man/CAPM.beta.Rd 2013-04-01 16:57:25 UTC (rev 2334) @@ -48,12 +48,17 @@ markets. Alternatively, \code{CAPM.beta.bear} provides the calculation on negative market returns. - The \code{TimingRatio} can help assess whether the + The \code{TimingRatio} may help assess whether the manager is a good timer of asset allocation decisions. The ratio, which is calculated as \deqn{TimingRatio =\frac{\beta^{+}}{\beta^{-}}}{Timing Ratio = beta+/beta-} is best when greater than one in a rising market and less than one in a falling market. + + While the classical CAPM has been almost completely + discredited by the literature, it is an example of a + simple single factor model, comparing an asset to any + arbitrary benchmark. } \examples{ data(managers) Modified: pkg/PerformanceAnalytics/man/table.CAPM.Rd =================================================================== --- pkg/PerformanceAnalytics/man/table.CAPM.Rd 2013-04-01 16:17:43 UTC (rev 2333) +++ pkg/PerformanceAnalytics/man/table.CAPM.Rd 2013-04-01 16:57:25 UTC (rev 2334) @@ -1,8 +1,9 @@ -\name{table.CAPM} -\alias{table.CAPM} -\title{Asset-Pricing Model Summary: Statistics and Stylized Facts} +\name{table.SFM} +\alias{table.CAPM,} +\alias{table.SFM} +\title{Single Factor Asset-Pricing Model Summary: Statistics and Stylized Facts} \usage{ - table.CAPM(Ra, Rb, scale = NA, Rf = 0, digits = 4) + table.SFM(Ra, Rb, scale = NA, Rf = 0, digits = 4) } \arguments{ \item{Ra}{a vector of returns to test, e.g., the asset to @@ -19,9 +20,9 @@ \item{digits}{number of digits to round results to} } \description{ - Takes a set of returns and relates them to a market - benchmark. Provides a set of measures related to the - excess return single index model, or CAPM. + Takes a set of returns and relates them to a benchmark + return. Provides a set of measures related to an excess + return single factor model, or CAPM. } \details{ This table will show statistics pertaining to an asset @@ -30,11 +31,11 @@ } \examples{ data(managers) -table.CAPM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) +table.SFM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) -result = table.CAPM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) +result = table.SFM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]) textplot(result, rmar = 0.8, cmar = 1.5, max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1) -title(main="CAPM-Related Statistics") +title(main="Single Factor Model Related Statistics") } \author{ Peter Carl From noreply at r-forge.r-project.org Sat Apr 6 16:35:22 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 6 Apr 2013 16:35:22 +0200 (CEST) Subject: [Returnanalytics-commits] r2335 - pkg/PortfolioAnalytics/inst/doc Message-ID: <20130406143523.06486184F9B@r-forge.r-project.org> Author: braverock Date: 2013-04-06 16:35:22 +0200 (Sat, 06 Apr 2013) New Revision: 2335 Added: pkg/PortfolioAnalytics/inst/doc/DesignThoughts.pdf Log: - add compiled pdf of design thoughts vignette Added: pkg/PortfolioAnalytics/inst/doc/DesignThoughts.pdf =================================================================== (Binary files differ) Property changes on: pkg/PortfolioAnalytics/inst/doc/DesignThoughts.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From noreply at r-forge.r-project.org Wed Apr 17 14:25:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Apr 2013 14:25:54 +0200 (CEST) Subject: [Returnanalytics-commits] r2336 - pkg/PerformanceAnalytics/R Message-ID: <20130417122554.61EB3185189@r-forge.r-project.org> Author: braverock Date: 2013-04-17 14:25:53 +0200 (Wed, 17 Apr 2013) New Revision: 2336 Modified: pkg/PerformanceAnalytics/R/Return.portfolio.R Log: - use sum of the weights rather than 1 for first return after a conversation with Chinmay Patel to help account for leverage Modified: pkg/PerformanceAnalytics/R/Return.portfolio.R =================================================================== --- pkg/PerformanceAnalytics/R/Return.portfolio.R 2013-04-06 14:35:22 UTC (rev 2335) +++ pkg/PerformanceAnalytics/R/Return.portfolio.R 2013-04-17 12:25:53 UTC (rev 2336) @@ -184,8 +184,9 @@ result = wealthindex result[2:length(result)] = result[2:length(result)] / lag(result)[2:length(result)] - 1 - result[1] = result[1] - 1 - w = matrix(rep(NA), ncol(wealthindex.assets) * nrow(wealthindex.assets), ncol = ncol(wealthindex.assets), nrow = nrow(wealthindex.assets)) + #result[1] = result[1] - 1 + result[1] = result[1] / sum(abs(weights[1,])) #divide by the sum of the first weighting vector to account for possible leverage + w = matrix(rep(NA), ncol(wealthindex.assets) * nrow(wealthindex.assets), ncol = ncol(wealthindex.assets), nrow = nrow(wealthindex.assets)) w[1, ] = weights w[2:length(wealthindex), ] = (wealthindex.weighted / rep(wealthindex, ncol(wealthindex.weighted)))[1:(length(wealthindex) - 1), ] weightedreturns = R[, colnames(weights)] * w