minvar: Minimum-Variance Portfolios

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/portfolio.R

Description

Compute minimum-variance portfolios, subject to lower and upper bounds on weights.

Usage

1
minvar(var, wmin = 0, wmax = 1, method = "qp")

Arguments

var

the covariance matrix: a numeric (real), symmetric matrix

wmin

numeric: a lower bound on weights. May also be a vector that holds specific bounds for each asset.

wmax

numeric: an upper bound on weights. May also be a vector that holds specific bounds for each asset.

method

character. Currently, only "qp" is supported.

Details

The function uses solve.QP from package quadprog package. Because of the algorithm that solve.QP uses, var has to be positive definit (i.e. must be of full rank).

Value

a numeric vector (the portfolio weights) with an attribute variance (the portfolio's variance)

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2011) Numerical Methods and Optimization in Finance. Elsevier. https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-375662-6

Schumann, E. (2012) Computing the global minimum-variance portfolio. http://enricoschumann.net/R/minvar.htm

Schumann, E. (2012–2018) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

See Also

TAopt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
## variance-covariance matrix from daily returns, 1 Jan 2014 -- 31 Dec 2013, of
## cleaned data set at http://enricoschumann.net/data/gilli_accuracy.html

if (requireNamespace("quadprog")) {

    var <- structure(c(0.000988087100677907, -0.0000179669410403153, 0.000368923882626859, 
                       0.000208303611101873, 0.000262742052359594, -0.0000179669410403153, 
                       0.00171852167358765, 0.0000857467457561209, 0.0000215059246610556, 
                       0.0000283532159921211, 0.000368923882626859, 0.0000857467457561209, 
                       0.00075871953281751, 0.000194002299424151, 0.000188824454515841, 
                       0.000208303611101873, 0.0000215059246610556, 0.000194002299424151, 
                       0.000265780633005374, 0.000132611196599808, 0.000262742052359594, 
                       0.0000283532159921211, 0.000188824454515841, 0.000132611196599808, 
                       0.00025948420130626),
                     .Dim = c(5L, 5L),
                     .Dimnames = list(c("CBK.DE", "VOW.DE", "CON.DE", "LIN.DE", "MUV2.DE"),
                                      c("CBK.DE", "VOW.DE", "CON.DE", "LIN.DE", "MUV2.DE")))
    
    ##            CBK.DE     VOW.DE    CON.DE    LIN.DE   MUV2.DE
    ## CBK.DE   0.000988 -0.0000180 0.0003689 0.0002083 0.0002627
    ## VOW.DE  -0.000018  0.0017185 0.0000857 0.0000215 0.0000284
    ## CON.DE   0.000369  0.0000857 0.0007587 0.0001940 0.0001888
    ## LIN.DE   0.000208  0.0000215 0.0001940 0.0002658 0.0001326
    ## MUV2.DE  0.000263  0.0000284 0.0001888 0.0001326 0.0002595
    ##

    minvar(var, wmin = 0, wmax = 0.5)
    
    minvar(var,
           wmin = c(0.1,0,0,0,0), ## enforce at least 10% weight in CBK.DE 
           wmax = 0.5)
    
    minvar(var, wmin = -Inf, wmax = Inf)   ## no bounds
    ## [1] -0.0467  0.0900  0.0117  0.4534  0.4916

    minvar(var, wmin = -Inf, wmax = 0.45)  ## no lower bounds
    ## [1] -0.0284  0.0977  0.0307  0.4500  0.4500

    minvar(var, wmin =  0.1, wmax = Inf)   ## no upper bounds
    ## [1] 0.100 0.100 0.100 0.363 0.337
    
}

enricoschumann/NMOF documentation built on Feb. 14, 2019, 2:21 p.m.