# Solved – Constrained Linear Regression with coefficients related by inequality

I have a (slightly simplified) model of the following form:

\$Y=c_1X_1 + c_2X_2 + epsilon\$ subject to the constraint \$0leq c_1leq c_2\$.

The distribution of \$epsilon\$ is actually not important to me – fitting the curve by least squares is all I care about (for a volatility surface parameterization).

What is the best approach to solving this with deterministic results (i.e. not using iterative techniques dependent on starting points etc.).

I am working in C++ and I have Armadillo for my linear algebra library.

I am comfortable with python's libraries as well and R if necessary, but ultimate implementation will be C++.

Contents

Reformulate your model to $$Y = c_1(X_1+X_2) + (c_2-c_1) X_2 + epsilon$$ (and probably an intercept which you have left out). Then the constraints is $$0le c_1, 0le (c_2-c_1)$$, and you can use an implementation of nonnegative least squares. In `R` there is a package `colf`, see an example in Looking for function to fit sigmoid-like curve. See also Linear Regression with individual constraints in R.