What is best way to run OLS in R with linear inequality constraints, e.g. $$y(x)= ax + b,$$ where $0<a<1$?
Asked
Active
Viewed 1,902 times
1
-
1did you get cut off there? – Eric Peterson Jul 19 '13 at 14:19
-
I copied the title of your question into Google. First hit: an article on Inference with Linear Equality and Inequality Constraints Using R – Stijn Jul 19 '13 at 14:27
-
Good find, @Stijn. That package could be overkill for such a simple problem, though: on any platform it's easy to run OLS and check whether $0\lt a \lt 1$ and, if not, to run and compare the two submodels $y=b$ and $y=x+b$. – whuber Jul 19 '13 at 14:30
-
Wait, is this about linear constraints, or box constraints? – Hong Ooi Jul 19 '13 at 15:09
1 Answers
1
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.
Hong Ooi
- 8,249