[Returnanalytics-commits] r3631 - in pkg/FactorAnalytics: R man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 17 02:32:48 CEST 2015


Author: pragnya
Date: 2015-04-17 02:32:48 +0200 (Fri, 17 Apr 2015)
New Revision: 3631

Added:
   pkg/FactorAnalytics/tests/FactorAnalytics_04_16_15.pdf
Removed:
   pkg/FactorAnalytics/tests/FactorAnalytics.pdf
Modified:
   pkg/FactorAnalytics/R/fitTsfm.R
   pkg/FactorAnalytics/R/fitTsfmMT.r
   pkg/FactorAnalytics/man/fitTsfm.Rd
   pkg/FactorAnalytics/man/fitTsfmMT.Rd
   pkg/FactorAnalytics/man/plot.tsfm.Rd
Log:
Updated package manual, edits to documentation

Modified: pkg/FactorAnalytics/R/fitTsfm.R
===================================================================
--- pkg/FactorAnalytics/R/fitTsfm.R	2015-04-15 18:27:13 UTC (rev 3630)
+++ pkg/FactorAnalytics/R/fitTsfm.R	2015-04-17 00:32:48 UTC (rev 3631)
@@ -66,12 +66,11 @@
 #' @param variable.selection the variable selection method, one of "none", 
 #' "stepwise","subsets","lars". See details. Default is "none".
 #' \code{mkt.name} is required if any of these options are to be implemented.
-#' @param control list of control parameters. The default is constructed by 
-#' the function \code{\link{fitTsfm.control}}. See the documentation for 
+#' @param control list of control parameters. Refer to 
 #' \code{\link{fitTsfm.control}} for details.
 #' @param ... arguments passed to \code{\link{fitTsfm.control}}
 #' 
-#' @return fitTsfm returns an object of class \code{"tsfm"} for which 
+#' @return \code{fitTsfm} returns an object of class \code{"tsfm"} for which 
 #' \code{print}, \code{plot}, \code{predict} and \code{summary} methods exist. 
 #' 
 #' The generic accessor functions \code{coef}, \code{fitted} and 
@@ -114,13 +113,6 @@
 #' Tibshirani, R. (2009). The elements of statistical learning (Vol. 2, No. 1). 
 #' New York: Springer.
 #' 
-#' Henriksson, R. D., & Merton, R. C. (1981). On market timing and investment 
-#' performance. II. Statistical procedures for evaluating forecasting skills. 
-#' Journal of business, 513-533.
-#' 
-#' Treynor, J., & Mazuy, K. (1966). Can mutual funds outguess the market. 
-#' Harvard business review, 44(4), 131-136.
-#' 
 #' @seealso The \code{tsfm} methods for generic functions: 
 #' \code{\link{plot.tsfm}}, \code{\link{predict.tsfm}}, 
 #' \code{\link{print.tsfm}} and \code{\link{summary.tsfm}}. 

Modified: pkg/FactorAnalytics/R/fitTsfmMT.r
===================================================================
--- pkg/FactorAnalytics/R/fitTsfmMT.r	2015-04-15 18:27:13 UTC (rev 3630)
+++ pkg/FactorAnalytics/R/fitTsfmMT.r	2015-04-17 00:32:48 UTC (rev 3631)
@@ -1,40 +1,39 @@
-#' @title Fit a time serie market timing factor model using time series regression
+#' @title Fit a market timing time series factor model
 #' 
-#' @description This is a wrapper function to fits a time series market timing factor model for one 
-#' or more asset returns or excess returns using time series regression. 
-#' Users can choose between ordinary least squares-LS, discounted least 
-#' squares-DLS (or) robust regression. An object of class 
+#' @description This is a wrapper function to fit a market timing time series 
+#' factor model for one or more asset returns or excess returns using time 
+#' series regression. Users can choose between ordinary least squares-LS, 
+#' discounted least squares-DLS (or) robust regression. An object of class 
 #' \code{"tsfm"} is returned.
 #' 
 #' @details 
-#' The Market timing accounts for the price movement of the general stock market relative to fixed income 
-#' securities. It includes down.market = max(0, R_f-R_m) as a factor, following Henriksson & Merton 
-#' (1981). The coefficient of this down-market factor can be interpreted as the 
-#' number of "free" put options on the market provided by the manager's market-timings kills.
+#' Market timing accounts for the price movement of the general stock market 
+#' relative to fixed income securities. A market-timing factor is added to the 
+#' time series regression, following Henriksson & Merton (1981). Here, we use 
+#' down.market = max(0, R_f-R_m), where Rm is the (excess) return on the market. 
+#' The coefficient of this down-market factor can be interpreted as the number 
+#' of "free" put options on the market provided by the manager's market-timings 
+#' skills.
 #' 
-#' 
-#' 
 #' @param asset.names vector containing names of assets, whose returns or 
 #' excess returns are the dependent variable.
-#' @param mkt.name name of the column for market returns; It 
-#' is required for a market timing model.
+#' @param mkt.name name of the column for market returns (required).
 #' @param rf.name name of the column of risk free rate variable to calculate 
-#' excess returns for all assets (in \code{asset.names}) and the market factor (in 
-#' \code{mkt.name}).Default is NULL, and no action is taken.
+#' excess returns for all assets (in \code{asset.names}) and the market factor 
+#' (in \code{mkt.name}). Default is NULL, and no action is taken.
 #' @param data vector, matrix, data.frame, xts, timeSeries or zoo object  
 #' containing column(s) named in \code{asset.names}, \code{factor.names} and 
 #' optionally, \code{mkt.name} and \code{rf.name}.
 #' @param fit.method the estimation method, one of "LS", "DLS" or "Robust". 
 #' See details. Default is "LS". 
-#' @param control list of control parameters. The default is constructed by 
-#' the function \code{\link{fitTsfm.control}}. See the documentation for 
-#' \code{\link{fitTsfm.control}} for details.
+#' @param control list of control parameters passed to \code{\link{fitTsfm}}. 
+#' Refer to \code{\link{fitTsfm.control}} for details.
 #' @param ... arguments passed to \code{\link{fitTsfm.control}}
 #' 
-#' @return \code{fitTsfmMT} also returns an object of class \code{"tsfm"} like 
-#' \code{fitTsfm}. The generic function such as \code{print}, \code{plot}, \code{predict} 
-#' and \code{summary} methods exist. Also, the generic accessor functions \code{coef}, 
-#' \code{fitted}, \code{residuals} and  \code{fmCov} can be applied as well.
+#' @return Similar to \code{fitTsfm}, \code{fitTsfmMT} also returns an object 
+#' of class \code{"tsfm"}, for which \code{print}, \code{plot}, \code{predict} 
+#' and \code{summary} methods exist. The generic accessor functions \code{coef}, 
+#' \code{fitted}, \code{residuals} and \code{fmCov} can be applied as well.
 #' 
 #' An object of class \code{"tsfm"} is a list containing the following 
 #' components:
@@ -46,47 +45,50 @@
 #' \item{r2}{length-N vector of R-squared values.}
 #' \item{resid.sd}{length-N vector of residual standard deviations.}
 #' \item{call}{the matched function call.}
-#' \item{data}{xts data object containing the assets and factors.}
+#' \item{data}{xts data object containing the asset(s) and factor(s) returns.}
 #' \item{asset.names}{asset.names as input.}
+#' \item{factor.names}{vector containing the names of the market-timing factor 
+#' and the market factor}
+#' \item{mkt.name}{mkt.name as input}
 #' \item{fit.method}{fit.method as input.}
-#' Where N is the number of assets and T is the 
-#' number of time periods.
+#' Where N is the number of assets and T is the number of time periods.
 #' 
-#' @author Yi-An Chen.
+#' @author Yi-An Chen, Sangeetha Srinivasan.
 #' 
 #' @references 
+#' Christopherson, J. A., Carino, D. R., & Ferson, W. E. (2009). Portfolio 
+#' performance measurement and benchmarking. McGraw Hill Professional. pp.127-133
+#' 
 #' Henriksson, R. D., & Merton, R. C. (1981). On market timing and investment 
 #' performance. II. Statistical procedures for evaluating forecasting skills. 
 #' Journal of business, 513-533.
 #' 
-#' #' Christopherson, J. A., Carino, D. R., & Ferson, W. E. (2009). Portfolio 
-#' performance measurement and benchmarking. McGraw Hill Professional. pp.127-133
+#' Treynor, J., & Mazuy, K. (1966). Can mutual funds outguess the market. 
+#' Harvard business review, 44(4), 131-136.
 #' 
 #' @seealso 
-#' The original time series function \code{\link{fitTsfm}} and its generic functions
-#'  application.
+#' The original time series factor model fitting function \code{\link{fitTsfm}} 
+#' and related methods.
 #' 
 #' @examples
 #' # load data from the database
 #' data(managers)
 #' 
-#' # example: Market-timing factors with LS fit
-#' fit <- fitTsfmMT(asset.names=colnames(managers[,(1:6)]),  
-#'                mkt.name="SP500.TR",rf.name="US.3m.TR",data=managers)
+#' # example: Market-timing time series factor model with LS fit
+#' fit <- fitTsfmMT(asset.names=colnames(managers[,(1:6)]), mkt.name="SP500.TR",
+#'                  rf.name="US.3m.TR", data=managers)
 #' summary(fit)
 #'  
 #' @importFrom PerformanceAnalytics checkData
-#' @importFrom robust lmRob step.lmRob
-#' @importFrom leaps regsubsets
-#' @importFrom lars lars cv.lars
 #' 
 #' @export
 
-fitTsfmMT <- function(asset.names,mkt.name, rf.name=NULL, 
-                    data=data, fit.method=c("LS","DLS","Robust"), 
-                    control=fitTsfm.control(...),...) {
+fitTsfmMT <- function(asset.names, mkt.name, rf.name=NULL, data=data, 
+                      fit.method=c("LS","DLS","Robust"), 
+                      control=fitTsfm.control(...), ...) {
+  
   if (is.null(mkt.name)){
-    stop("Missing argument: mkt.name has to be specified for market timing model.")
+    stop("Missing argument: mkt.name is required for market timing models.")
   }
   
   # convert data into an xts object and hereafter work with xts objects
@@ -104,23 +106,24 @@
                                      FUN.VALUE = numeric(nrow(dat.xts))))
   } 
   
- # mkt-timing factors: down.market=max(0,Rf-Rm), market.sqd=(Rm-Rf)^2
-
-    down.market <- dat.xts[,mkt.name]
-    down.market[down.market < 0 ] <- 0
-    dat.xts <- merge.xts(dat.xts,down.market)
-    colnames(dat.xts)[dim(dat.xts)[2]] <- "down.market"
-    factor.names <- c(mkt.name,"down.market")
+  # mkt-timing factors: down.market=max(0,Rf-Rm), market.sqd=(Rm-Rf)^2
   
-#   if("TM" %in% mkt.timing) {
-#     market.sqd <- data.xts[,mkt.name]^2   
-#     dat.xts <- merge(dat.xts, market.sqd)
-#     colnames(dat.xts)[dim(dat.xts)[2]] <- "market.sqd"
-#     factor.names <- c(factor.names, "market.sqd")
-#   }
+  down.market <- dat.xts[,mkt.name]
+  down.market[down.market < 0 ] <- 0
+  dat.xts <- merge.xts(dat.xts,down.market)
+  colnames(dat.xts)[dim(dat.xts)[2]] <- "down.market"
+  factor.names <- c(mkt.name,"down.market")
   
-  fit.Timing <-  fitTsfm(asset.names=asset.names,factor.names=factor.names,rf.name=NULL,
-          data=dat.xts,fit.method=fit.method,variable.selection="none",control=control)
-
-return(fit.Timing)  
+  #   if("TM" %in% mkt.timing) {
+  #     market.sqd <- data.xts[,mkt.name]^2   
+  #     dat.xts <- merge(dat.xts, market.sqd)
+  #     colnames(dat.xts)[dim(dat.xts)[2]] <- "market.sqd"
+  #     factor.names <- c(factor.names, "market.sqd")
+  #   }
+  
+  fit.MktTiming <-  fitTsfm(asset.names=asset.names, factor.names=factor.names, 
+                         rf.name=NULL, data=dat.xts, fit.method=fit.method, 
+                         variable.selection="none", control=control)
+  
+  return(fit.MktTiming)  
 }

Modified: pkg/FactorAnalytics/man/fitTsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitTsfm.Rd	2015-04-15 18:27:13 UTC (rev 3630)
+++ pkg/FactorAnalytics/man/fitTsfm.Rd	2015-04-17 00:32:48 UTC (rev 3631)
@@ -41,8 +41,7 @@
 "stepwise","subsets","lars". See details. Default is "none".
 \code{mkt.name} is required if any of these options are to be implemented.}
 
-\item{control}{list of control parameters. The default is constructed by
-the function \code{\link{fitTsfm.control}}. See the documentation for
+\item{control}{list of control parameters. Refer to
 \code{\link{fitTsfm.control}} for details.}
 
 \item{...}{arguments passed to \code{\link{fitTsfm.control}}}
@@ -51,7 +50,7 @@
 \code{fitTsfm}}
 }
 \value{
-fitTsfm returns an object of class \code{"tsfm"} for which
+\code{fitTsfm} returns an object of class \code{"tsfm"} for which
 \code{print}, \code{plot}, \code{predict} and \code{summary} methods exist.
 
 The generic accessor functions \code{coef}, \code{fitted} and
@@ -171,13 +170,6 @@
 Hastie, T., Tibshirani, R., Friedman, J., Hastie, T., Friedman, J., &
 Tibshirani, R. (2009). The elements of statistical learning (Vol. 2, No. 1).
 New York: Springer.
-
-Henriksson, R. D., & Merton, R. C. (1981). On market timing and investment
-performance. II. Statistical procedures for evaluating forecasting skills.
-Journal of business, 513-533.
-
-Treynor, J., & Mazuy, K. (1966). Can mutual funds outguess the market.
-Harvard business review, 44(4), 131-136.
 }
 \seealso{
 The \code{tsfm} methods for generic functions:

Modified: pkg/FactorAnalytics/man/fitTsfmMT.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitTsfmMT.Rd	2015-04-15 18:27:13 UTC (rev 3630)
+++ pkg/FactorAnalytics/man/fitTsfmMT.Rd	2015-04-17 00:32:48 UTC (rev 3631)
@@ -2,7 +2,7 @@
 % Please edit documentation in R/fitTsfmMT.r
 \name{fitTsfmMT}
 \alias{fitTsfmMT}
-\title{Fit a time serie market timing factor model using time series regression}
+\title{Fit a market timing time series factor model}
 \usage{
 fitTsfmMT(asset.names, mkt.name, rf.name = NULL, data = data,
   fit.method = c("LS", "DLS", "Robust"), control = fitTsfm.control(...),
@@ -12,12 +12,11 @@
 \item{asset.names}{vector containing names of assets, whose returns or
 excess returns are the dependent variable.}
 
-\item{mkt.name}{name of the column for market returns; It
-is required for a market timing model.}
+\item{mkt.name}{name of the column for market returns (required).}
 
 \item{rf.name}{name of the column of risk free rate variable to calculate
-excess returns for all assets (in \code{asset.names}) and the market factor (in
-\code{mkt.name}).Default is NULL, and no action is taken.}
+excess returns for all assets (in \code{asset.names}) and the market factor
+(in \code{mkt.name}). Default is NULL, and no action is taken.}
 
 \item{data}{vector, matrix, data.frame, xts, timeSeries or zoo object
 containing column(s) named in \code{asset.names}, \code{factor.names} and
@@ -26,17 +25,16 @@
 \item{fit.method}{the estimation method, one of "LS", "DLS" or "Robust".
 See details. Default is "LS".}
 
-\item{control}{list of control parameters. The default is constructed by
-the function \code{\link{fitTsfm.control}}. See the documentation for
-\code{\link{fitTsfm.control}} for details.}
+\item{control}{list of control parameters passed to \code{\link{fitTsfm}}.
+Refer to \code{\link{fitTsfm.control}} for details.}
 
 \item{...}{arguments passed to \code{\link{fitTsfm.control}}}
 }
 \value{
-\code{fitTsfmMT} also returns an object of class \code{"tsfm"} like
-\code{fitTsfm}. The generic function such as \code{print}, \code{plot}, \code{predict}
-and \code{summary} methods exist. Also, the generic accessor functions \code{coef},
-\code{fitted}, \code{residuals} and  \code{fmCov} can be applied as well.
+Similar to \code{fitTsfm}, \code{fitTsfmMT} also returns an object
+of class \code{"tsfm"}, for which \code{print}, \code{plot}, \code{predict}
+and \code{summary} methods exist. The generic accessor functions \code{coef},
+\code{fitted}, \code{residuals} and \code{fmCov} can be applied as well.
 
 An object of class \code{"tsfm"} is a list containing the following
 components:
@@ -48,47 +46,55 @@
 \item{r2}{length-N vector of R-squared values.}
 \item{resid.sd}{length-N vector of residual standard deviations.}
 \item{call}{the matched function call.}
-\item{data}{xts data object containing the assets and factors.}
+\item{data}{xts data object containing the asset(s) and factor(s) returns.}
 \item{asset.names}{asset.names as input.}
+\item{factor.names}{vector containing the names of the market-timing factor
+and the market factor}
+\item{mkt.name}{mkt.name as input}
 \item{fit.method}{fit.method as input.}
-Where N is the number of assets and T is the
-number of time periods.
+Where N is the number of assets and T is the number of time periods.
 }
 \description{
-This is a wrapper function to fits a time series market timing factor model for one
-or more asset returns or excess returns using time series regression.
-Users can choose between ordinary least squares-LS, discounted least
-squares-DLS (or) robust regression. An object of class
+This is a wrapper function to fit a market timing time series
+factor model for one or more asset returns or excess returns using time
+series regression. Users can choose between ordinary least squares-LS,
+discounted least squares-DLS (or) robust regression. An object of class
 \code{"tsfm"} is returned.
 }
 \details{
-The Market timing accounts for the price movement of the general stock market relative to fixed income
-securities. It includes down.market = max(0, R_f-R_m) as a factor, following Henriksson & Merton
-(1981). The coefficient of this down-market factor can be interpreted as the
-number of "free" put options on the market provided by the manager's market-timings kills.
+Market timing accounts for the price movement of the general stock market
+relative to fixed income securities. A market-timing factor is added to the
+time series regression, following Henriksson & Merton (1981). Here, we use
+down.market = max(0, R_f-R_m), where Rm is the (excess) return on the market.
+The coefficient of this down-market factor can be interpreted as the number
+of "free" put options on the market provided by the manager's market-timings
+skills.
 }
 \examples{
 # load data from the database
 data(managers)
 
-# example: Market-timing factors with LS fit
-fit <- fitTsfmMT(asset.names=colnames(managers[,(1:6)]),
-               mkt.name="SP500.TR",rf.name="US.3m.TR",data=managers)
+# example: Market-timing time series factor model with LS fit
+fit <- fitTsfmMT(asset.names=colnames(managers[,(1:6)]), mkt.name="SP500.TR",
+                 rf.name="US.3m.TR", data=managers)
 summary(fit)
 }
 \author{
-Yi-An Chen.
+Yi-An Chen, Sangeetha Srinivasan.
 }
 \references{
+Christopherson, J. A., Carino, D. R., & Ferson, W. E. (2009). Portfolio
+performance measurement and benchmarking. McGraw Hill Professional. pp.127-133
+
 Henriksson, R. D., & Merton, R. C. (1981). On market timing and investment
 performance. II. Statistical procedures for evaluating forecasting skills.
 Journal of business, 513-533.
 
-#' Christopherson, J. A., Carino, D. R., & Ferson, W. E. (2009). Portfolio
-performance measurement and benchmarking. McGraw Hill Professional. pp.127-133
+Treynor, J., & Mazuy, K. (1966). Can mutual funds outguess the market.
+Harvard business review, 44(4), 131-136.
 }
 \seealso{
-The original time series function \code{\link{fitTsfm}} and its generic functions
- application.
+The original time series factor model fitting function \code{\link{fitTsfm}}
+and related methods.
 }
 

Modified: pkg/FactorAnalytics/man/plot.tsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/plot.tsfm.Rd	2015-04-15 18:27:13 UTC (rev 3630)
+++ pkg/FactorAnalytics/man/plot.tsfm.Rd	2015-04-17 00:32:48 UTC (rev 3631)
@@ -140,7 +140,7 @@
 Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
 }
 \seealso{
-\code{\link{fitTsfm}}, \code{\link{resduals.tsfm}},
+\code{\link{fitTsfm}}, \code{\link{residuals.tsfm}},
 \code{\link{fitted.tsfm}}, \code{\link{fmCov.tsfm}} and
 \code{\link{summary.tsfm}} for time series factor model fitting and related
 S3 methods. Refer to \code{\link{fmSdDecomp}}, \code{\link{fmEsDecomp}},
@@ -155,7 +155,7 @@
 I(13) - \code{\link[PerformanceAnalytics]{chart.Histogram}},
 I(14) - \code{\link[PerformanceAnalytics]{chart.QQPlot}},
 I(15,16,17) - \code{\link[strucchange]{plot.efp}},
-I(18) - \code{\link[xts]{plot.zoo}},
+I(18) - \code{\link[zoo]{plot.zoo}},
 G(1,2) - \code{\link[graphics]{barplot}},
 G(4,5,9,10,11) - \code{\link[lattice]{barchart}},
 G(6) - \code{\link[PerformanceAnalytics]{chart.Correlation}} and

Deleted: pkg/FactorAnalytics/tests/FactorAnalytics.pdf
===================================================================
(Binary files differ)

Added: pkg/FactorAnalytics/tests/FactorAnalytics_04_16_15.pdf
===================================================================
(Binary files differ)


Property changes on: pkg/FactorAnalytics/tests/FactorAnalytics_04_16_15.pdf
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the Returnanalytics-commits mailing list