What is best way to run OLS in R with linear inequality constraints, e.g.

$$y(x)= ax + b,$$ where $0<a<1$?

**Contents**hide

#### Best Answer

You can use `constrOptim`

to minimise the RSS, subject to the constraints. There's an example in *Modern Applied Statistics with S* of using optim to do logistic regression via direct minimisation of the negative log-likelihood; just do the same, but changing the binomial likelihood to sums of squares and adding the constraint.