Intermediate Portfolio Analysis in R
Ross Bennett
Instructor
Many solvers are not specific to portfolio optimization
Understanding the capabilities and limits of solvers to select the appropriate solver for the problem or formulate the problem to fit the solver
Difficult to switch between solvers
Closed-Form solver (e.g., quadratic programming)
Global solver (e.g., differential evolution optimization)
$$\omega_{i} >= 0$$
$$\sum_{i=1}^{n} \omega_i = 1$$
Use the R package quadprog
to solve the quadratic utility optimization problem
solve.QP()
solves quadratic programming problems of the form:
$$min(-d^Tb+\frac{1}{2}b^TDb)$$
$$A^Tb>=b_0$$
library(quadprog)
data(edhec)
dat <- edhec[,1:4]
# Create the constraint matrix
Amat <- cbind(1, diag(ncol(dat)), -diag(ncol(dat)))
# Create the constraint vector
bvec <- c(1, rep(0, ncol(dat)), -rep(1, ncol(dat)))
# Create the objective matrix
Dmat <- 10 * cov(dat)
# Create the objective vector
dvec <- colMeans(dat)
# Specify number of equality constraints
meq <- 1
# Solve the optimization problem
opt <- solve.QP(Dmat, dvec, Amat, bvec, meq)
Intermediate Portfolio Analysis in R