[Returnanalytics-commits] r2650 - in pkg/FactorAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 26 21:45:12 CEST 2013
Author: chenyian
Date: 2013-07-26 21:45:12 +0200 (Fri, 26 Jul 2013)
New Revision: 2650
Modified:
pkg/FactorAnalytics/R/fitFundamentalFactorModel.R
pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r
pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd
Log:
add summary.FundamentalFactorModel.Rd and summary.FundamentalFactorModel.r
Modified: pkg/FactorAnalytics/R/fitFundamentalFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitFundamentalFactorModel.R 2013-07-26 18:08:20 UTC (rev 2649)
+++ pkg/FactorAnalytics/R/fitFundamentalFactorModel.R 2013-07-26 19:45:12 UTC (rev 2650)
@@ -411,8 +411,10 @@
# SSE <- apply(fit.fund$residuals^2,2,sum)
# SST <- tapply(data[,returnsvar],data[,assetvar],function(x) sum((x-mean(x))^2))
# r2 <- 1- SSE/SST
-
+# change names for intercept
+colnames(f.hat)[1] <- "Intercept"
+
output <- list(returns.cov = Cov.returns,
factor.cov = Cov.factors,
resids.cov = Cov.resids,
Modified: pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r 2013-07-26 18:08:20 UTC (rev 2649)
+++ pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r 2013-07-26 19:45:12 UTC (rev 2650)
@@ -1,18 +1,48 @@
-#' summary method for FundamentalFactorModel
+#' summary FundamentalFactorModel object
#'
-#' Generic function of summary method for fitTimeSeriesFactorModel.
+#' Generic function of summary method for fitFundamentalFactorModel.
#'
-#' @param fit it object created by fitFundamentalFactorModel.
#'
-#' @author Yi-An Chen
+#' @param fit.fund fit object created by fitFundamentalFactorModel.
+#' @param digits integer indicating the number of decimal places. Default is 3.
+#' @param ... Other arguments for print methods.
+#' @author Yi-An Chen.
+#' @examples
#'
+#' data(stock)
+#' # there are 447 assets
+#' exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
+#' test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
+#' datevar = "DATE", returnsvar = "RETURN",
+#' assetvar = "TICKER", wls = TRUE,
+#' regression = "classic",
+#' covariance = "classic", full.resid.cov = TRUE,
+#' robust.scale = TRUE)
#'
+#' summary(test.fit)
#'
-#' @export
-#'
-
-summary.FundamentalFactorModel <- function(fit) {
-dim(fit$factors)
-print(fit$factors)
+#' @export
+summary.FundamentalFactorModel <-
+ function(fit.fund, digits = max(3, .Options$digits - 3), ...)
+ {
+ if(!is.null(cl <- fit.fund$call)) {
+ cat("\nCall:\n")
+ dput(cl)
+ }
-}
\ No newline at end of file
+ cat("\nFactor Returns:\n")
+ n <- dim(fit.fund$factor.returns)[1]
+ k <- dim(fit.fund$factor.returns)[2]
+ se.beta <- fit.fund$factor.returns/fit.fund$tstat
+ pvalue <- 1- pt(fit.fund$tstat,df=n-k)
+ table.fund <- cbind(fit.fund$factor.returns[,1],se.beta[,1],fit.fund$tstat[,1])
+ f.names <- colnames(fit.fund$factor.returns)
+ for (i in 1:k) {
+ cat("\n",f.names[i],"\n")
+ table.fund <- cbind(fit.fund$factor.returns[,i],se.beta[,i],fit.fund$tstat[,i],pvalue[,i])
+ colnames(table.fund)[1:4] <- c("Estimate","Std. Error","t value","Pr(>|t|)")
+ print(table.fund, digits = digits,...)
+ }
+ cat("\nResidual Variance:\n")
+ print(fit.fund$resid.variance, digits = digits, ...)
+ }
Modified: pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd 2013-07-26 18:08:20 UTC (rev 2649)
+++ pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd 2013-07-26 19:45:12 UTC (rev 2650)
@@ -1,18 +1,37 @@
\name{summary.FundamentalFactorModel}
\alias{summary.FundamentalFactorModel}
-\title{summary method for FundamentalFactorModel}
+\title{summary FundamentalFactorModel object}
\usage{
- summary.FundamentalFactorModel(fit)
+ summary.FundamentalFactorModel(fit.fund,
+ digits = max(3, .Options$digits - 3), ...)
}
\arguments{
- \item{fit}{it object created by
+ \item{fit.fund}{fit object created by
fitFundamentalFactorModel.}
+
+ \item{digits}{integer indicating the number of decimal
+ places. Default is 3.}
+
+ \item{...}{Other arguments for print methods.}
}
\description{
Generic function of summary method for
- fitTimeSeriesFactorModel.
+ fitFundamentalFactorModel.
}
+\examples{
+data(stock)
+# there are 447 assets
+exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
+test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
+ datevar = "DATE", returnsvar = "RETURN",
+ assetvar = "TICKER", wls = TRUE,
+ regression = "classic",
+ covariance = "classic", full.resid.cov = TRUE,
+ robust.scale = TRUE)
+
+summary(test.fit)
+}
\author{
- Yi-An Chen
+ Yi-An Chen.
}
More information about the Returnanalytics-commits
mailing list