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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 25 20:50:32 CEST 2013


Author: chenyian
Date: 2013-07-25 20:50:32 +0200 (Thu, 25 Jul 2013)
New Revision: 2645

Modified:
   pkg/FactorAnalytics/R/print.StatFactorModel.r
   pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r
   pkg/FactorAnalytics/man/print.StatFactorModel.Rd
   pkg/FactorAnalytics/man/print.TimeSeriesFactorModel.Rd
Log:
create print.StatFactorModel.r and print.StatFactorModel.Rd

Modified: pkg/FactorAnalytics/R/print.StatFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/print.StatFactorModel.r	2013-07-25 18:18:00 UTC (rev 2644)
+++ pkg/FactorAnalytics/R/print.StatFactorModel.r	2013-07-25 18:50:32 UTC (rev 2645)
@@ -1,36 +1,40 @@
-#' print StatFactorModel object
-#' 
-#' Generic function of print method for fitStatFactorModel.
-#' 
-#' 
-#' @param fit.stat fit object created by fitMacroeconomicFactorModel.
-#' @param digits maximum digits. Default is 3.
-#' @param ...  Other variables for print methods.
-#' @author Eric Zivot and Yi-An Chen.
-#' @examples
-#' 
-#' # load data for fitStatisticalFactorModel.r
-#' # data from finmetric berndt.dat and folio.dat
-#' 
-#' data(stat.fm.data)
-#' # pca
-#' sfm.pca.fit <- fitStatisticalFactorModel(sfm.dat,k=10)
-#' print(sfm.pca.fit)
-#' 
-#' 
-print.StatFactorModel <-
-function(fit.stat, digits = max(3, .Options$digits - 3), ...)
-{
-  if(!is.null(cl <- fit.stat$call)) {
-    cat("\nCall:\n")
-    dput(cl)
-  }
-  cat("\nFactor Model:\n")
-  tmp <- c(dim(fit.stat$loadings), nrow(fit.stat$factors))
-  names(tmp) <- c("Factors", "Variables", "Periods")
-  print(tmp)
-  cat("\nFactor Loadings:\n")
-  print(fit.stat$loadings, digits = digits, ...)
-  cat("\nRegression R-squared:\n")
-  print(fit.stat$r2, digits = digits, ...)
-}
+#' print StatFactorModel object
+#' 
+#' Generic function of print method for fitStatFactorModel.
+#' 
+#' 
+#' @param fit.stat fit object created by fitMacroeconomicFactorModel.
+#' @param digits integer indicating the number of decimal places. Default is 3.
+#' @param ...  Other arguments for print methods.
+#' @author Eric Zivot and Yi-An Chen.
+#' @examples
+#' 
+#' # load data for fitStatisticalFactorModel.r
+#' # data from finmetric berndt.dat and folio.dat
+#' 
+#' data(stat.fm.data)
+#' # pca
+#' sfm.pca.fit <- fitStatisticalFactorModel(sfm.dat,k=10)
+#' print(sfm.pca.fit)
+#' 
+#' 
+print.StatFactorModel <-
+function(fit.stat, digits = max(3, .Options$digits - 3), ...)
+{
+  if(!is.null(cl <- fit.stat$call)) {
+    cat("\nCall:\n")
+    dput(cl)
+  }
+  cat("\nFactor Model:\n")
+  tmp <- c(dim(fit.stat$loadings), nrow(fit.stat$factors))
+  names(tmp) <- c("Factors", "Variables", "Periods")
+  print(tmp)
+  cat("\nRegression alphas:\n")
+  print(fit.stat$alpha , digits = digits, ...)
+  cat("\nFactor Loadings:\n")
+  print(fit.stat$loadings, digits = digits, ...)
+  cat("\nRegression R-squared:\n")
+  print(fit.stat$r2, digits = digits, ...)
+  cat("\nResidual Variance:\n")
+  print(fit.stat$resid.variance, digits = digits, ...)
+}

Modified: pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r	2013-07-25 18:18:00 UTC (rev 2644)
+++ pkg/FactorAnalytics/R/print.TimeSeriesFactorModel.r	2013-07-25 18:50:32 UTC (rev 2645)
@@ -4,7 +4,8 @@
 #' 
 #' 
 #' @param fit.macro fit object created by fitTimeSeriesFactorModel.
-#' @param digits. integer indicating the number of decimal places.  
+#' @param digits. integer indicating the number of decimal places. Default is 3.
+#' @param ... arguments to be passed to print method.   
 #' @author Eric Zivot and Yi-An Chen.
 #' @examples
 #' 
@@ -16,14 +17,31 @@
 #' print(fit.macro)
 #' 
 #' @export
-print.TimeSeriesFactorModel <- function(fit.macro,digits=3){
-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="")
+print.TimeSeriesFactorModel <- function(fit.macro,digits=max(3, .Options$digits - 3),...){
+  if(!is.null(cl <- fit.macro$call)) {
+    cat("\nCall:\n")
+    dput(cl)
+  }
+  cat("\nFactor Model:\n")
+  tmp <- c(dim(t(fit.macro$beta)), nrow(fit.macro$data))
+  names(tmp) <- c("Factors", "Variables", "Periods")
+  print(tmp)
+  cat("\nRegression alphas:\n")
+  print(fit.macro$alpha , digits = digits, ...)
+  cat("\nFactor Betas:\n")
+  print(t(fit.macro$beta), digits = digits, ...)
+  cat("\nRegression R-squared:\n")
+  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))
 }
-colnames(table.macro) <- c("alpha",beta.names,"r2","resid.var")
-print(round(table.macro,digits=digits))
-}

Modified: pkg/FactorAnalytics/man/print.StatFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/print.StatFactorModel.Rd	2013-07-25 18:18:00 UTC (rev 2644)
+++ pkg/FactorAnalytics/man/print.StatFactorModel.Rd	2013-07-25 18:50:32 UTC (rev 2645)
@@ -1,31 +1,32 @@
-\name{print.StatFactorModel}
-\alias{print.StatFactorModel}
-\title{print StatFactorModel object}
-\usage{
-  print.StatFactorModel(fit.stat,
-    digits = max(3, .Options$digits - 3), ...)
-}
-\arguments{
-  \item{fit.stat}{fit object created by
-  fitMacroeconomicFactorModel.}
-
-  \item{digits}{maximum digits. Default is 3.}
-
-  \item{...}{Other variables for print methods.}
-}
-\description{
-  Generic function of print method for fitStatFactorModel.
-}
-\examples{
-# load data for fitStatisticalFactorModel.r
-# data from finmetric berndt.dat and folio.dat
-
-data(stat.fm.data)
-# pca
-sfm.pca.fit <- fitStatisticalFactorModel(sfm.dat,k=10)
-print(sfm.pca.fit)
-}
-\author{
-  Eric Zivot and Yi-An Chen.
-}
-
+\name{print.StatFactorModel}
+\alias{print.StatFactorModel}
+\title{print StatFactorModel object}
+\usage{
+  print.StatFactorModel(fit.stat,
+    digits = max(3, .Options$digits - 3), ...)
+}
+\arguments{
+  \item{fit.stat}{fit object created by
+  fitMacroeconomicFactorModel.}
+
+  \item{digits}{integer indicating the number of decimal
+  places. Default is 3.}
+
+  \item{...}{Other arguments for print methods.}
+}
+\description{
+  Generic function of print method for fitStatFactorModel.
+}
+\examples{
+# load data for fitStatisticalFactorModel.r
+# data from finmetric berndt.dat and folio.dat
+
+data(stat.fm.data)
+# pca
+sfm.pca.fit <- fitStatisticalFactorModel(sfm.dat,k=10)
+print(sfm.pca.fit)
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+

Modified: pkg/FactorAnalytics/man/print.TimeSeriesFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/print.TimeSeriesFactorModel.Rd	2013-07-25 18:18:00 UTC (rev 2644)
+++ pkg/FactorAnalytics/man/print.TimeSeriesFactorModel.Rd	2013-07-25 18:50:32 UTC (rev 2645)
@@ -2,14 +2,17 @@
 \alias{print.TimeSeriesFactorModel}
 \title{print TimeSeriesfactorModel object}
 \usage{
-  print.TimeSeriesFactorModel(fit.macro, digits = 3)
+  print.TimeSeriesFactorModel(fit.macro,
+    digits = max(3, .Options$digits - 3), ...)
 }
 \arguments{
   \item{fit.macro}{fit object created by
   fitTimeSeriesFactorModel.}
 
   \item{digits.}{integer indicating the number of decimal
-  places.}
+  places. Default is 3.}
+
+  \item{...}{arguments to be passed to print method.}
 }
 \description{
   Generic function of print method for



More information about the Returnanalytics-commits mailing list