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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 3 23:01:25 CEST 2013


Author: chenyian
Date: 2013-09-03 23:01:25 +0200 (Tue, 03 Sep 2013)
New Revision: 2977

Modified:
   pkg/FactorAnalytics/DESCRIPTION
   pkg/FactorAnalytics/NAMESPACE
   pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r
Log:
debug for statistical model and fundamental model 

Modified: pkg/FactorAnalytics/DESCRIPTION
===================================================================
--- pkg/FactorAnalytics/DESCRIPTION	2013-09-03 20:16:57 UTC (rev 2976)
+++ pkg/FactorAnalytics/DESCRIPTION	2013-09-03 21:01:25 UTC (rev 2977)
@@ -7,5 +7,5 @@
 Maintainer: Yi-An Chen <chenyian at uw.edu>
 Description: An R package for estimation and risk analysis of linear factor models for asset returns and portfolios. It contains three major fitting method for the factor models: fitting macroeconomic factor model, fitting fundamental factor model and fitting statistical factor model and some risk analysis tools like VaR, ES to use the result of the fitting method. It also provides the different type of distribution to fit the fat-tail behavior of the financial returns, including edgeworth expansion type distribution.  
 License: GPL-2
-Depends: robust, robustbase, leaps, lars, zoo, MASS, PerformanceAnalytics, ff, sn, tseries, strucchange,xts,ellipse 
+Depends: robust, robustbase, leaps, lars,ff, MASS, PerformanceAnalytics, sn, tseries, strucchange,xts,ellipse 
 LazyLoad: yes
\ No newline at end of file

Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE	2013-09-03 20:16:57 UTC (rev 2976)
+++ pkg/FactorAnalytics/NAMESPACE	2013-09-03 21:01:25 UTC (rev 2977)
@@ -1,4 +1,4 @@
-S3method(summary.FM.attribution)
+S3method(summary,FM.attribution)
 export(factorModelPerformanceAttribution)
 export(dCornishFisher)
 export(factorModelCovariance)

Modified: pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r
===================================================================
--- pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r	2013-09-03 20:16:57 UTC (rev 2976)
+++ pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r	2013-09-03 21:01:25 UTC (rev 2977)
@@ -142,8 +142,13 @@
 
     
   #cumulative return attributed to factors
+  if (factor.names[1] == "(Intercept)") {
   cum.attr.ret <- matrix(,nrow=length(ticker),ncol=length(factor.names),
-                         dimnames=list(ticker,factor.names))
+                         dimnames=list(ticker,factor.names))[,-1] # discard intercept
+  } else {
+    cum.attr.ret <- matrix(,nrow=length(ticker),ncol=length(factor.names),
+                           dimnames=list(ticker,factor.names))
+  }
   cum.spec.ret <- rep(0,length(ticker))
   names(cum.spec.ret) <- ticker
  
@@ -164,7 +169,7 @@
     
     attr.factor <- exposure * coredata(factor.returns)
     specific.returns <- returns - apply(attr.factor,1,sum)
-    attr <- cbind(returns,attr.factor,specific.returns)
+    attr <- cbind(attr.factor,specific.returns)
     attr.list[[k]] <- xts(attr,as.Date(dates))
     cum.attr.ret[k,] <- apply(attr.factor,2,Return.cumulative)
     cum.spec.ret[k] <- Return.cumulative(specific.returns)



More information about the Returnanalytics-commits mailing list