[Returnanalytics-commits] r3768 - pkg/Dowd/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 2 20:22:44 CEST 2015
Author: dacharya
Date: 2015-07-02 20:22:44 +0200 (Thu, 02 Jul 2015)
New Revision: 3768
Modified:
pkg/Dowd/R/PCAES.R
Log:
Mistakes in svd decomposition corrected.
Modified: pkg/Dowd/R/PCAES.R
===================================================================
--- pkg/Dowd/R/PCAES.R 2015-07-02 18:17:26 UTC (rev 3767)
+++ pkg/Dowd/R/PCAES.R 2015-07-02 18:22:44 UTC (rev 3768)
@@ -40,11 +40,11 @@
# Principal components estimation
a <- svd(return.data) # SVD; provides U and V
index <- n - number.of.principal.components # Establishes how many zero terms on diagonal of S matrix
- S.diag <- c(sort(a$d, decreasing = TRUE)[1:number.of.principal.components],
- double(index)) # Creates diagonal for S matrix
- S <- matrix(0, m, n)
- diag(S) <- S.diag # Creates S matrix with diagonal S.diag
- synthetic.PandL.data <- a$u %*% S * t(a$v) * position.data
+ S.diag <- sort(a$d, decreasing = TRUE)[1:number.of.principal.components] # Creates diagonal for S matrix
+ S.diag <- diag(S.diag)
+ S <- matrix(0, min(m, n), min(m, n))
+ S[1:number.of.principal.components,1:number.of.principal.components] <- S.diag # Creates S matrix with diagonal S.diag
+ synthetic.PandL.data <- a$u %*% S %*% t(a$v) %*% position.data
y <- HSES(synthetic.PandL.data, cl)
return(y)
More information about the Returnanalytics-commits
mailing list