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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 25 20:26:01 CEST 2013


Author: chenyian
Date: 2013-06-25 20:26:00 +0200 (Tue, 25 Jun 2013)
New Revision: 2433

Added:
   pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r
   pkg/FactorAnalytics/man/predict.TimeSeriesFactorModel.Rd
Modified:
   pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r
   pkg/FactorAnalytics/man/summary.TimeSeriesFactorModel.Rd
Log:
1. revise summary.TimeSeriesFactorModel.Rd
2. add predict.TimeSeriesFactorModel.Rd and predict.TimeSeriesFactorModel.r

Added: pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r	                        (rev 0)
+++ pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r	2013-06-25 18:26:00 UTC (rev 2433)
@@ -0,0 +1,30 @@
+#' predict method for TimeSeriesModel object.
+#' 
+#' Generic function of predict method for fitTimeSeriesFactorModel. It utilizes
+#' function \code{predict.lm}.
+#' 
+#' @param fit "TimeSeriesFactorModel" object created by fitTimeSeiresFactorModel.
+#' @param newdata An optional data frame in which to look for variables with which to predict. 
+#' If omitted, the fitted values are used.
+#' @param ... Any other arguments used in \code{predict.lm}
+#' @author Yi-An Chen.
+#' ' 
+#' @examples
+#' 
+#' # load data from the database
+#' data(managers.df)
+#' ret.assets = managers.df[,(1:6)]
+#' # fit the factor model with OLS
+#' fit <- fitTimeseriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+#'                                factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+#'                                data=managers.df,fit.method="OLS")
+#' 
+#' predict(fit)
+#' predict(fit,newdata,interval="confidence")
+#' 
+#' @export
+#' 
+
+predict.TimeSeriesFactorModel <- function(fit,...){
+  lapply(fit[[1]], predict,...)
+}
\ No newline at end of file

Modified: pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r	2013-06-25 14:19:19 UTC (rev 2432)
+++ pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r	2013-06-25 18:26:00 UTC (rev 2433)
@@ -1,10 +1,10 @@
-#' summary TimeSeriesModel object.
+#' summary method for TimeSeriesModel object.
 #' 
-#' Generic function of summary method for fitMacroeconomicFactorModel.
+#' Generic function of summary method for fitTimeSeriesFactorModel.
 #' 
 #' 
-#' @param fit.macro fit object created by fitMacroeconomicFactorModel.
-#' @author Eric Zivot and Yi-An Chen.
+#' @param fit fit object created by fitTimeSeiresFactorModel.
+#' @author Yi-An Chen.
 #' @examples
 #' 
 #' # load data from the database
@@ -12,13 +12,15 @@
 #' ret.assets = managers.df[,(1:6)]
 #' factors    = managers.df[,(7:9)]
 #' # fit the factor model with OLS
-#' fit.macro <- fitTimeSeriesFactorModel(ret.assets,factors,fit.method="OLS",
-#'                                  variable.selection="all subsets")
-#' summary(fit.macro)
+#' fit <- fitTimeSeriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+#'                                factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+#'                                data=managers.df,fit.method="OLS")
+#' summary(fit)
 #' 
+#' @export
 #' 
 summary.TimeSeriesFactorModel <- 
-  function(fit.macro){
-     lapply(fit.macro[[1]], summary)
+  function(fit){
+     lapply(fit[[1]], summary)
   }
     

Added: pkg/FactorAnalytics/man/predict.TimeSeriesFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/predict.TimeSeriesFactorModel.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/man/predict.TimeSeriesFactorModel.Rd	2013-06-25 18:26:00 UTC (rev 2433)
@@ -0,0 +1,37 @@
+\name{predict.TimeSeriesFactorModel}
+\alias{predict.TimeSeriesFactorModel}
+\title{predict method for TimeSeriesModel object.}
+\usage{
+  predict.TimeSeriesFactorModel(fit, ...)
+}
+\arguments{
+  \item{fit}{"TimeSeriesFactorModel" object created by
+  fitTimeSeiresFactorModel.}
+
+  \item{newdata}{An optional data frame in which to look
+  for variables with which to predict. If omitted, the
+  fitted values are used.}
+
+  \item{...}{Any other arguments used in \code{predict.lm}}
+}
+\description{
+  Generic function of predict method for
+  fitTimeSeriesFactorModel. It utilizes function
+  \code{predict.lm}.
+}
+\examples{
+# load data from the database
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
+# fit the factor model with OLS
+fit <- fitTimeseriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+                               factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+                               data=managers.df,fit.method="OLS")
+
+predict(fit)
+predict(fit,newdata,interval="confidence")
+}
+\author{
+  Yi-An Chen. '
+}
+

Modified: pkg/FactorAnalytics/man/summary.TimeSeriesFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/summary.TimeSeriesFactorModel.Rd	2013-06-25 14:19:19 UTC (rev 2432)
+++ pkg/FactorAnalytics/man/summary.TimeSeriesFactorModel.Rd	2013-06-25 18:26:00 UTC (rev 2433)
@@ -1,16 +1,16 @@
 \name{summary.TimeSeriesFactorModel}
 \alias{summary.TimeSeriesFactorModel}
-\title{summary TimeSeriesModel object.}
+\title{summary method for TimeSeriesModel object.}
 \usage{
-  summary.TimeSeriesFactorModel(fit.macro)
+  summary.TimeSeriesFactorModel(fit)
 }
 \arguments{
-  \item{fit.macro}{fit object created by
-  fitMacroeconomicFactorModel.}
+  \item{fit}{fit object created by
+  fitTimeSeiresFactorModel.}
 }
 \description{
   Generic function of summary method for
-  fitMacroeconomicFactorModel.
+  fitTimeSeriesFactorModel.
 }
 \examples{
 # load data from the database
@@ -18,11 +18,12 @@
 ret.assets = managers.df[,(1:6)]
 factors    = managers.df[,(7:9)]
 # fit the factor model with OLS
-fit.macro <- fitTimeSeriesFactorModel(ret.assets,factors,fit.method="OLS",
-                                 variable.selection="all subsets")
-summary(fit.macro)
+fit <- fitTimeSeriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+                               factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+                               data=managers.df,fit.method="OLS")
+summary(fit)
 }
 \author{
-  Eric Zivot and Yi-An Chen.
+  Yi-An Chen.
 }
 



More information about the Returnanalytics-commits mailing list