By using the utility functions defined in the previous section, the concept of proba- bilistic utility is now applied to an equity portfolio consisting of the S&P 500, the Rus- sell, the DAX, and the FTSE index series. It will be shown how the above-mentioned MCMC packages can be used.
In Listing 14.5, the required packages are brought into memory first. The equity indices are part of theMultiAssetdata set, which is contained in theFRAPO package. The MCMC is conducted by alternative means, that is, the expected values of the allocations are determined by utilizing the MCMC-related functions in the packagesadaptMCMC,MCMCpack,mcmc, andrstan. For computing the asset allocations by maximizing the utility function, the packageRsolnpwill be used (see Ghalanos and Theussl, 2015).
Commencing in line 8 of the listing, the data set is loaded and the annualized, discrete, percentage returns of the equity indices are calculated and assigned to the objectRequity. Next, the sample means and the variance-covariance matrix are assigned to the objectsmuSampleandSigmaSample, respectively. The compar- ison between the maximum expected utility and the probabilistic utility allocations is cast in terms of a targeted return equal to 10% (objecttargetR), a risk aversion parameter set to 3 (objectriskA), an investment horizon encompassing 60 periods (objectNt), and an asymptotic conversion rate equal to the square root ofNt, that is, objectconvR.
The maximization of the expected utility is conducted in lines 24–43 of Listing 14.5. First, the objective function to be minimized is defined as objectf0(). Within the function’s body the utility level is computed for a given set of parameters and the negative value is returned. In line 34, a function representing the budget constraint is defined as objectbudget(). This function is then used together with the right-hand side set equal to one (argumenteqB) in the call tosolnp(). The optimization algo- rithm is initialized with an equal-weighted solution (objectw0) and the argument for the objective function,fun, is set tof0in the call tosolnp(). The non-negativity constraints for the elements of the weight vector are swiftly accomplished by setting rep(0, N)for the lower bound argumentLB. The remaining arguments in the call tosolnp()are passed down to the utility functionU()as defined in Listing 14.4.
The optimization result is assigned to the objectoptMEU, and in the last lines the so- lution is stored inwMEUas percentages and the associated utility level as objectUMEU.
k k Rcode 14.5Probabilistic versus maximized expected utility, part one.
# # L o a d i n g o f p a c k a g e s 1
l i b r a r y ( FRAPO ) 2
l i b r a r y ( adaptMCMC ) 3
l i b r a r y ( MCMCpack ) 4
l i b r a r y ( mcmc ) 5
l i b r a r y ( r s t a n ) 6
l i b r a r y ( R s o l n p ) 7
# # C o m p u t a t i o n o f e q u i t y r e t u r n s 8
d a t a ( M u l t i A s s e t ) 9
A s s e t s <− t i m e S e r i e s ( M u l t i A s s e t , 10
c h a r v e c = rownames ( M u l t i A s s e t ) ) 11
R <− 100 ∗ ( ( 1 + r e t u r n s ( A s s e t s , method = " d i s c r e t e " , 12
p e r c e n t a g e = FALSE ) ) ^12 − 1 ) 13
#R <− r e t u r n s ( A s s e t s , m e t h o d = " d i s c r e t e " , p e r c e n t a g e = FALSE ) 14
R e q u i t y <− R [ , c ( "GSPC" , "RUA" , "GDAXI" , " FTSE " ) ] 15
# # P a r a m e t e r s e t t i n g s/i n i t i a l i z a t i o n 16
muSample <− c o l M e a n s ( R e q u i t y ) 17
s i g m a S a m p l e <− cov ( R e q u i t y ) 18
t a r g e t R <− 10 19
r i s k A <− 3 20
Nt <− 60 21
convR <− s q r t ( nrow ( R e q u i t y ) ) 22
N <− n c o l ( R e q u i t y ) 23
# # 24
# # M a x i m i z i n g e x p e c t e d u t i l i t y 25
# # 26
# # o b j e c t i v e f u n c t i o n t o be m i n i m i z e d 27
f 0 <− f u n c t i o n ( p a r s , mu , Sigma , Lambda , L , i p e r i o d ) { 28
u v a l <− U( p a r s , mu , Sigma , Lambda , L , i p e r i o d ) 29
−1.0 ∗ u v a l 30
} 31
# # b u d g e t c o n s t r a i n t f o r o p t i m i z a t i o n 32
b u d g e t <− f u n c t i o n ( p a r s , mu , Sigma , Lambda , L , i p e r i o d ) { 33
sum ( p a r s ) 34
} 35
# # i n i t i a l p o i n t 36
w0 <− r e p ( 1 / N , N) 37
# # C o m p u t i n g MEU a l l o c a t i o n 38
optMEU <− s o l n p ( p a r s = w0 , f u n = f 0 , e q f u n = b u d g e t , 39
eqB = 1 . 0 , LB = r e p ( 0 , N) , mu = muSample , 40
Sigma = s i g m a S a m p l e , Lambda = r i s k A , 41
L = t a r g e t R , i p e r i o d = Nt ) 42
wMEU <− optMEU$ p a r s ∗ 100 43
UMEU <− U(wMEU / 1 0 0 , mu = muSample , Sigma = s i g m a S a m p l e , 44
Lambda = r i s k A , L = t a r g e t R , i p e r i o d = Nt ) 45
k k Rcode 14.6Probabilistic versus maximized expected utility, part two.
McmcLength <− 5 e4 1
# # adaptMCMC 2
a n s 1 <− MCMC( p = PUL , n = McmcLength , i n i t = w0 , 3
mu = muSample , Sigma = s i g m a S a m p l e , 4
Lambda = r i s k A , L = t a r g e t R , i p e r i o d = Nt , 5
nu = convR , a c c . r a t e = 0 . 5 ) 6
a n s 1 $ a c c e p t a n c e . r a t e 7
w1 <− c o l M e a n s ( a n s 1 $ s a m p l e s ) 8
w1 <− w1 / sum ( w1 ) ∗ 100 9
w1 10
# # MCMCpack 11
a n s 2 <− MCMCmetrop1R ( f u n = PUL , t h e t a . i n i t = w0 , 12
mcmc = McmcLength , mu = muSample , 13
V = 1 e−3 ∗ d i a g (N) , Sigma = s i g m a S a m p l e , 14
Lambda = r i s k A , L = t a r g e t R , 15
i p e r i o d = Nt , nu = convR ) 16
w2 <− c o l M e a n s ( a n s 2 ) 17
w2 <− w2 / sum ( w2 ) ∗ 100 18
w2 19
# # mcmc 20
a n s 3 <− m e t r o p ( o b j = PUL , i n i t i a l = w0 , n b a t c h = McmcLength , 21
b l e n = 1 , s c a l e = 0 . 0 2 5 , mu = muSample , 22
Sigma = s i g m a S a m p l e , Lambda = r i s k A , 23
L = t a r g e t R , i p e r i o d = Nt , nu = convR ) 24
a n s 3 $ a c c e p t 25
w3 <− c o l M e a n s ( a n s 3 $ b a t c h ) 26
w3 <− w3 / sum ( w3 ) ∗ 100 27
w3 28
# # r s t a n 29
p u d a t <− l i s t (N = N , Lambda = r i s k A , mu = muSample , 30
Sigma = s i g m a S a m p l e , L = t a r g e t R , 31
i p e r i o d = Nt , nu = convR ) 32
n c h a i n <− 4 33
S t a n F i l e <− f i l e . p a t h ( f i n d . p a c k a g e ( "FRAPO" ) , " BookEx " , 34
" C14S1 . s t a n " ) 35
a n s 4 <− s t a n ( f i l e = S t a n F i l e , d a t a = p u d a t , i t e r = McmcLength , 36
c h a i n s = n c h a i n ) 37
w4 <− d r o p ( g e t _ p o s t e r i o r _ mean ( a n s 4 , p a r s = "w" ) 38
[ , n c h a i n + 1 ] ) ∗ 100 39
w4 40
# # S u m m a r i z i n g r e s u l t s 41
W a l l <− r o u n d ( r b i n d (wMEU, w1 , w2 , w3 , w4 ) , 2 ) 42
rownames ( Wa l l ) <− c ( "MEU" , " adaptMCMC " , "MCMCpack" , "mcmc" , 43
" r s t a n " ) 44
CR <− a p p l y ( Wall , 1 , f u n c t i o n ( x ) c r ( x , s i g m a S a m p l e ) ) 45
Wans <− c b i n d ( Wall , CR) 46
c o l n a m e s ( Wans ) <− c ( "GSPC" , "RUA" , "GDAXI" , " FTSE " , 47
" C o n c e n t r a t i o n " ) 48
Wans 49
k k The allocations according to the concept of probabilistic utility are computed in
Listing 14.6. In the first line, the length of the Markov chains is set to5e4. In the subsequent lines the weight vectors expressed as percentages are determined by call- ing the respective functions of the packages adaptMCMC,MCMCpack,mcmc, andrstanand assigned to the objectsw1tow4, respectively. To avoid rounding is- sues, the allocations are rescaled to fulfill the budget constraint. Commencing in line 42, the portfolio allocations are combined in the objectWalland the implied con- centration ratios for each allotment is computed in line 45 (objectCR). Both objects are joined by column and provided in Table 14.1.
The maximization of the expected utility yields a concentrated portfolio solution with allotments only to the S&P 500 and FTSE 100 indices. The latter accounts for roughly 87% of the invested wealth. The allocations according to the concept of prob- abilistic utility are, first, more balanced across the assets, and secondly are pretty similar to each other with respect to the chosenRpackage. The allocations to the Russell and DAX indices are the smallest and the allotment to the S&P 500 remained almost unchanged. Hence, the high concentration in the FTSE 100 market implied by the MEU optimization has been ameliorated by utilizing the probabilistic utility approach. This observation is also mirrored by the concentration ratios.