port_estim_solver: Nummerical Portfolio Optimization with constraints

Description Usage Arguments Details Value Examples

View source: R/port-optim.R

Description

Calculates the weights of a GMV or tangency portfolio strategy with different constraints and/or penalties.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
port_estim_solver(
  Sigma,
  mu = NULL,
  rf = 0,
  gamma = 2,
  Aeq = NULL,
  beq = NULL,
  A = NULL,
  b = NULL,
  lambda1 = 0,
  penidx1 = NULL,
  lambda2 = 0,
  penidx2 = NULL,
  gross_c = NULL,
  porttype = "GMV",
  zero_tol = 1e-07,
  res_all = FALSE
)

Arguments

Sigma

a pxp matrix, the covariance matrix of asset returns.

mu

a vector, the expected returns. Default value is NULL.

rf

a double, the assumed risk-free return. Default value is 0.

gamma

an integer, the assumed risk-averse parameter. Default value is 2.

Aeq

a cxp equality constraint matrix, containing c constraints for p regressors. Default value is Aeq=NULL, no equality constraints.

beq

a cx1 equality constraint vector. Default value is beq=NULL, no equality constraints.

A

a cxp inequality constraint matrix, containing c constraints for p regressors. Default value is A=NULL, no inequality constraints.

b

a cx1 inequality constraint vector. Default value is b=NULL, no inequality constraints.

lambda1

a tuning parameter value for the lasso penalty. Default value is lambda1=0.

penidx1

a logical px1 vector, indicating which coefficients are to be penalized with the lasso penalty lambda1. Default value is penidx1=NULL and imposes penalty on all p coefficients.

lambda2

a tuning parameter value for the ridge penalty. Default value is lambda2=0.

penidx2

a logical px1 vector, indicating which coefficients are to be penalized with the ridge penalty lambda2. Default value is penidx2=NULL and imposes penalty on all p coefficients.

gross_c

a double, the requied gross exposure constraint. Default value is NULL (no constraint). Attention! Works only with GMV.

porttype

a character string. Possible values are "Tang" (tangency portfolio) and "GMV" (global minimum variance portfolio). Default value is "GMV".

zero_tol

a double, indicating the zero tolerance for the calculated weights. Default value is 1e-7.

res_all

a logical. If TRUE, the result includes the calculated weights and the duals from the optimization. If FALSE, only the weights. Default value is FALSE.

Details

The portfolio optimization with constraints minimizes

0.5||y - X β ||^2_2 + λ_1||β||_1 + λ_2||β||^2_2,

subject to Aeq β = beq and A β≤ b.

Value

a vector of length p with the weights of the portfolio.

a list with the weights vector and the duals from the optimization.

Examples

1
2
3
4
5
6
data(sp500_rets)
example_rets <- sp500_rets[,2:11]
covMat <- var(example_rets)
muVec <- colMeans(example_rets)
port_estim_solver(covMat)
port_estim_solver(covMat, muVec, porttype="Tang")

antshi/auxPort documentation built on Oct. 27, 2020, 1:16 p.m.