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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 6 23:21:59 CET 2014


Author: gyollin
Date: 2014-03-06 23:21:59 +0100 (Thu, 06 Mar 2014)
New Revision: 3345

Modified:
   pkg/FactorAnalytics/R/fitStatisticalFactorModel.R
Log:
Fixed error in the computation of the returns covariance matrix as estimated by the factor model.

Modified: pkg/FactorAnalytics/R/fitStatisticalFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitStatisticalFactorModel.R	2014-02-27 10:39:11 UTC (rev 3344)
+++ pkg/FactorAnalytics/R/fitStatisticalFactorModel.R	2014-03-06 22:21:59 UTC (rev 3345)
@@ -225,7 +225,7 @@
 	resid <- t(t(tmp) - alpha)
 	r2 <- (1 - colSums(resid^2)/colSums(xc^2))
 	ret.cov <- t(B) %*% var(f) %*% B
-	diag(ret.cov) <- diag(ret.cov) + colSums(tmp^2)/(m - k - 1)
+	diag(ret.cov) <- diag(ret.cov) + colSums(resid^2)/(m - k - 1)
 	dimnames(B) <- list(paste("F", 1:k, sep = "."), data.names)
 	dimnames(f) <- list(dimnames(data)[[1]], paste("F", 1:k, sep = "."))
 	dimnames(ret.cov) <- list(data.names, data.names)



More information about the Returnanalytics-commits mailing list