[R] Linear Regression with Constraints

Emmanuel Charpentier charpent at bacbuc.dyndns.org
Wed May 27 09:05:21 CEST 2009


Le mardi 26 mai 2009 à 14:11 -0400, Stu @ AGS a écrit :
> Hi!
> I am a bit new to R.
> I am looking for the right function to use for a multiple regression problem
> of the form:
> 
> y = c1 + x1 + (c2 * x2) - (c3 * x3)
> 
> Where c1, c2, and c3 are the desired regression coefficients that are
> subject to the following constraints:
> 
> 0.0 < c2 < 1.0, and
> 0.0 < c3 < 1.0

Sounds rather like an in-the-closet Bayesian problem (with a very
strange prior...). Did you consider to submit it to WinBUGS (or JAGS) ?

If you still want a direct optimization, you could have started :

RSiteSearch("optimization constraint")

Which would have quickly led you to ask :

? constrOptim

> y, x1, x2, and x3 are observed data.  
> I have a total of 6 rows of data in a data set.

??? I that's real-life data, I wonder what kind of situation forces you
to estimate 3+1 parameters (c1, c2, c3 and the residual, which is not
really a parameter) with 6 data points ? Your problem can be written as
a system of 6 linear equations with 3 unknowns (c1, c2, c3), leaving you
room to search in (a small piece of) R^3 (the residual is another way to
express your objective function, not an independent parameter).

Of course, if it's homework, get lost !

					Emmanuel Charpentier

> Is "optim" in the stats package the right function to use?
> Also, I can't quite figure out how to specify the constraints.
> Thank you!
> 
> -Stu
> 




More information about the R-help mailing list