Portfolio back-test: robust optimization

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 201 - 209)

In this subsection robust portfolio optimizations with elliptical uncertainty for the expected returns are applied to the data set of the previous section. The elliptical un- certainty will be based on the ML point estimates. The efficient frontiers for a classical mean-variance optimization as given in (10.7) and the robust counterpart optimiza- tion as given in (10.16) will then be compared. Please recall that these two problem formulations only differ with respect to the factor in the first term. The SOCP will be solved by utilizing the functioncccp()contained in the packagecccp(see Pfaff 2015). That is, the portfolio optimization problems in (10.7) and (10.16) are cast so as to maximize the expected portfolio return for a given portfolio standard deviation risk. Before doing so, the functionPMV() for carrying out this task is defined; it returns the portfolio weights and is exhibited in the Listing 10.7.

Here, the SOCP is expressed in its primal form as in (10.18). The arguments of the function areSRootfor the square root of the variance-covariance matrix,mufor the

Rcode 10.7Robust portfolio optimization with elliptical uncertainty.

# # D e f i n i n g f u n c t i o n f o r p o i n t s on e f f i c i e n t f r o n t i e r 1

PMV <− f u n c t i o n ( SRoot , mu , SigTerm , 2

o p t c t r l = c t r l ( t r a c e = FALSE ) ) { 3

N <− nrow ( SRoot ) 4

# # P o r t f o l i o r i s k c o n s t r a i n t 5

s o c 1 <− s o c c ( F = SRoot , g = r e p ( 0 , N) , d = r e p ( 0 , N) , 6

f = SigTerm ) 7

# # nonn e g a t i v i t y c o n s t r a i n t 8

nno1 <− nnoc (G = −d i a g (N) , h = r e p ( 0 , N) ) 9

# # B u d g e t c o n s t r a i n t 10

A1 <− m a t r i x ( r e p ( 1 , N) , nrow = 1 ) 11

b1 <− 1 . 0 12

# # o p t i m i z a t i o n 13

a n s <− c c c p ( q = −mu , A = A1 , b = b1 , 14

c L i s t = l i s t ( nno1 , s o c 1 ) , o p t c t r l = o p t c t r l ) 15

g e t x ( a n s ) 16

} 17

k k point estimates of the expected returns,SigTermfor the first term as in (10.7) and

(10.16), andoptctrlfor providing user-specified control options with respect to the functioncccp(). As a default, this argument is initialized such that the solver’s trace is not printed. In the function’s body, first the number of assets is determined by the row count ofSRoot. In the following lines, the portfolio constraints are created with respect to a fully invested, long-only portfolio. The portfolio standard deviation risk constraint is defined by calling the functionsocc. This constraint consists of the square root of the variance covariance matrix as the left-hand side argument and the constant termSigTermas the upper bound. This second-order cone constraint is assigned to the objectsoc1. The non-negativity constraints are created by calling the functionnnocfor creating constraints with respect to the non-negative orthant cone. Because all cone constraints are formulated as lower or equal constraints with respect to a cone, the negative diagonal matrix has to be provided as the left-hand side argumentG. This constraint is assigned to the objectnno1. Finally, the fully invested requirement is cast as an equality constraint (objectsA1andb1). The optimization is then swiftly conducted by calling the functioncccp(), and the linear objective to be minimized is set to minus the negative returns. The weighting parameter𝜆as in (10.7) and (10.16) does not have to be provided, given that it is a scaler and does not influence the optimization outcome, but only the value of the objective function. The remaining arguments passed tocccp()are the budget constraint (argumentsAand b), the two previously created cone constraints cast in alistobject as argument cList, and the control settings for the optimizer (argumentoptctrl).

With this wrapper function in Listings 10.7 one can now trace the efficient frontiers of the mean-variance and the robustly optimized portfolios. The relevantRcode for doing so is exhibited in Listing 10.8.

First, the package cccp is loaded into the workspace. In lines 2–8 the parame- ters used in the optimizations are defined. These consist of the count assets and observations, the expected return vector set as the column means of rzoo, the variance-covariance matrix of the returns and the square-root thereof, and the 90%

quantile for the returns uncertainties. In lines 9–12 a sequence of ten risk aversion parameters is determined for computing the points on the efficient frontier. These are constructed such that the range encompasses the portfolio standard deviation risks greater than 110% of the least risky and 90% of the riskiest asset in terms of the standard deviation risk.

Commencing in line 14, twomatrixobjects for storing the optimization results of the classical mean-variance portfolio approach (objectMVans) and its robust coun- terpart (objectRCans) are defined, respectively.

The computation of the ten points on the efficient frontier for each optimization scheme is conducted in aforloop starting on line 18. In the loop’s body, the im- plied allocation by the classical mean-variance approach for a given risk aversion parameterra[i]is determined and assigned to the objectwmv. Next, the associated portfolio standard deviation risk, the portfolio return to be expected and the alloca- tion itself is stored in theith row of thematrixobjectMVans. Similarly, the same is accomplished for the robust counterpart setting in the remaining part of the loop’s

k k Rcode 10.8Efficient frontiers for mean-variance and robust counterpart

optimization with elliptical uncertainty of𝝁.

l i b r a r y ( c c c p ) 1

# # S e t t i n g o f p a r a m e t e r s 2

N a s s e t s <− n c o l ( r z o o ) 3

Nobs <− nrow ( r z o o ) 4

mu <− c o l M e a n s ( r z o o ) 5

S <− cov ( r z o o ) 6

SR <− sqrm ( S ) 7

d e l t a <− s q r t ( q c h i s q ( 0 . 9 , N a s s e t s ) ) 8

# # D e t e r m i n i n g f e a s i b l e r i s k a v e r s i o n 9

SigMax <− max ( c o l S d s ( r z o o ) ) 10

SigMin <− min ( c o l S d s ( r z o o ) ) 11

r a <− s e q ( SigMin 1 . 1 , SigMax 0 . 9 , l e n g t h . o u t = 1 0 ) / SigMax 12

# # I n i t i a l i z i n g o b j e c t s f o r MV and r o b u s t c o u n t e r p a r t r e s u l t s 13

RCans <− MVans <− m a t r i x (NA, 14

nrow = 1 0 , 15

n c o l = N a s s e t s + 2 ) 16

# # C o m p u t i n g p o i n t s on e f f i c i e n t f r o n t i e r and a l l o c a t i o n s 17

f o r ( i i n 1 : 1 0 ) { 18

# # minimumv a r i a n c e 19

wmv <− PMV( SRoot = SR , mu = mu , SigTerm = SigMin / r a [ i ] ) 20

MVans [ i , ] <− c ( s q r t ( t (wmv) %% S %% wmv) , 21

c r o s s p r o d ( mu , wmv) , 22

wmv) 23

# # r o b u s t c o u n t e r p a r t 24

t h e t a <− r a [ i ] + ( 1 − r a [ i ] ) d e l t a / s q r t ( Nobs ) 25

wrc <− PMV( SRoot = SR , mu = mu , SigTerm = SigMin / t h e t a ) 26

RCans [ i , ] <− c ( s q r t ( t ( wrc ) %% S %% wrc ) , 27

c r o s s p r o d ( mu , wrc ) , 28

wrc ) 29

} 30

body. As an outcome of thisforloop, twomatrixobjects have been filled with respect to the classical and robust counterpart optimizations. As is evident from the invocation of thecccp()function, the two optimizations only differ from each other with respect to the provided argumentsigTerm.

Now, recall (10.17) in which the relation between the robust counterpart and the classical mean-variance risk-weighting parameter𝜆was stated. For a given value of the risk-weighting scalar𝜃∈ [0,1]in the robust counterpart optimization, an equiva- lent value for the classical mean-variance setting can be computed. This is the subject in Listing 10.9.

k k Rcode 10.9Determining equivalent mean-variance allocation for a given robust

counterpart risk weighting.

# # E q u i v a l e n t w e i g h t i n g p a r a m e t e r f o r t h e t a 1

t h e t a 2 l a m b d a <− f u n c t i o n ( t h e t a , N a s s e t s , Nobs , l e v e l ) { 2

d e l t a <− s q r t ( q c h i s q ( l e v e l , N a s s e t s ) ) 3

l a m b d a <− t h e t a / ( 1 + t h e t a ( d e l t a / s q r t ( Nobs ) ) ) 4

l a m b d a 5

} 6

# # r o b u s t a l l o c a t i o n and e q u i v a l e n t 7

# # meanv a r i a n c e a l l o c a t i o n 8

t h e t a <− 0 . 7 9

wrc <− PMV( SRoot = SR , mu = mu , SigTerm = SigMin / t h e t a ) 10

# # RC p o i n t on e f f i c i e n t f r o n t i e r 11

r c e q <− c ( s q r t ( t ( wrc ) %% S %% wrc ) , c r o s s p r o d ( mu , wrc ) ) 12

# # E q u i v a l e n t r i s k w e i g h t i n g 13

rweq <− t h e t a 2 l a m b d a ( t h e t a , N a s s e t s = N a s s e t s , Nobs = Nobs , 14

l e v e l = 0 . 9 ) 15

# # E q u i v a l e n t MV p o i n t on e f f i c i e n t f r o n t i e r 16

wmv <− PMV( SRoot = SR , mu = mu , SigTerm = SigMin / rweq ) 17

mveq <− c ( s q r t ( t (wmv) %% S %% wmv) , c r o s s p r o d ( mu , wmv) ) 18

First, the functiontheta2lambda() is defined for computing the equivalent risk weighting for the mean-variance portfolio. The function’s closure has arguments thetafor a given risk weighting of the robust counterpart portfolio,Nassetsfor the count of assets,Nobsfor the sample size, andlevelfor the desired confidence level. The argumentsNassetsandlevelare employed in the computation of the quantile according to a𝜒2 distribution. Starting in line 10, the robust allocation for a value oftheta = 0.7is determined (objectwrc) and the associated point on the efficient frontier is assigned to the objectrceqin line 12. Next, the equivalent risk weighting is computed by callingtheta2lambda(), and its returned value is assigned to the objectrweq. This scalar is then utilized in the call toPMV()to determine the equivalent classical mean-variance allocation (objectwmv). Finally, the associated point on the efficient frontier is computed and stored asmveq.

TheRcode for producing a graphical display of the efficient frontier with equiva- lence points is exhibited in Listing 10.10.

First, the limits of the x- andy-axes are set. Next, the efficient frontier for the computed points according to the classical mean-variance allocations are plot- ted as a line. Superimposed on this graphic are the efficient points with respect to the mean-variance and robust counterpart allocations. Finally, the equiva- lent mean-variance and robust counterpart points are drawn in as computed in Listing 10.9. The outcome is displayed in Figure 10.3.

k k Rcode 10.10Graphical display of efficient frontier for mean-variance and robust

counterpart portfolios.

# # E f f i c i e n t F r o n t i e r 1

# # d e t e r m i n i n g r a n g e s 2

x l i m s <− c ( SigMin 0 . 9 , 3

max ( c b i n d ( MVans [ , 1 ] , RCans [ , 1 ] ) ) ) 4

y l i m s <− c ( min ( c b i n d ( MVans [ , 2 ] , RCans [ , 2 ] ) ) , 5

max ( c b i n d ( MVans [ , 2 ] , RCans [ , 2 ] ) ) ) 6

# # p l o t t i n g e f f i c i e n t f r o n t i e r f o r MV 7

p l o t ( MVans [ , 1 ] , MVans [ , 2 ] , t y p e = " l " , 8

x l i m = x l i m s , 9

y l i m = y l i m s , 10

x l a b = e x p r e s s i o n ( s i g m a ) , 11

y l a b = e x p r e s s i o n ( mu ) ) 12

# # S u p e r i m p o s i n g p o i n t s 13

f o r ( i i n 1 : nrow ( MVans ) ) { 14

p o i n t s ( x = MVans [ i , 1 ] , y = MVans [ i , 2 ] , c o l = " b l u e " , 15

pch = 1 9 ) 16

p o i n t s ( x = RCans [ i , 1 ] , y = RCans [ i , 2 ] , c o l = " r e d " , 17

pch = 1 9 ) 18

} 19

# # S u p e r i m p o s i n g e q u i v a l e n c e p o i n t s 20

p o i n t s ( x = r c e q [ 1 ] , y = r c e q [ 2 ] , c o l = " d a r k g r e e n " , 21

bg = " d a r k g r e e n " , pch = 2 3 ) 22

p o i n t s ( x = mveq [ 1 ] , y = mveq [ 2 ] , c o l = " g r e e n " , bg = " g r e e n " , 23

pch = 2 3 ) 24

# # L e g e n d 25

l e g e n d ( " t o p l e f t " , l e g e n d = c ( " E f f i c i e n t F r o n t i e r " , "MV p o i n t s " , 26

"RC p o i n t s " , 27

e x p r e s s i o n ( p a s t e ( "RC a l l o c a t i o n w i t h " , 28

t h e t a == 0 . 7 ) ) , 29

" E q u i v a l e n t MV−P o r t f o l i o " ) , 30

l t y = c ( 1 , NA, NA, NA, NA) , pch = c (NA, 1 9 , 1 9 , 2 3 , 2 3 ) , 31

p t . bg = c (NA, NA, NA, " d a r k g r e e n " , " o r a n g e " ) , 32

c o l = c ( " b l a c k " , " b l u e " , " r e d " , " d a r k g r e e n " , " o r a n g e " ) ) 33

It can be seen that the robust optimization solutions selected are part of the mean-variance efficient frontier, though the solutions of the former fall short of the latter. This becomes apparent when one compares the equivalent solutions of the mean-variance and robust optimizations. The solution indicated as a point to the far north-east is the corresponding mean-variance solution to the adjacent robust counterpart, which lies to the south-west of it.

k k

4.0 4.5 5.0 5.5 6.0 6.5 7.0

0.700.750.800.850.900.95

σ

μ

Efficient Frontier MV points RC points

RC allocation with θ = 0.7 Equivalent MV−Portfolio

Figure 10.3 Efficient frontier of mean-variance and robust portfolios.

References

Ben-Tal A. and Nemirovski A. 1998 Robust convex optimization.Mathematics of Operations Research23(4), 769–805.

Boyd S. and Vandenberghe L. 2004Convex Optimization. Cambridge University Press, Cam- bridge.

Burger M., Jỹnemann K., and Kửnig T. 2015RUnit: R Unit Test Framework. R package version 0.4.28.

Chalabi Y. and Würtz D. 2014Rsocp: An R extenstion library to use SOCP from R.R package version 271.1.

Cornuejols G. and Tütüncü R. 2007Optimization Methods in Finance. Cambridge University Press, Cambridge.

Davies P. 1987 Asymptotic behavior of S-estimators of multivariate location parameters and dispersion matrices.The Annals of Statistics15, 1269–1292.

Donoho D. 1982 Breakdown properties of multivariate location estimators. Technical report, Harvard University, Boston.

k k Eddelbüttel D. 2013Seamless R and C++Integration with Rcpp. Springer, New York.

Eddelbỹttel D. and Franỗois R. 2011 Rcpp: Seamless R and C++integration.Journal of Sta- tistical Software40(8), 1–18.

Eddelbüttel D. and Sanderson C. 2014 RcppArmadillo: Accelerating R with high-performance C++linear algebra.Computational Statistics and Data Analysis71, 1054–1063.

Fabozzi F., Focardi S., Kolm P., and Pachamanova D. 2007Robust Portfolio Optimization and Management. John Wiley & Sons, New Jersey.

Filzmoser P., Fritz H., and Kalcher K. 2014 pcaPP: Robust PCA by Projection Pursuit. R package version 1.9-60.

Genz A. and Bretz F. 2009Computation of Multivariate Normal and t ProbabilitiesLecture Notes in Statistics. Springer-Verlag, Heidelberg.

Gnanadesikan R. and Kettenring J. 1972 Robust estimates, residuals and outlier detection with multiresponse data.Biometrics28, 81–124.

Hampel F. R., Rochetti E. M., Rousseeuw P. J., and Stahel W. A. 1986Robust Statistics, The Approach Based on Influence Functions. John Wiley & Sons, New York.

Huber P. 1964 Robust estimation of a location parameter.Annals of Mathematical Statistics 35, 73–101.

Huber P. J. 1981Robust Statistics. John Wiley & Sons, New York.

Lee B. and Rowe Y. 2014tawny: Provides various portfolio optimization strategies including random matrix theory and shrinkage estimators. R package version 2.1.2.

Lobo M., Vandenberghe L., and Boyd S. 1997SOCP: Software for Second-order Cone Pro- gramming, User’s GuideStanford University Stanford. Beta Version.

Lobo M., Vandenberghe L., Boyd S., and Lebret H. 1998 Applications of second-order cone programming.Linear Algebra and its Applications284, 193–228.

Lopuhaã H. 1991 Multivariate𝜏-estimators for location and scatter. Canadian Journal of Statistics19, 307–321.

Lopuhaã H. 1992 Highly efficient estimators of multivariate location with high breakdown point.The Annals of Statistics20, 398–413.

Maronna R. and Zamar R. 2002 Robust estimates of location and dispersion of high-dimensional datasets.Technometrics44(4), 307–317.

Maronna R., Martin D., and Yohai V. 2006Robust Statistics: Theory and Methods. John Wiley

& Sons, New York.

Meucci A. 2005Risk and Asset Allocation. Springer-Verlag, New York.

Nesterov Y. and Nemirovsky A. 1994Interior-Point Polynomial Methods in Convex Program- mingvol.13ofStudies in Applied Mathematics. SIAM, Philadelphia.

Pfaff B. 2010Modelling Financial Risks: Fat Tails, Volatility Clustering and Copulae. Frank- furt Allgemeine Buch, Frankfurt am Main.

Pfaff B. 2015cccp: Cone Constrained Convex Problems. R package version 0.2-4.

Rousseeuw P. 1985 Multivariate estimation with high breakdown point InMathematical Statis- tics and Applications(ed. Grossmann W., Pflug G., Vincze I., and Wertz W.) vol. B Reidel Publishing Dordrecht pp. 283–297.

Rousseeuw P. and Leroy A. 1987Robust Regression and Outlier Detection. John Wiley &

Sons, New York.

Rousseeuw P., Croux C., Todorov V., Ruckstuhl A., Salibian-Barrera M., Verbeke T., Koller M., and Mọchler M. 2015robustbase: Basic Robust Statistics. R package version 0.92-5.

k k Scherer B. 2010Portfolio Construction and Risk Budgeting4th edn. Risk Books, London.

Schửttle K. 2007 Robust Optimization with Application in Asset ManagementDissertation Technische Universitọt Mỹnchen Mỹnchen.

Stahel W. 1981Robuste Schọtzungen: Infinitesimale Optimalitọt und Schọtzungen von Kovar- ianzmatrizenPhD thesis Swiss Federal Institute of Technology (ETH) Zürich.

Staudte R. G. and Sheather S. J. 1990Robust Estimation and Testing. John Wiley & Sons, New York.

Todorov V. and Filzmoser P. 2009 An object-oriented framework for robust multivariate anal- ysis.Journal of Statistical Software32(3), 1–47.

Tỹntỹcỹ R. and Kửnig M. 2004 Robust asset allocation.Annals of Operation Reserach132, 132–157.

Venables W. N. and Ripley B. D. 2002Modern Applied Statistics with S4th edn. Springer, New York.

Wang J., Zamar R., Marazzi A., Yohai V., Salibian-Barrera M., Maronna R., Zivot E., Rocke D., Martin D., Maechler M., and Konis K. 2014robust: Robust Library. R package version 0.4-16.

Wang N. and Raftery A. 2002 Nearest neighbor variance estimation (NNVE): Robust covari- ance estimation via nearest neighbor cleaning (with discussion).Journal of the American Statistical Association97, 994–1019.

Wang N., Raftery A., and Fraley C. 2013covRobust: Robust Covariance Estimation via Nearest Neighbor Cleaning. R package version 1.1-0.

Würtz D., Setz T., and Chalabi Y. 2014fPortfolio: Rmetrics—Portfolio Selection and Opti- mization. R package version 3011.81.

Würtz D., Setz T., Chalabi Y., Chen W., and Ellis A. 2009Portfolio Optimization with R/Rmet- rics Update 2015Rmetrics eBooks. Rmetrics Association and Finance Online Publishing, Zürich.

Yohai V. 1987 High breakdown-point and high efficiency estimates for regression.The Annals of Statistics15, 642–656.

Yohai V., Stahel W., and Zamar R. 1991 A procedure for robust estimation and inference in linear regression InDirections in Robust Statistics and Diagnostics (Part II)(ed. Sta- hel W. and Weisberg S.) vol.34ofThe IMA Volumes in Mathematics and its Applications Springer-Verlag New York pp. 365–374.

k k

11

Diversification reconsidered

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 201 - 209)

Tải bản đầy đủ (PDF)

(436 trang)