Tag Archives: Quadratic Programming

Another Quadratic Programming Example with R

Following Quadratic Programming with R, this is another example of how to solve quadratic programming problem with R package “quadprog“.

Why Another Example?

Quadratic programming matrix math notation
quadratic programming matrix notation

quadprog” package requires us to rewrite the quadratic equation in the proper matrix equation as above. You may have the following questions:

  • What if our equation is to maximize the objective function instead of minimize it?
  • What if the inequality constraints are “less than (<=)” instead of “more than (>=)”?
  • What if there is no equality constraints?

To give you an idea how to answer these questions, this post will give you another example.

Continue reading

Quadratic Programming with R

Optimization of a quadratic function

Quadratic programming problems can be solved with “quadprog” package in R and the key point is to find the matrix notation of quadratic programming problems:

Example

Let’s figure out how to do it with an example of “Applying Nonlinear Programming to Portfolio Selection”:

Please note that, this example involves three variables (x1, x2, and x3). If you want an example of two variables (x1 and x2), please check my another post: Another Quadratic Programming Example with R.

Continue reading