## Saturday, June 9, 2012

### Universal portfolio, part 5

The first three tables in Universal Portfolios presents the same information in numerical form as some of the plots.  The following code generates all three tables by defining a function then calling it with suitable parameters.  The output is text only, so does not match the typography of the original.

# tables 8.1, 8.2 and 8.3 of Cover "Universal Portfolios"
require(logopt)
x <- nyse.cover.1962.1984

ShowTable <- function(a,b) {
cat(sprintf("%s versus %s\n", a, b))
cat(sprintf("------------------\n"))
cat(sprintf("b            Sn(b)\n"))
cat(sprintf("------------------\n"))
xab <- x[,c(a,b)]
nDays <- dim(xab)[1]
Days <- 1:nDays
alphas <- seq(0,1,by=0.05)
crps <- alphas
for (i in 1:length(crps)) {
crps[i] <- crp(xab, c(1-alphas[i], alphas[i]))[nDays]
cat(sprintf("%.2f     %9.4f\n",1-alphas[i], crps[i]))
}
cat(sprintf("------------------\n"))
cat(sprintf("Target wealth: Sn* = %.4f\n",max(crps)))
cat(sprintf("Best rebalanced portfolio: bn* = %4.2f\n",1-alphas[which.max(crps)]))
cat(sprintf("Best constituent stock: %.4f\n", max(c(crps[1], crps[length(crps)]))))
cat(sprintf("Universal wealth: Sn^ = %.4f\n\n\n\n", mean(crps)))
}

ShowTable("iroqu","kinar")
ShowTable("comme","kinar")
ShowTable("comme","meico")

iroqu versus kinar
------------------
b            Sn(b)
------------------
1.00        8.9151
0.95       13.7712
0.90       20.2276
0.85       28.2560
0.80       37.5429
0.75       47.4513
0.70       57.0581
0.65       65.2793
0.60       71.0652
0.55       73.6190
0.50       72.5766
0.45       68.0915
0.40       60.7981
0.35       51.6645
0.30       41.7831
0.25       32.1593
0.20       23.5559
0.15       16.4196
0.10       10.8910
0.05        6.8737
0.00        4.1276
------------------
Target wealth: Sn* = 73.6190
Best rebalanced portfolio: bn* = 0.55
Best constituent stock: 8.9151
Universal wealth: Sn^ = 38.6727

comme versus kinar
------------------
b            Sn(b)
------------------
1.00       52.0203
0.95       68.2890
0.90       85.9255
0.85      103.6415
0.80      119.8472
0.75      132.8752
0.70      141.2588
0.65      144.0035
0.60      140.7803
0.55      131.9910
0.50      118.6854
0.45      102.3564
0.40       84.6655
0.35       67.1703
0.30       51.1127
0.25       37.3042
0.20       26.1131
0.15       17.5315
0.10       11.2883
0.05        6.9704
0.00        4.1276
------------------
Target wealth: Sn* = 144.0035
Best rebalanced portfolio: bn* = 0.65
Best constituent stock: 52.0203
Universal wealth: Sn^ = 78.4742

comme versus meico
------------------
b            Sn(b)
------------------
1.00       52.0203
0.95       61.0165
0.90       70.0625
0.85       78.7602
0.80       86.6815
0.75       93.4026
0.70       98.5414
0.65      101.7927
0.60      102.9589
0.55      101.9691
0.50       98.8869
0.45       93.9033
0.40       87.3172
0.35       79.5057
0.30       70.8890
0.25       61.8932
0.20       52.9162
0.15       44.3012
0.10       36.3178
0.05       29.1538
0.00       22.9160
------------------
Target wealth: Sn* = 102.9589
Best rebalanced portfolio: bn* = 0.60
Best constituent stock: 52.0203
Universal wealth: Sn^ = 72.6289

The final table is more complex to reproduce and also more interesting, we'll tackle it in a next post.