Linear regression with constraints on conditional y

Hi everyone,
I am struggling with a linear regression with constraints. I have y and x variables which are both vectors 89x1. I am trying to implement a regression in which the parameters alpha and beta are estimated under a constraint such that:
alpha + beta*x(tao) >=0 for tao = 1,...,t
I was trying to use the command lsqlin but I do not understand what should the matrixes be in my optimization problem.
Can someone guide me through the implementation of it? Thank you in advance!!

2 Comments

So you want to find alpha, beta such that
y(x) = alpha + beta*x
is a good approximation for your data vectors (x_data,y_data) and alpha + beta*x_data >= 0 ?
Best wishes
Torsten.
I'll try to answer your question, but you've left out too much information for me to be confident. I think this is because you've tried to put in only what you think is pertinent, and you also tried to add some formalization to the process. So my answer below is only a guess. If you can clear up your question, that would help.

Sign in to comment.

 Accepted Answer

Ok, only a guess here.
I THINK you are trying to solve the problem
y = alpha + beta*x
for vectors x and y (assume column vectors, each of length 89) subject to the set of linear inequality constraints...
alpha + beta*x >= 0
So this is a linear least squares problem, and you want to enforce that all predictions for y are non-negative. Maybe. Again, this is just a wild guess.
So just pose it as a problem for lsqlin...
n = numel(x);
A = [ones(n,1),x];
alphabeta = lsqlin(A,y,-A,zeros(n,1));
alpha = alphabeta(1);
beta = alphabeta(2);
It is important to remember that the inequality constraint in lsqlin is <=0. So I had to flip the sign on A.
I'm not totally sure why you are trying to do this, since for some values of x, possibly outside the support of your data, this linear model must predict negative numbers as long as beta is non-zero.
I wonder if your goal is really in the form of non-negative residuals, and you have just stated the problem wrong above. Non-negative residuals are a problem I've often had to solve, as this corresponds to an envelope problem. Thus, find the regression model that is as close to the data as possible, yet is always just slightly below (or above) the data. It can be formulated for splines as well as simple lines.

2 Comments

Hi John, many thanks for your quick reply, yes your guess was totally right, sorry that I did not specify enough my problem initially!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!