[Returnanalytics-commits] r2647 - pkg/FactorAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 26 00:12:37 CEST 2013


Author: chenyian
Date: 2013-07-26 00:12:37 +0200 (Fri, 26 Jul 2013)
New Revision: 2647

Modified:
   pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r
   pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r
Log:
revise summary.TimeSeriesFactorModel.r to matrix look.

Modified: pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r	2013-07-25 20:30:30 UTC (rev 2646)
+++ pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r	2013-07-25 22:12:37 UTC (rev 2647)
@@ -34,14 +34,5 @@
   print(fit.macro$r2, digits = digits, ...)
   cat("\nResidual Variance:\n")
   print(fit.macro$resid.variance, digits = digits, ...)
-  
-# n <- length(fit.macro$beta)
-# table.macro <-  as.matrix(fit.macro$alpha,nrow=n[1])
-# table.macro <- cbind(table.macro,fit.macro$beta,fit.macro$r2,fit.macro$resid.variance)
-# beta.names <- colnames(fit.macro$beta)
-# for (i in 1:length(beta.names)) {
-# beta.names[i] <- paste("beta.",beta.names[i],sep="")
-# }
-# colnames(table.macro) <- c("alpha",beta.names,"r2","resid.var")
-# print(round(table.macro,digits=digits))
+
 }

Modified: pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r	2013-07-25 20:30:30 UTC (rev 2646)
+++ pkg/FactorAnalytics/R/summary.TimeSeriesFactorModel.r	2013-07-25 22:12:37 UTC (rev 2647)
@@ -11,8 +11,6 @@
 #' 
 #' # load data from the database
 #' data(managers.df)
-#' ret.assets = managers.df[,(1:6)]
-#' factors    = managers.df[,(7:9)]
 #' # fit the factor model with OLS
 #' fit <- fitTimeSeriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
 #'                                factors.names=c("EDHEC.LS.EQ","SP500.TR"),
@@ -21,7 +19,21 @@
 #' 
 #' @export
 #' 
-summary.TimeSeriesFactorModel <- function(fit,...){
-     lapply(fit[[1]], summary,...)
+summary.TimeSeriesFactorModel <- function(fit,digits=3){
+  if(!is.null(cl <- fit.macro$call)) {
+    cat("\nCall:\n")
+    dput(cl)
   }
+  cat("\nFactor Betas\n")
+  n <- length(fit.macro$assets.names)
+  for (i in 1:n) {
+  options(digits = digits)  
+  cat("\n", fit.macro$assets.names[i], "\n")  
+  table.macro <- t(summary(fit.macro$asset.fit[[i]])$coefficients)
+  colnames(table.macro)[1] <- "alpha"
+  print(table.macro,digits = digits)
+  cat("\nR-square =", fit.macro$r2[i] ,",residual variance ="
+      , fit.macro$resid.variance[i],"\n")
+  }
+}
     



More information about the Returnanalytics-commits mailing list