Homework 2
MAFS5310 - Portfolio Optimization with R
Fall 2023-24
You should prepare your solution in R Markdown and submit the generated .html or .pdf file. Report all the steps neatly and also provide the R code snippet.
(Q) We consider the Markowitz’s mean-variance portfolio with penalty on max position, where we aim to find a trade-off between the expected return w⊤μ and the risk of the portfolio measured by the variance w⊤Σw:
maximize w⊤μ− λw⊤Σw−γ∥w∥∞ w
subjectto w≥0, 1⊤w=1,
where w ∈ Rn,μ ∈ Rn,Σ ∈ Rn×n, w⊤1 = 1 is the capital budget constraint, λ is a parameter that controls how risk-averse the investor is. The above optimization problem has one variable, i.e., w ∈ Rn and two hyper-parameters, i.,e., λ ≥ 0 and γ ≥ 0. The choice of hyper-parameters play a crucial role in the overall performance of portfolio optimization algorithm. For γ = +∞ it becomes the uniform portfolio, and for γ = 0 it is the trivial MVP. For sufficiently large λ, the above problem becomes the global minimum variance portfolio and for λ = 0 it is the global maximum return portfolio. A universal rule for choosing hyper-parameters is not available, as choices are specific to the individual datasets, leading to cross-validation methods. The aim of this assignment is to help you to understand the intricacies of parameter selection and their effect on the final performance of a portfolio optimization algorithm.
Use the datasets available in the package ”portfolioBacktest” and perform the following tasks. ˆ Consider datasets: dataset10[[1]] to dataset10[[5]]. The setting of the experiment is as follows:
– You have to use dataset10[[1]] to dataset10[[5]]..
– Chose a set of L = 50 different values of hyperparameters, {λi,γi} for i = 1,2,...,L. – and do the following
(a) For d=dataset10[[1]] to dataset10[[5]].
(b) Fori=1:L
(c) Use hyper-parameters: γi, λi, and
(d) compute w[d, i] by solving the above optimization problem.
* Optimal weight vector for the d dataset using the ith hyper-parmeter. (e) Compute the Sharpe ratio (SR) S[d, i]
ˆ After completing the steps in (a) to (e) above. Report the hyper-parameter values and the corre- sponding Sharpe ratio in a tabular form. There will be a total of 5 such tables. Highlight the set of hyper-parameters which yields the best Sharpe ratio and the worst Sharpe ratio values.
ˆ If you choose the hyperparameters that give maximum SR on, say, the first dataset, is that maintained on the other datasets?
ˆ How should you choose the best hyper-parameters overall? Explain and then make your final choice. ˆ How do these experiments fit with what you learned in the lecture of backtesting?