Commit be8efeda authored by Martin Maechler's avatar Martin Maechler

Compare with Env8 and Env9 -- gives the same (for all n=476 assets)

parent 319ae667
......@@ -7,6 +7,7 @@ if(requireNamespace("FRAPO")) {
print(dim(SP500)) # 265 * 476
}
(n <- length(muS.sp500$mu)) # 476
system.time(# ~ 9 sec
CLs5c.0.120 <- CLA(muS.sp500$mu, muS.sp500$covar, lB=0, uB=1/20)
)
......@@ -39,11 +40,36 @@ stopifnot(
NOC = 74L, NUE = 31L, NVDA = 14L, PBG = 72L, PCP = 103L, PDCO = 71L,
PEP = 69L, PG = 87L, RAI = 110L, RIG = 121L, RRC = 106L, RTN = 90L,
SII = 27L, SSP = 14L, SYK = 19L, SYMC = 13L, TEX = 37L, TIE = 85L,
TSO = 116L, TYC = 59L, UST = 127L, WAG = 17L, WFR = 6L, WMT = 6L, X = 44L, XTO = 102L))
TSO = 116L, TYC = 59L, UST = 127L, WAG = 17L, WFR = 6L, WMT = 6L,
X = 44L, XTO = 102L))
, identical(head(CLs5c.0.120$free_indices, 12),
list(295L, c(295L, 453L), 453L, c(453L, 472L), c(19L, 453L, 472L), c(19L, 453L),
453L, c(15L, 453L), 15L, c(15L, 320L), c(15L, 105L, 320L), c(105L, 320L)))
list(295L, c(295L, 453L), 453L, c(453L, 472L), c(19L, 453L, 472L),
c(19L, 453L), 453L, c(15L, 453L), 15L, c(15L, 320L),
c(15L, 105L, 320L), c(105L, 320L)))
)
## Check some of the 'Env<n>' versions:
claStrip <- function(res) {
## transform to old style
class(res) <- NULL
res$weights_set <- unname(res$weights_set)
names(res)[[5]] <- "MS_weight" # new is "MS_weights" w/ final "s"
res
}
rCLA <- claStrip(CLs5c.0.120)
nsCLA <- asNamespace("CLA")
if(is.environment(e8 <- nsCLA$Env8)) local(withAutoprint({
system.time(r8 <- e8$cla.solve(muS.sp500$mu, muS.sp500$covar,
lB = rep(0,n), uB= rep(1/20, n)))
## lynne: 9.6--9.8 sec
stopifnot(all.equal(r8, rCLA, tol = 1e-14)) # they are the same!
}))
if(is.environment(e9 <- nsCLA$Env9)) local(withAutoprint({
system.time(r9 <- e9$cla.solve(muS.sp500$mu, muS.sp500$covar,
lB = rep(0,n), uB= rep(1/20, n)))
## lynne: 10.0 sec
stopifnot(all.equal(r9, rCLA, tol = 1e-14)) # they are the same!
}))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment