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))

}

}

This gives the following output

Min delta from Cover with 21 samples is 2.3056

Min delta from Cover with 20 samples is 0.0398

Min delta from Cover with 19 samples is 0.0116

Min delta from Cover with 18 samples is 0.0000

Min delta from Cover with 17 samples is 0.0003

Min delta from Cover with 16 samples is 0.0008

Min delta from Cover with 15 samples is 0.0002

280599 different subsets tried

Subsets matching the wealth reported in Table 8.4

1 2 3 4 5 6 9 10 11 12 13 14 15 17 19 20 21 22 98.42403

1 2 3 4 5 6 9 11 12 13 14 15 17 18 19 20 21 22 98.42403

## No comments:

## Post a Comment