[Returnanalytics-commits] r3371 - pkg/FactorAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 15 19:49:26 CEST 2014


Author: chenyian
Date: 2014-04-15 19:49:26 +0200 (Tue, 15 Apr 2014)
New Revision: 3371

Modified:
   pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R
Log:
fix a bug in add.up.market.beta in fitTimeSeriesFactorModel.R

Modified: pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R	2014-04-15 17:30:19 UTC (rev 3370)
+++ pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R	2014-04-15 17:49:26 UTC (rev 3371)
@@ -146,9 +146,9 @@
           for (i in assets.names) {
         reg.df = na.omit(reg.xts[, c(i, factors.names)])  
         if(add.up.market.returns == TRUE) {
-        up.beta <- apply(reg.xts[,excess.market.returns.name],1,max,0)
-        reg.df = merge(reg.df,up.beta)
-        }
+        reg.df$up.beta = reg.df[,excess.market.returns.name]
+        reg.df$up.beta[reg.df$up.beta <0] <- rep(0,sum(reg.df$up.beta<0)) 
+         }
         if(add.quadratic.term == TRUE) {
           quadratic.term <- reg.xts[,excess.market.returns.name]^2
           reg.df = merge(reg.df,quadratic.term)



More information about the Returnanalytics-commits mailing list