R is fun
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
As mentioned in Universal portfolio, part 6, the wealth reported in Table 8.4 of Universal Portfolios could not be reproduced. An other observation is that the random weight vectors reported in Table 8.4 are shown in descending lexicographic order, except for the last one, suggesting possibly that there is an error in the original table.
R code allows to perform a simple experiment, take subsets of the full set of weights and check if we can reproduce the reported wealth. Explicitly we’ll try all subsets that exclude from 1 to 7 values in the original set. This shows the expressive power of R, and how fast modern computers operate. The whole search only takes a few line of codes and execute very fast even if this entails computing the mean of 280,599 different subsets.
As it turns out, two different subsets with 18 elements match the reported wealth, a surprising result. No other subsets match. The code below must be appended after the code used in Universal portfolio, part 6.
# remove selected entries to try to get the published value of 98.4240
# R is fun and modern computers are fast
BestAppr <- 0
nPruned <- 0
nC <- length(crps)
cat(“\n”)
for (m in seq(nC-1, nC-7)) {
CrpPruned <- combn(crps, m, mean)
nPruned <- nPruned + length(CrpPruned)
Best <- min(abs(CrpPruned - 98.4240))
cat(sprintf(“Min delta from Cover with %d samples is %.4f\n”, m, Best))
}
cat(sprintf(“\n%d different subsets tried\n”, nPruned))
cat(“\n Subsets matching the wealth reported in Table 8.4\n”)
# so at least one subset of 18 samples match the published value, show them
Indices <- combn(1:22,18)
for (i in 1:(dim(Indices)[2])) {
PrunedMean <- mean(crps[Indices[,i]])
if (abs(PrunedMean – 98.4240) < 0.0001) {
cat(Indices[,i])
cat(sprintf(” %.5f\n”,PrunedMean))
}
}
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.