[Returnanalytics-commits] r3316 - in pkg/PerformanceAnalytics: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 20 15:48:26 CET 2014


Author: braverock
Date: 2014-02-20 15:48:26 +0100 (Thu, 20 Feb 2014)
New Revision: 3316

Removed:
   pkg/PerformanceAnalytics/inst/
Modified:
   pkg/PerformanceAnalytics/DESCRIPTION
   pkg/PerformanceAnalytics/NAMESPACE
   pkg/PerformanceAnalytics/R/CAPM.alpha.R
   pkg/PerformanceAnalytics/R/CAPM.beta.R
   pkg/PerformanceAnalytics/R/CAPM.dynamic.R
   pkg/PerformanceAnalytics/R/CAPM.epsilon.R
   pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R
   pkg/PerformanceAnalytics/R/CAPM.utils.R
   pkg/PerformanceAnalytics/R/checkData.R
   pkg/PerformanceAnalytics/R/lpm.R
   pkg/PerformanceAnalytics/man/CAPM.RiskPremium.Rd
   pkg/PerformanceAnalytics/man/CAPM.alpha.Rd
   pkg/PerformanceAnalytics/man/CAPM.beta.Rd
   pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd
   pkg/PerformanceAnalytics/man/CAPM.epsilon.Rd
   pkg/PerformanceAnalytics/man/CAPM.jensenAlpha.Rd
   pkg/PerformanceAnalytics/man/checkData.Rd
   pkg/PerformanceAnalytics/man/lpm.Rd
Log:
- add SFM aliases for all CAPM functions, and export them
- minor doc edits
- bump version as we prepare for new CRAN release

Modified: pkg/PerformanceAnalytics/DESCRIPTION
===================================================================
--- pkg/PerformanceAnalytics/DESCRIPTION	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/DESCRIPTION	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,7 +1,7 @@
 Package: PerformanceAnalytics
 Type: Package
 Title: Econometric tools for performance and risk analysis.
-Version: 1.1.2
+Version: 1.1.3
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson
 Maintainer: Brian G. Peterson <brian at braverock.com>

Modified: pkg/PerformanceAnalytics/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/NAMESPACE	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/NAMESPACE	2014-02-20 14:48:26 UTC (rev 3316)
@@ -72,6 +72,13 @@
 export(Return.read)
 export(Return.rebalancing)
 export(Return.relative)
+export(SFM.CML)
+export(SFM.CML.slope)
+export(SFM.alpha)
+export(SFM.beta)
+export(SFM.dynamic)
+export(SFM.epsilon)
+export(SFM.jensenAlpha)
 export(Selectivity)
 export(SemiDeviation)
 export(SemiVariance)
@@ -200,6 +207,22 @@
 export(tim12equal)
 export(tim6equal)
 export(tim8equal)
+export(tol10qualitative)
+export(tol11qualitative)
+export(tol12qualitative)
+export(tol14rainbow)
+export(tol15rainbow)
+export(tol18rainbow)
+export(tol1qualitative)
+export(tol21rainbow)
+export(tol2qualitative)
+export(tol3qualitative)
+export(tol4qualitative)
+export(tol5qualitative)
+export(tol6qualitative)
+export(tol7qualitative)
+export(tol8qualitative)
+export(tol9qualitative)
 importFrom(stats,sd)
 importFrom(utils,packageDescription)
 importFrom(zoo,rollapply)

Modified: pkg/PerformanceAnalytics/R/CAPM.alpha.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.alpha.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/CAPM.alpha.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,6 +1,6 @@
-#' calculate CAPM alpha
+#' calculate single factor model (CAPM) alpha
 #' 
-#' This is a wrapper for calculating a CAPM alpha.
+#' This is a wrapper for calculating a single factor model (CAPM) alpha.
 #' 
 #' "Alpha" purports to be a measure of a manager's skill by measuring the
 #' portion of the managers returns that are not attributable to "Beta", or the
@@ -43,9 +43,10 @@
 #'     CAPM.alpha(managers[,1:6], 
 #' 			managers[,8:7,drop=FALSE], 
 #' 			Rf = managers[,10,drop=FALSE])
-#' 
-#' @export
-CAPM.alpha <- function (Ra, Rb, Rf = 0)
+#'   		
+#' @rdname CAPM.alpha
+#' @export SFM.alpha CAPM.alpha
+CAPM.alpha <- SFM.alpha <- function (Ra, Rb, Rf = 0)
 { # @author Peter Carl
 
     # DESCRIPTION:

Modified: pkg/PerformanceAnalytics/R/CAPM.beta.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.beta.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/CAPM.beta.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,7 +1,7 @@
-#' calculate CAPM beta
+#' calculate single factor model (CAPM) beta
 #' 
-#' CAPM Beta is the beta of an asset to the variance and covariance of an
-#' initial portfolio.  Used to determine diversification potential.
+#' The single factor model or CAPM Beta is the beta of an asset to the variance 
+#' and covariance of an initial portfolio.  Used to determine diversification potential.
 #' 
 #' This function uses a linear intercept model to achieve the same results as
 #' the symbolic model used by \code{\link{BetaCoVariance}}
@@ -83,10 +83,10 @@
 #' 			Rf = managers[, "US 3m TR", drop=FALSE], 
 #' 			fit="conditional", 
 #' 			main="Conditional Beta")
-#' 
-#' @export
-CAPM.beta <-
-function (Ra, Rb, Rf = 0)
+#'   		
+#' @rdname CAPM.beta
+#' @export CAPM.beta SFM.beta
+CAPM.beta <- SFM.beta <- function (Ra, Rb, Rf = 0)
 { # @author Peter Carl
 
     # DESCRIPTION:

Modified: pkg/PerformanceAnalytics/R/CAPM.dynamic.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.dynamic.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/CAPM.dynamic.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,101 +1,108 @@
-#' Time-varying conditional beta
-#' 
-#' CAPM is estimated assuming that betas and alphas change over time. It is 
-#' assumed that the market prices of securities fully reflect readily available
-#' and public information. A matrix of market information variables, \eqn{Z}
-#' measures this information. Possible variables in \eqn{Z} could be the
-#' divident yield, Tresaury yield, etc. The betas of stocks and managed
-#' portfolios are allowed to change with market conditions:
-#' \deqn{\beta_{p}(z_{t})=b_{0p}+B_{p}'z_{t}}{beta(zt) = b0 + Bp'zt}
-#' where \eqn{z_{t}=Z_{t}-E[Z]}{zt = Zt - E[Z]} - a normalized vector of the 
-#' deviations of \eqn{Z_{t}}{Zt}, \eqn{B_{p}}{Bp} - a vector with the same 
-#' dimension as \eqn{Z_{t}}{Zt}. The coefficient \eqn{b_{0p}}{b0} can be 
-#' interpreted as the "average beta" or the beta when all infromation variables
-#' are at their means. The elements of \eqn{B_{p}}{Bp} measure the sensitivity 
-#' of the conditional beta to the deviations of the \eqn{Z_{t}}{Zt} from their
-#' means. 
-#' In the similar way the time-varying conditional alpha is modeled:
-#' \deqn{\alpha_{pt}=\alpha_{p}(z_{t})=\alpha_{0p}+A_{p}'z_{t}}{alpha(zt) = 
-#' a0 + Ap'zt}
-#' The modified regression is therefore:
-#' \deqn{r_{pt+1}=\alpha_{0p}+A_{p}'z_{t}+b_{0p}r_{bt+1}+B_{p}'[z_{t}r_{bt+1}]+
-#' \mu_{pt+1}}
-#' 
-#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
-#' the asset returns
-#' @param Rb an xts, vector, matrix, data frame, timeSeries or zoo object of 
-#' the benchmark asset return
-#' @param Rf risk free rate, in same period as your returns
-#' @param Z an xts, vector, matrix, data frame, timeSeries or zoo object of 
-#' k variables that reflect public information
-#' @param lags number of lags before the current period on which the alpha and
-#' beta are conditioned
-#' @param \dots any other passthrough parameters
-#' @author Andrii Babii
-#' @seealso \code{\link{CAPM.beta}}
-#' @references J. Christopherson, D. Carino, W. Ferson. \emph{Portfolio 
-#' Performance Measurement and Benchmarking}. 2009. McGraw-Hill. Chapter 12. 
-#' \cr Wayne E. Ferson and Rudi Schadt, "Measuring Fund Strategy and 
-#' Performance in Changing Economic Conditions," \emph{Journal of Finance}, 
-#' vol. 51, 1996, pp.425-462 \cr
-#' @examples
-#' 
-#' data(managers)
-#' CAPM.dynamic(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12, Z=managers[, 9:10])
-#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,7,drop=FALSE], Rf=managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
-#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
-#'
-#' @export
-CAPM.dynamic <- function (Ra, Rb, Rf = 0, Z, lags = 1, ...)
-{ # @author Andrii Babii
-    
-    # FUNCTION
-  
-    Ra = checkData(Ra)
-    Rb = checkData(Rb)
-    Z = checkData(Z)
-    Z = na.omit(Z)
-    if (!is.null(dim(Rf))) 
-      Rf = checkData(Rf)
-    Ra.ncols = NCOL(Ra)
-    Rb.ncols = NCOL(Rb)
-    pairs = expand.grid(1:Ra.ncols)
-    
-    xRa = Return.excess(Ra, Rf)[1:(nrow(Ra) - 1)]
-    xRb = Return.excess(Rb, Rf)[1:(nrow(Rb) - 1)]
-    z = Z - matrix(rep(mean(Z), nrow(Z)), nrow(Z), ncol(Z), byrow = TRUE)
-    # Construct the matrix with information regressors (lagged values)
-    inform = lag(z)
-    if (lags > 1){
-      for (i in 2:lags) {
-        inform = cbind(inform, lag(z, i))
-      }
-    }
-    z = inform[(lags + 1):nrow(z), ]
-        
-    dynamic <- function (xRa, xRb, z){
-      y = xRa[1:nrow(z)]
-      X = cbind(z, coredata(xRb[1:nrow(z)]), z * matrix(rep(xRb[1:nrow(z)], ncol(z)), nrow(z), ncol(z)))
-      X.df = as.data.frame(X)
-      model = lm(xRa[1:nrow(z)] ~ 1 + ., data = X.df)
-      return(coef(model))
-    }
-    result = apply(pairs, 1, FUN = function(n, xRa, xRb, z) 
-      dynamic(xRa[, n[1]], xRb[, 1], z), xRa = xRa, xRb = xRb, z = z)
-    result = t(result)
-    
-    if (ncol(Rb) > 1){
-      for (i in 2:ncol(xRb)){
-        res = apply(pairs, 1, FUN = function(n, xRa, xRb, z) 
-          dynamic(xRa[, n[1]], xRb[, i], z), xRa = xRa, xRb = xRb, z = z)
-        res = t(res)
-        result = rbind(result, res)
-      }
-    }
-    
-    a = paste(rep(colnames(Z), lags), "alpha at t -", expand.grid(1:ncol(Z), 1:lags)[, 2])
-    b = paste(rep(colnames(Z), lags), "beta at t -", expand.grid(1:ncol(Z), 1:lags)[, 2])
-    colnames(result) = c("Average alpha", a, "Average beta", b)
-    rownames(result) = paste(rep(colnames(Ra), ncol(Rb)), "to",  rep(colnames(Rb), each = ncol(Ra)))
-    return(result)
+#' Time-varying conditional single factor model beta
+#' 
+#' CAPM is estimated assuming that betas and alphas change over time. It is 
+#' assumed that the market prices of securities fully reflect readily available
+#' and public information. A matrix of market information variables, \eqn{Z}
+#' measures this information. Possible variables in \eqn{Z} could be the
+#' divident yield, Tresaury yield, etc. The betas of stocks and managed
+#' portfolios are allowed to change with market conditions:
+#' 
+#' \deqn{\beta_{p}(z_{t})=b_{0p}+B_{p}'z_{t}}{beta(zt) = b0 + Bp'zt}
+#' 
+#' where \eqn{z_{t}=Z_{t}-E[Z]}{zt = Zt - E[Z]} 
+#' 
+#' - a normalized vector of the deviations of \eqn{Z_{t}}{Zt}, \eqn{B_{p}}{Bp} 
+#' 
+#' - a vector with the same dimension as \eqn{Z_{t}}{Zt}. 
+#' 
+#' The coefficient \eqn{b_{0p}}{b0} can be 
+#' interpreted as the "average beta" or the beta when all infromation variables
+#' are at their means. The elements of \eqn{B_{p}}{Bp} measure the sensitivity 
+#' of the conditional beta to the deviations of the \eqn{Z_{t}}{Zt} from their
+#' means. 
+#' In the similar way the time-varying conditional alpha is modeled:
+#' \deqn{\alpha_{pt}=\alpha_{p}(z_{t})=\alpha_{0p}+A_{p}'z_{t}}{alpha(zt) = 
+#' a0 + Ap'zt}
+#' The modified regression is therefore:
+#' \deqn{r_{pt+1}=\alpha_{0p}+A_{p}'z_{t}+b_{0p}r_{bt+1}+B_{p}'[z_{t}r_{bt+1}]+
+#' \mu_{pt+1}}
+#' 
+#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' the asset returns
+#' @param Rb an xts, vector, matrix, data frame, timeSeries or zoo object of 
+#' the benchmark asset return
+#' @param Rf risk free rate, in same period as your returns
+#' @param Z an xts, vector, matrix, data frame, timeSeries or zoo object of 
+#' k variables that reflect public information
+#' @param lags number of lags before the current period on which the alpha and
+#' beta are conditioned
+#' @param \dots any other passthrough parameters
+#' @author Andrii Babii
+#' @seealso \code{\link{CAPM.beta}}
+#' @references J. Christopherson, D. Carino, W. Ferson. \emph{Portfolio 
+#' Performance Measurement and Benchmarking}. 2009. McGraw-Hill. Chapter 12. 
+#' \cr Wayne E. Ferson and Rudi Schadt, "Measuring Fund Strategy and 
+#' Performance in Changing Economic Conditions," \emph{Journal of Finance}, 
+#' vol. 51, 1996, pp.425-462 \cr
+#' @examples
+#' 
+#' data(managers)
+#' CAPM.dynamic(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12, Z=managers[, 9:10])
+#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,7,drop=FALSE], Rf=managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+#' 
+#' @rdname CAPM.dynamic 
+#' @export CAPM.dynamic SFM.dynamic 
+CAPM.dynamic <- SFM.dynamic <- function (Ra, Rb, Rf = 0, Z, lags = 1, ...)
+{ # @author Andrii Babii
+    
+    # FUNCTION
+  
+    Ra = checkData(Ra)
+    Rb = checkData(Rb)
+    Z = checkData(Z)
+    Z = na.omit(Z)
+    if (!is.null(dim(Rf))) 
+      Rf = checkData(Rf)
+    Ra.ncols = NCOL(Ra)
+    Rb.ncols = NCOL(Rb)
+    pairs = expand.grid(1:Ra.ncols)
+    
+    xRa = Return.excess(Ra, Rf)[1:(nrow(Ra) - 1)]
+    xRb = Return.excess(Rb, Rf)[1:(nrow(Rb) - 1)]
+    z = Z - matrix(rep(mean(Z), nrow(Z)), nrow(Z), ncol(Z), byrow = TRUE)
+    # Construct the matrix with information regressors (lagged values)
+    inform = lag(z)
+    if (lags > 1){
+      for (i in 2:lags) {
+        inform = cbind(inform, lag(z, i))
+      }
+    }
+    z = inform[(lags + 1):nrow(z), ]
+        
+    dynamic <- function (xRa, xRb, z){
+      y = xRa[1:nrow(z)]
+      X = cbind(z, coredata(xRb[1:nrow(z)]), z * matrix(rep(xRb[1:nrow(z)], ncol(z)), nrow(z), ncol(z)))
+      X.df = as.data.frame(X)
+      model = lm(xRa[1:nrow(z)] ~ 1 + ., data = X.df)
+      return(coef(model))
+    }
+    result = apply(pairs, 1, FUN = function(n, xRa, xRb, z) 
+      dynamic(xRa[, n[1]], xRb[, 1], z), xRa = xRa, xRb = xRb, z = z)
+    result = t(result)
+    
+    if (ncol(Rb) > 1){
+      for (i in 2:ncol(xRb)){
+        res = apply(pairs, 1, FUN = function(n, xRa, xRb, z) 
+          dynamic(xRa[, n[1]], xRb[, i], z), xRa = xRa, xRb = xRb, z = z)
+        res = t(res)
+        result = rbind(result, res)
+      }
+    }
+    
+    a = paste(rep(colnames(Z), lags), "alpha at t -", expand.grid(1:ncol(Z), 1:lags)[, 2])
+    b = paste(rep(colnames(Z), lags), "beta at t -", expand.grid(1:ncol(Z), 1:lags)[, 2])
+    colnames(result) = c("Average alpha", a, "Average beta", b)
+    rownames(result) = paste(rep(colnames(Ra), ncol(Rb)), "to",  rep(colnames(Rb), each = ncol(Ra)))
+    return(result)
 }
\ No newline at end of file

Modified: pkg/PerformanceAnalytics/R/CAPM.epsilon.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.epsilon.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/CAPM.epsilon.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -22,15 +22,15 @@
 #' @examples
 #'
 #' data(portfolio_bacon)
-#' print(CAPM.epsilon(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.013
+#' print(SFM.epsilon(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.013
 #'
 #' data(managers)
-#' print(CAPM.epsilon(managers['1996',1], managers['1996',8]))
-#' print(CAPM.epsilon(managers['1996',1:5], managers['1996',8]))
+#' print(SFM.epsilon(managers['1996',1], managers['1996',8]))
+#' print(SFM.epsilon(managers['1996',1:5], managers['1996',8]))
 #'
-#' @export 
-
-CAPM.epsilon <-
+#' @rdname CAPM.epsilon
+#' @export CAPM.epsilon SFM.epsilon
+CAPM.epsilon <- SFM.epsilon <-
 function (Ra, Rb, Rf = 0, ...)
 {
     Ra = checkData(Ra, method="matrix")

Modified: pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -22,15 +22,16 @@
 #' @examples
 #'
 #' data(portfolio_bacon)
-#' print(CAPM.jensenAlpha(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.014
+#' print(SFM.jensenAlpha(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.014
 #'
 #' data(managers)
-#' print(CAPM.jensenAlpha(managers['1996',1], managers['1996',8]))
-#' print(CAPM.jensenAlpha(managers['1996',1:5], managers['1996',8]))
+#' print(SFM.jensenAlpha(managers['1996',1], managers['1996',8]))
+#' print(SFM.jensenAlpha(managers['1996',1:5], managers['1996',8]))
 #'
-#' @export 
+#' @rdname CAPM.jensenAlpha
+#' @export CAPM.jensenAlpha SFM.jensenAlpha
 
-CAPM.jensenAlpha <-
+CAPM.jensenAlpha <- SFM.jensenAlpha <-
 function (Ra, Rb, Rf = 0, ...)
 {
     calcul = FALSE

Modified: pkg/PerformanceAnalytics/R/CAPM.utils.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.utils.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/CAPM.utils.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -2,8 +2,8 @@
 # CAPM.alpha and CAPM.beta could probably have gone in here too, but they're already in separate files
 
 #' @rdname CAPM.RiskPremium
-#' @export
-CAPM.CML.slope <- function (Rb, Rf = 0 )
+#' @export CAPM.CML.slope SFM.CML.slope
+CAPM.CML.slope <- SFM.CML.slope <- function (Rb, Rf = 0 )
 { #author Brian G. Peterson
 
     #the Capital Market Line slope is a wrapper for the Sharpe Ratio on the benchmark asset
@@ -16,8 +16,8 @@
 }
 
 #' @rdname CAPM.RiskPremium
-#' @export
-CAPM.CML <- function (Ra, Rb, Rf = 0)
+#' @export CAPM.CML SFM.CML 
+CAPM.CML <- SFM.CML <-function (Ra, Rb, Rf = 0)
 { #@author Brian G. Peterson
 
     Ra = checkData(Ra)
@@ -50,13 +50,18 @@
 
 
 
-#' utility functions for CAPM CML, SML, and RiskPremium
+#' utility functions for single factor (CAPM) CML, SML, and RiskPremium
 #' 
 #' The Capital Asset Pricing Model, from which the popular
 #' \code{\link{SharpeRatio}} is derived, is a theory of market equilibrium.
 #' These utility functions provide values for various measures proposed in the
 #' CAPM.
 #' 
+#' At it's core, the CAPM is a single factor linear model.  In light of 
+#' the general ustility and wide use of single factor model, all 
+#' functions in the CAPM suite will also be available with SFM (single factor model)
+#' prefixes.
+#' 
 #' The CAPM provides a justification for passive or index investing by positing
 #' that assets that are not on the efficient frontier will either rise or lower
 #' in price until they are on the efficient frontier of the market portfolio.
@@ -87,22 +92,22 @@
 #' Chapter 7 of Ruppert(2004) gives an extensive overview of CAPM, its
 #' assumptions and deficiencies.
 #' 
-#' \code{CAPM.RiskPremium} is the premium returned to the investor over the
+#' \code{SFM.RiskPremium} is the premium returned to the investor over the
 #' risk free asset
 #' 
 #' \deqn{\overline{(R_{a}-R_{f})}}{mean(Ra-Rf=0)}
 #' 
-#' \code{CAPM.CML} calculates the expected return of the asset against the
+#' \code{SFM.CML} calculates the expected return of the asset against the
 #' benchmark Capital Market Line
 #' 
-#' \code{CAPM.CML.slope} calculates the slope of the Capital Market Line for
+#' \code{SFM.CML.slope} calculates the slope of the Capital Market Line for
 #' looking at how a particular asset compares to the CML
 #' 
-#' \code{CAPM.SML.slope} calculates the slope of the Security Market Line for
+#' \code{SFM.SML.slope} calculates the slope of the Security Market Line for
 #' looking at how a particular asset compares to the SML created by the
 #' benchmark
 #' 
-#' @aliases CAPM.utils CAPM.RiskPremium CAPM.CML CAPM.CML.slope CAPM.SML.slope
+#' @aliases CAPM.utils CAPM.RiskPremium CAPM.CML CAPM.CML.slope CAPM.SML.slope SFM.utils SFM.RiskPremium SFM.CML SFM.CML.slope SFM.SML.slope
 #' @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/checkData.R
===================================================================
--- pkg/PerformanceAnalytics/R/checkData.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/checkData.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -3,8 +3,8 @@
 #' This function was created to make the different kinds of data classes at
 #' least \emph{seem} more fungible.  It allows the user to pass in a data
 #' object without being concerned that the function requires a matrix,
-#' data.frame, or timeSeries object.  By using this, the function "knows" what
-#' data format it has to work with.
+#' data.frame, vector, xts, or timeSeries object.  By using \code{checkData}, 
+#' the function "knows" what data format it has to work with.
 #' 
 #' 
 #' @param x a vector, matrix, data.frame, xts, timeSeries or zoo object to be
@@ -13,7 +13,7 @@
 #' @param quiet TRUE/FALSE if false, it will throw warnings when errors are
 #' noticed, default TRUE
 #' @param method type of coerced data object to return, one of
-#' c("zoo","matrix","vector"), default "zoo"
+#' c("xts", "zoo", "data.frame", "matrix", "vector"), default "xts"
 #' @param \dots any other passthru parameters
 #' @author Peter Carl
 #' @keywords ts multivariate distribution models

Modified: pkg/PerformanceAnalytics/R/lpm.R
===================================================================
--- pkg/PerformanceAnalytics/R/lpm.R	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/R/lpm.R	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,16 +1,23 @@
-#' calculate the lower partial moment of a time series
+#' calculate a lower partial moment for a time series
+#' 
+#' Caclulate a Lower Partial Moment around the mean or a specified threshold.
+#' 
+#' Lower partial moments capture negative deviation from a reference point.  
+#' That reference point may be the mean, or some specified threshold that
+#' has other meaning for the investor.
+#' 
+#' @references Huffman S.P. & Moll C.R., 
+#' "The impact of Asymmetry on Expected Stock Returns: An Investigation of Alternative Risk Measures", 
+#' Algorithmic Finance 1, 2011 p. 79-93
 #'
-#' Code to calculate the Lower Partion Moments around the mean or a specified threshold
-#' from Huffman S,P & Moll C.R. 2011 "The impact of Asymmetry on Expected Stock Returns: An Investigation of Alternative Risk Measures" Algorithmic Finance 1 (2011) 79-93
-#'
 #' @param R xts data
 #' @param n the n-th moment to return
 #' @param threshold threshold can be the mean or any point as desired
 #' @param about_mean TRUE/FALSE calculate LPM about the mean under the threshold or use the threshold to calculate the LPM around (if FALSE)
 #'
-#' @author Kyle Balkissoon /email{kylebalkissoon at gmail.com} /email{kyle at corporateknights.com}
+#' @author Kyle Balkissoon \email{kylebalkisoon@@gmail.com}
 #' @export
-lpm <- function(R,n,threshold,about_mean=FALSE){
+lpm <- function(R,n=2,threshold=0,about_mean=FALSE){
 
   if(about_mean==TRUE){
     #Calculate Number of obs less than threshold

Modified: pkg/PerformanceAnalytics/man/CAPM.RiskPremium.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.RiskPremium.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/CAPM.RiskPremium.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -4,7 +4,12 @@
 \alias{CAPM.RiskPremium}
 \alias{CAPM.SML.slope}
 \alias{CAPM.utils}
-\title{utility functions for CAPM CML, SML, and RiskPremium}
+\alias{SFM.CML}
+\alias{SFM.CML.slope}
+\alias{SFM.RiskPremium}
+\alias{SFM.SML.slope}
+\alias{SFM.utils}
+\title{utility functions for single factor (CAPM) CML, SML, and RiskPremium}
 \usage{
   CAPM.CML.slope(Rb, Rf = 0)
 
@@ -29,6 +34,11 @@
   values for various measures proposed in the CAPM.
 }
 \details{
+  At it's core, the CAPM is a single factor linear model.
+  In light of the general ustility and wide use of single
+  factor model, all functions in the CAPM suite will also
+  be available with SFM (single factor model) prefixes.
+
   The CAPM provides a justification for passive or index
   investing by positing that assets that are not on the
   efficient frontier will either rise or lower in price
@@ -68,21 +78,21 @@
   Chapter 7 of Ruppert(2004) gives an extensive overview of
   CAPM, its assumptions and deficiencies.
 
-  \code{CAPM.RiskPremium} is the premium returned to the
+  \code{SFM.RiskPremium} is the premium returned to the
   investor over the risk free asset
 
   \deqn{\overline{(R_{a}-R_{f})}}{mean(Ra-Rf=0)}
 
-  \code{CAPM.CML} calculates the expected return of the
+  \code{SFM.CML} calculates the expected return of the
   asset against the benchmark Capital Market Line
 
-  \code{CAPM.CML.slope} calculates the slope of the Capital
+  \code{SFM.CML.slope} calculates the slope of the Capital
   Market Line for looking at how a particular asset
   compares to the CML
 
-  \code{CAPM.SML.slope} calculates the slope of the
-  Security Market Line for looking at how a particular
-  asset compares to the SML created by the benchmark
+  \code{SFM.SML.slope} calculates the slope of the Security
+  Market Line for looking at how a particular asset
+  compares to the SML created by the benchmark
 }
 \examples{
 data(managers)

Modified: pkg/PerformanceAnalytics/man/CAPM.alpha.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.alpha.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/CAPM.alpha.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,6 +1,6 @@
 \name{CAPM.alpha}
 \alias{CAPM.alpha}
-\title{calculate CAPM alpha}
+\title{calculate single factor model (CAPM) alpha}
 \usage{
   CAPM.alpha(Ra, Rb, Rf = 0)
 }
@@ -13,7 +13,8 @@
   \item{Rf}{risk free rate, in same period as your returns}
 }
 \description{
-  This is a wrapper for calculating a CAPM alpha.
+  This is a wrapper for calculating a single factor model
+  (CAPM) alpha.
 }
 \details{
   "Alpha" purports to be a measure of a manager's skill by

Modified: pkg/PerformanceAnalytics/man/CAPM.beta.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.beta.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/CAPM.beta.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -3,7 +3,7 @@
 \alias{CAPM.beta.bear}
 \alias{CAPM.beta.bull}
 \alias{TimingRatio}
-\title{calculate CAPM beta}
+\title{calculate single factor model (CAPM) beta}
 \usage{
   CAPM.beta(Ra, Rb, Rf = 0)
 
@@ -22,9 +22,9 @@
   \item{Rf}{risk free rate, in same period as your returns}
 }
 \description{
-  CAPM Beta is the beta of an asset to the variance and
-  covariance of an initial portfolio.  Used to determine
-  diversification potential.
+  The single factor model or CAPM Beta is the beta of an
+  asset to the variance and covariance of an initial
+  portfolio.  Used to determine diversification potential.
 }
 \details{
   This function uses a linear intercept model to achieve

Modified: pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -1,70 +1,78 @@
-\name{CAPM.dynamic}
-\alias{CAPM.dynamic}
-\title{Time-varying conditional beta}
-\usage{
-  CAPM.dynamic(Ra, Rb, Rf = 0, Z, lags = 1, ...)
-}
-\arguments{
-  \item{Ra}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of the asset returns}
-
-  \item{Rb}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of the benchmark asset return}
-
-  \item{Rf}{risk free rate, in same period as your returns}
-
-  \item{Z}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of k variables that reflect public
-  information}
-
-  \item{lags}{number of lags before the current period on
-  which the alpha and beta are conditioned}
-
-  \item{\dots}{any other passthrough parameters}
-}
-\description{
-  CAPM is estimated assuming that betas and alphas change
-  over time. It is assumed that the market prices of
-  securities fully reflect readily available and public
-  information. A matrix of market information variables,
-  \eqn{Z} measures this information. Possible variables in
-  \eqn{Z} could be the divident yield, Tresaury yield, etc.
-  The betas of stocks and managed portfolios are allowed to
-  change with market conditions:
-  \deqn{\beta_{p}(z_{t})=b_{0p}+B_{p}'z_{t}}{beta(zt) = b0
-  + Bp'zt} where \eqn{z_{t}=Z_{t}-E[Z]}{zt = Zt - E[Z]} - a
-  normalized vector of the deviations of \eqn{Z_{t}}{Zt},
-  \eqn{B_{p}}{Bp} - a vector with the same dimension as
-  \eqn{Z_{t}}{Zt}. The coefficient \eqn{b_{0p}}{b0} can be
-  interpreted as the "average beta" or the beta when all
-  infromation variables are at their means. The elements of
-  \eqn{B_{p}}{Bp} measure the sensitivity of the
-  conditional beta to the deviations of the \eqn{Z_{t}}{Zt}
-  from their means. In the similar way the time-varying
-  conditional alpha is modeled:
-  \deqn{\alpha_{pt}=\alpha_{p}(z_{t})=\alpha_{0p}+A_{p}'z_{t}}{alpha(zt)
-  = a0 + Ap'zt} The modified regression is therefore:
-  \deqn{r_{pt+1}=\alpha_{0p}+A_{p}'z_{t}+b_{0p}r_{bt+1}+B_{p}'[z_{t}r_{bt+1}]+
-  \mu_{pt+1}}
-}
-\examples{
-data(managers)
-CAPM.dynamic(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12, Z=managers[, 9:10])
-CAPM.dynamic(managers[80:120,1:6], managers[80:120,7,drop=FALSE], Rf=managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
-CAPM.dynamic(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
-}
-\author{
-  Andrii Babii
-}
-\references{
-  J. Christopherson, D. Carino, W. Ferson. \emph{Portfolio
-  Performance Measurement and Benchmarking}. 2009.
-  McGraw-Hill. Chapter 12. \cr Wayne E. Ferson and Rudi
-  Schadt, "Measuring Fund Strategy and Performance in
-  Changing Economic Conditions," \emph{Journal of Finance},
-  vol. 51, 1996, pp.425-462 \cr
-}
-\seealso{
-  \code{\link{CAPM.beta}}
-}
-
+\name{CAPM.dynamic}
+\alias{CAPM.dynamic}
+\title{Time-varying conditional single factor model beta}
+\usage{
+  CAPM.dynamic(Ra, Rb, Rf = 0, Z, lags = 1, ...)
+}
+\arguments{
+  \item{Ra}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of the asset returns}
+
+  \item{Rb}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of the benchmark asset return}
+
+  \item{Rf}{risk free rate, in same period as your returns}
+
+  \item{Z}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of k variables that reflect public
+  information}
+
+  \item{lags}{number of lags before the current period on
+  which the alpha and beta are conditioned}
+
+  \item{\dots}{any other passthrough parameters}
+}
+\description{
+  CAPM is estimated assuming that betas and alphas change
+  over time. It is assumed that the market prices of
+  securities fully reflect readily available and public
+  information. A matrix of market information variables,
+  \eqn{Z} measures this information. Possible variables in
+  \eqn{Z} could be the divident yield, Tresaury yield, etc.
+  The betas of stocks and managed portfolios are allowed to
+  change with market conditions:
+}
+\details{
+  \deqn{\beta_{p}(z_{t})=b_{0p}+B_{p}'z_{t}}{beta(zt) = b0
+  + Bp'zt}
+
+  where \eqn{z_{t}=Z_{t}-E[Z]}{zt = Zt - E[Z]}
+
+  - a normalized vector of the deviations of
+  \eqn{Z_{t}}{Zt}, \eqn{B_{p}}{Bp}
+
+  - a vector with the same dimension as \eqn{Z_{t}}{Zt}.
+
+  The coefficient \eqn{b_{0p}}{b0} can be interpreted as
+  the "average beta" or the beta when all infromation
+  variables are at their means. The elements of
+  \eqn{B_{p}}{Bp} measure the sensitivity of the
+  conditional beta to the deviations of the \eqn{Z_{t}}{Zt}
+  from their means. In the similar way the time-varying
+  conditional alpha is modeled:
+  \deqn{\alpha_{pt}=\alpha_{p}(z_{t})=\alpha_{0p}+A_{p}'z_{t}}{alpha(zt)
+  = a0 + Ap'zt} The modified regression is therefore:
+  \deqn{r_{pt+1}=\alpha_{0p}+A_{p}'z_{t}+b_{0p}r_{bt+1}+B_{p}'[z_{t}r_{bt+1}]+
+  \mu_{pt+1}}
+}
+\examples{
+data(managers)
+CAPM.dynamic(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12, Z=managers[, 9:10])
+CAPM.dynamic(managers[80:120,1:6], managers[80:120,7,drop=FALSE], Rf=managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+CAPM.dynamic(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+}
+\author{
+  Andrii Babii
+}
+\references{
+  J. Christopherson, D. Carino, W. Ferson. \emph{Portfolio
+  Performance Measurement and Benchmarking}. 2009.
+  McGraw-Hill. Chapter 12. \cr Wayne E. Ferson and Rudi
+  Schadt, "Measuring Fund Strategy and Performance in
+  Changing Economic Conditions," \emph{Journal of Finance},
+  vol. 51, 1996, pp.425-462 \cr
+}
+\seealso{
+  \code{\link{CAPM.beta}}
+}
+

Modified: pkg/PerformanceAnalytics/man/CAPM.epsilon.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.epsilon.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/CAPM.epsilon.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -31,11 +31,11 @@
 }
 \examples{
 data(portfolio_bacon)
-print(CAPM.epsilon(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.013
+print(SFM.epsilon(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.013
 
 data(managers)
-print(CAPM.epsilon(managers['1996',1], managers['1996',8]))
-print(CAPM.epsilon(managers['1996',1:5], managers['1996',8]))
+print(SFM.epsilon(managers['1996',1], managers['1996',8]))
+print(SFM.epsilon(managers['1996',1:5], managers['1996',8]))
 }
 \author{
   Matthieu Lestel

Modified: pkg/PerformanceAnalytics/man/CAPM.jensenAlpha.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.jensenAlpha.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/CAPM.jensenAlpha.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -30,11 +30,11 @@
 }
 \examples{
 data(portfolio_bacon)
-print(CAPM.jensenAlpha(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.014
+print(SFM.jensenAlpha(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.014
 
 data(managers)
-print(CAPM.jensenAlpha(managers['1996',1], managers['1996',8]))
-print(CAPM.jensenAlpha(managers['1996',1:5], managers['1996',8]))
+print(SFM.jensenAlpha(managers['1996',1], managers['1996',8]))
+print(SFM.jensenAlpha(managers['1996',1:5], managers['1996',8]))
 }
 \author{
   Matthieu Lestel

Modified: pkg/PerformanceAnalytics/man/checkData.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/checkData.Rd	2014-02-20 12:53:23 UTC (rev 3315)
+++ pkg/PerformanceAnalytics/man/checkData.Rd	2014-02-20 14:48:26 UTC (rev 3316)
@@ -17,7 +17,8 @@
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 3316


More information about the Returnanalytics-commits mailing list