[Returnanalytics-commits] r2911 - in pkg/FactorAnalytics: R vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 28 01:19:50 CEST 2013


Author: chenyian
Date: 2013-08-28 01:19:50 +0200 (Wed, 28 Aug 2013)
New Revision: 2911

Modified:
   pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r
   pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw
Log:
add section performance attribution in vignettes 

Modified: pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r
===================================================================
--- pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r	2013-08-27 22:22:40 UTC (rev 2910)
+++ pkg/FactorAnalytics/R/factorModelPerformanceAttribution.r	2013-08-27 23:19:50 UTC (rev 2911)
@@ -91,7 +91,7 @@
     fit.lm = fit$asset.fit[[k]]
    
     ## extract information from lm object
-    date <- names(fitted(fit.lm))
+    date <- index(fit$data[,k])
    
     actual.xts = xts(fit.lm$model[1], as.Date(date))
  
@@ -191,7 +191,7 @@
         fit.lm = fit$asset.fit[[k]]
         
         ## extract information from lm object
-        date <- names(fitted(fit.lm))
+        date <- index(fit$data[,k])
         # probably needs more general Date setting
         actual.xts = xts(fit.lm$model[1], as.Date(date))
         

Modified: pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw
===================================================================
--- pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw	2013-08-27 22:22:40 UTC (rev 2910)
+++ pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw	2013-08-27 23:19:50 UTC (rev 2911)
@@ -376,4 +376,20 @@
 @
 
 
+\section{Performance Attribution}
+
+User can do factor-based performance attribution with \verb at factorAnalytics@ package. factor model:
+\begin{equation}
+r_t = \alpha + Bf_t + e_t,\;t=1 \cdots T
+\end{equation}
+can break down asset returns into two pieces. The first term is \emph{returns atttributed to factors} $Bf_t$ and the second term is called \emph{specific returns} which is simply $\alpha + e_t$. 
+
+For example, let's breakdown time series factor model we usded previously. Function \verb at factorModelPerformanceAttribution()@ can help us to calculate performance attribution. 
+<<ts.attr>>=
+ts.attr <- factorModelPerformanceAttribution(fit.time)
+names(ts.attr)
+@
+There are 3 items generated by the function. \verb at cum.ret.attr.f@ will return a N x K matrix with cummulative returns attributed to factors. \verb at cum.spec.ret@ will return a N x 1 matrix with cummulative specific returns. \verb at attr.list@ will return a list which contains returns atttribution to each factors and specific returns asset by asset. 
+
+
 \end{document}
\ No newline at end of file



More information about the Returnanalytics-commits mailing list