[Returnanalytics-commits] r2982 - in pkg/FactorAnalytics: . R man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 4 02:23:36 CEST 2013
Author: chenyian
Date: 2013-09-04 02:23:36 +0200 (Wed, 04 Sep 2013)
New Revision: 2982
Added:
pkg/FactorAnalytics/R/print.FM.attribution.r
pkg/FactorAnalytics/man/print.FM.attribution.Rd
Modified:
pkg/FactorAnalytics/NAMESPACE
pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw
Log:
add new function print.FM.attribution.r and print.FM.attribution.Rd
Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE 2013-09-04 00:02:34 UTC (rev 2981)
+++ pkg/FactorAnalytics/NAMESPACE 2013-09-04 00:23:36 UTC (rev 2982)
@@ -1,3 +1,4 @@
+S3method(print,FM.attribution)
S3method(plot,FM.attribution)
S3method(summary,FM.attribution)
export(factorModelPerformanceAttribution)
Added: pkg/FactorAnalytics/R/print.FM.attribution.r
===================================================================
--- pkg/FactorAnalytics/R/print.FM.attribution.r (rev 0)
+++ pkg/FactorAnalytics/R/print.FM.attribution.r 2013-09-04 00:23:36 UTC (rev 2982)
@@ -0,0 +1,28 @@
+#' Print FM.attribution object.
+#'
+#' Generic function of print method for factorModelPerformanceAttribution.
+#'
+#'
+#' @param fm.attr FM.attribution object created by
+#' factorModelPerformanceAttribution.
+#' @author Yi-An Chen.
+#' @examples
+#' \dontrun{
+#' # load data from the database
+#' data(managers.df)
+#' # fit the factor model with OLS
+#' fit.ts <- fitTimeSeriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+#' factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+#' data=managers.df,fit.method="OLS")
+#'
+#' fm.attr <- factorModelPerformanceAttribution(fit.ts)
+#' print(fm.attr)
+#' }
+#' @method print FM.attribution
+#' @export
+#'
+print.FM.attribution <- function(fm.attr) {
+ cat("\nMean of returns attributed to factors
+ \n")
+ print(sapply(fm.attr[[3]],function(x) apply(x,2,mean)))
+ }
Added: pkg/FactorAnalytics/man/print.FM.attribution.Rd
===================================================================
--- pkg/FactorAnalytics/man/print.FM.attribution.Rd (rev 0)
+++ pkg/FactorAnalytics/man/print.FM.attribution.Rd 2013-09-04 00:23:36 UTC (rev 2982)
@@ -0,0 +1,31 @@
+\name{print.FM.attribution}
+\alias{print.FM.attribution}
+\title{Print FM.attribution object.}
+\usage{
+ \method{print}{FM.attribution} (fm.attr)
+}
+\arguments{
+ \item{fm.attr}{FM.attribution object created by
+ factorModelPerformanceAttribution.}
+}
+\description{
+ Generic function of print method for
+ factorModelPerformanceAttribution.
+}
+\examples{
+\dontrun{
+# load data from the database
+ data(managers.df)
+ # fit the factor model with OLS
+ fit.ts <- fitTimeSeriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+ factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+ data=managers.df,fit.method="OLS")
+
+ fm.attr <- factorModelPerformanceAttribution(fit.ts)
+ print(fm.attr)
+ }
+}
+\author{
+ Yi-An Chen.
+}
+
Modified: pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw
===================================================================
--- pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw 2013-09-04 00:02:34 UTC (rev 2981)
+++ pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw 2013-09-04 00:23:36 UTC (rev 2982)
@@ -389,7 +389,7 @@
ts.attr <- factorModelPerformanceAttribution(fit.time)
names(ts.attr)
@
-There are 3 items generated by the function. \verb at cum.ret.attr.f@ will return a N x K matrix with cummulative returns attributed to factors. \verb at cum.spec.ret@ will return a N x 1 matrix with cummulative specific returns. \verb at attr.list@ will return a list which contains returns atttribution to each factors and specific returns asset by asset.
+There are 3 items generated by the function. \verb at cum.ret.attr.f@ will return a N x K matrix with cummulative returns attributed to factors. \verb at cum.spec.ret@ will return a N x 1 matrix with cummulative specific returns. \verb at attr.list@ will return a list which contains returns atttribution to each factors and specific returns asset by asset. In addition, a \emph{FM.attribution} class will be generated and generic function \verb at print()@, \verb at summary()@ and \verb at plot()@ can be applied to it.
\end{document}
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list