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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 24 00:18:47 CET 2015


Author: chenyian
Date: 2015-02-24 00:18:46 +0100 (Tue, 24 Feb 2015)
New Revision: 3602

Added:
   pkg/FactorAnalytics/R/print.tsfmUpDn.r
   pkg/FactorAnalytics/man/print.tsfmUpDn.Rd
Modified:
   pkg/FactorAnalytics/NAMESPACE
   pkg/FactorAnalytics/R/summary.tsfmUpDn.r
   pkg/FactorAnalytics/man/summary.tsfmUpDn.Rd
Log:
Add print.tsfmUpDn.r and print.tsfmUpDn.Rd

Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE	2015-02-23 22:57:04 UTC (rev 3601)
+++ pkg/FactorAnalytics/NAMESPACE	2015-02-23 23:18:46 UTC (rev 3602)
@@ -23,6 +23,7 @@
 S3method(print,summary.tsfm)
 S3method(print,summary.tsfmUpDn)
 S3method(print,tsfm)
+S3method(print,tsfmUpDn)
 S3method(residuals,sfm)
 S3method(residuals,tsfm)
 S3method(summary,pafm)

Added: pkg/FactorAnalytics/R/print.tsfmUpDn.r
===================================================================
--- pkg/FactorAnalytics/R/print.tsfmUpDn.r	                        (rev 0)
+++ pkg/FactorAnalytics/R/print.tsfmUpDn.r	2015-02-23 23:18:46 UTC (rev 3602)
@@ -0,0 +1,62 @@
+#' @title Prints out a fitted up and down market time series factor model object
+#' 
+#' @description S3 \code{print} method for object of class \code{tsfmUpDn}. Prints 
+#' the call, factor model dimension, regression coefficients, r-squared and 
+#' residual volatilities from the fitted object. 
+#' 
+#' @param x an object of class \code{tsfmUpDn} produced by \code{fitTsfmUpDn}.
+#' @param digits an integer value, to indicate the required number of 
+#' significant digits. Default is 3.
+#' @param ... optional arguments passed to the \code{print} method.
+#'    
+#' @author Yi-An Chen and Sangeetha Srinivasan
+#' 
+#' @seealso \code{\link{fitTsfmUpDn}}, \code{\link{summary.tsfmUpDn}}
+#' 
+#' @examples
+#' data(managers)
+#' # example: Up and down market factor model with OLS fit
+#' fitUpDn <- fitTsfmUpDn(asset.names=colnames(managers[,(1:6)]),mkt.name="SP500.TR",
+#'                        data=managers, fit.method="OLS",control=NULL)
+#'  
+#' print(fitUpDn)
+#' 
+#' @method print tsfmUpDn
+#' @export
+#' 
+
+
+
+print.tsfmUpDn <- function(x, digits=max(3, .Options$digits - 3), ...){
+  if(!is.null(cl <- x$Up$call)){
+    cat("\nCall:\n")
+    dput(cl)
+  }
+  cat("\nModel dimensions:\n")
+  tmp <- c(dim(t(x$Up$beta)), nrow(x$Up$data))
+  names(tmp) <- c("Factors", "Assets", "Periods")
+  print(tmp)
+  cat("\nRegression Alphas in up market:\n")
+  print(t(x$Up$alpha), digits=digits,...)
+  cat("\nRegression Alphas in down market:\n")
+  print(t(x$Dn$alpha), digits=digits,...)
+  
+  cat("\nFactor Betas in up market:\n")
+  B <- as.matrix(t(x$Up$beta))
+  if (x$Up$variable.selection=="lars") { B[B==0] <- NA }
+  print(B, digits=digits, na.print=".", ...)
+  cat("\nFactor Betas in down market:\n")
+  B <- as.matrix(t(x$Dn$beta))
+  if (x$Dn$variable.selection=="lars") { B[B==0] <- NA }
+  print(B, digits=digits, na.print=".", ...)
+  
+  cat("\nR-squared values in up market:\n")
+  print(x$Up$r2, digits=digits, ...)
+  cat("\nR-squared values in down market:\n")
+  print(x$Dn$r2, digits=digits, ...)
+  
+  cat("\nResidual Volatilities in up market:\n")
+  print(x$Up$resid.sd, digits=digits, ...)
+  cat("\nResidual Volatilities in down market:\n")
+  print(x$Dn$resid.sd, digits=digits, ...)
+}
\ No newline at end of file

Modified: pkg/FactorAnalytics/R/summary.tsfmUpDn.r
===================================================================
--- pkg/FactorAnalytics/R/summary.tsfmUpDn.r	2015-02-23 22:57:04 UTC (rev 3601)
+++ pkg/FactorAnalytics/R/summary.tsfmUpDn.r	2015-02-23 23:18:46 UTC (rev 3602)
@@ -27,7 +27,7 @@
 #' \item{Up}{A list of the up market fitted object. It is a class of \code{summary.tsfm}}
 #' \item{Dn}{A list of the down market fitted object. It is a class of \code{summary.tsfm}} 
 #' 
-#' @author Yi-An Chen.
+#' @author Yi-An Chen and Sangeetha Srinivasan.
 #' 
 #' @seealso \code{\link{fitTsfmUpDn}}, \code{\link[stats]{summary.tsfm}}
 #' 

Added: pkg/FactorAnalytics/man/print.tsfmUpDn.Rd
===================================================================
--- pkg/FactorAnalytics/man/print.tsfmUpDn.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/man/print.tsfmUpDn.Rd	2015-02-23 23:18:46 UTC (rev 3602)
@@ -0,0 +1,36 @@
+% Generated by roxygen2 (4.1.0): do not edit by hand
+% Please edit documentation in R/print.tsfmUpDn.r
+\name{print.tsfmUpDn}
+\alias{print.tsfmUpDn}
+\title{Prints out a fitted up and down market time series factor model object}
+\usage{
+\method{print}{tsfmUpDn}(x, digits = max(3, .Options$digits - 3), ...)
+}
+\arguments{
+\item{x}{an object of class \code{tsfmUpDn} produced by \code{fitTsfmUpDn}.}
+
+\item{digits}{an integer value, to indicate the required number of
+significant digits. Default is 3.}
+
+\item{...}{optional arguments passed to the \code{print} method.}
+}
+\description{
+S3 \code{print} method for object of class \code{tsfmUpDn}. Prints
+the call, factor model dimension, regression coefficients, r-squared and
+residual volatilities from the fitted object.
+}
+\examples{
+data(managers)
+# example: Up and down market factor model with OLS fit
+fitUpDn <- fitTsfmUpDn(asset.names=colnames(managers[,(1:6)]),mkt.name="SP500.TR",
+                       data=managers, fit.method="OLS",control=NULL)
+
+print(fitUpDn)
+}
+\author{
+Yi-An Chen and Sangeetha Srinivasan
+}
+\seealso{
+\code{\link{fitTsfmUpDn}}, \code{\link{summary.tsfmUpDn}}
+}
+

Modified: pkg/FactorAnalytics/man/summary.tsfmUpDn.Rd
===================================================================
--- pkg/FactorAnalytics/man/summary.tsfmUpDn.Rd	2015-02-23 22:57:04 UTC (rev 3601)
+++ pkg/FactorAnalytics/man/summary.tsfmUpDn.Rd	2015-02-23 23:18:46 UTC (rev 3602)
@@ -35,12 +35,12 @@
 \description{
 \code{summary} method for object of class \code{tsfmUpDn}.
 Returned object is of class {summary.tsfmUpDn}. This function provides a \code{summary}
-method to a return object of a wrapper function \code{fitTsfmUpDn}.
+method to an object returned by a wrapper function \code{fitTsfmUpDn}.
 }
 \details{
 Since \code{fitTsfmUpDn} fits both up market and down market,
 \code{summary.tsfmUpDn} applies \code{summary.tsfm} for both markets fitted
-objects and combines the coefficients together.
+objects and combines the coefficients interested together.
 }
 \examples{
 # load data from the database
@@ -53,7 +53,7 @@
  summary(fitUpDn)
 }
 \author{
-Yi-An Chen.
+Yi-An Chen and Sangeetha Srinivasan.
 }
 \seealso{
 \code{\link{fitTsfmUpDn}}, \code{\link[stats]{summary.tsfm}}



More information about the Returnanalytics-commits mailing list