From: Adam Schirmacher on 16 Jun 2010 10:50 Hello everyone. I am using MATLAB to compute multiple regressions. For the purpose of this message let's just assume my regressions are using three (3) independent variables and I will have a five (5) data points from which to calculate the regression. I have a requirement that my regression MUST pass through a specific point (an intercept). I have followed the simple examples for multiple regressions, but none of them mention an intercept or intercepts. Certainly this is mathematically possible. Can anyone point me to a resource which will help me find out how to compute a multiple regression with an intercept?
From: Matt J on 16 Jun 2010 11:12 "Adam Schirmacher" <adam.schirmacher(a)medtronic.com> wrote in message <hvaobg$302$1(a)fred.mathworks.com>... > Hello everyone. I am using MATLAB to compute multiple regressions. For the purpose of this message let's just assume my regressions are using three (3) independent variables and I will have a five (5) data points from which to calculate the regression. I have a requirement that my regression MUST pass through a specific point (an intercept). > > I have followed the simple examples for multiple regressions, but none of them mention an intercept or intercepts. Certainly this is mathematically possible. Can anyone point me to a resource which will help me find out how to compute a multiple regression with an intercept? ================ So, you have a data fitting model y-y0=bsxfun(@minus,X,x0)*beta where x0,y0 are your intercept coordinates and beta is the vector of unknown parameters. Then the fit is beta=bsxfun(@minus,X,x0)\(y-y0);
From: John D'Errico on 16 Jun 2010 11:18 "Adam Schirmacher" <adam.schirmacher(a)medtronic.com> wrote in message <hvaobg$302$1(a)fred.mathworks.com>... > Hello everyone. I am using MATLAB to compute multiple regressions. For the purpose of this message let's just assume my regressions are using three (3) independent variables and I will have a five (5) data points from which to calculate the regression. I have a requirement that my regression MUST pass through a specific point (an intercept). > > I have followed the simple examples for multiple regressions, but none of them mention an intercept or intercepts. Certainly this is mathematically possible. Can anyone point me to a resource which will help me find out how to compute a multiple regression with an intercept? Only 5 points to estimate 3 parameters is a bit low in general, but I will pretend you really have more data. First of all, how do you fit a regression model that has NO constant term? If X,Y,Z,W are column vectors (important), then to fit the model W = a(1)*X + a(2)*Y + a(3)*Z you would just do this: a = [X,Y,Z]\W; If they might not be column vectors, then this will be robust to their shape. a = [X(:),Y(:),Z(:)]\W(:); Now, suppose we wanted to fit the model W = C + a(1)*X + a(2)*Y + a(3)*Z where C was a KNOWN constant? Can you fit that as easily? Sure, because this just reduces to the simple form (W - C) = a(1)*X + a(2)*Y + a(3)*Z Use the line of code to fit (W-C) as a linear function of the variables X,Y,Z. The word intercept can mean different things to different people however. It sounds like you wish to ensure that the surface will pass through a specific point. (x0,y0,z0,w0). An easy way to do this is to use lsqlin, from the optimization toolbox. lsqlin can set an equality constraint on the problem. Lacking that toolbox, you can download my lse from the file exchange. http://www.mathworks.com/matlabcentral/fileexchange/13835 The the call is simply: a = lse([X,Y,Z],W,[x0,y0,z0],w0); The call to lsqlin would be similar of course. HTH, John
From: Adam Schirmacher on 16 Jun 2010 12:14 "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hvapvc$mhi$1(a)fred.mathworks.com>... > Only 5 points to estimate 3 parameters is a bit low > in general, but I will pretend you really have more > data. > > Now, suppose we wanted to fit the model > > W = C + a(1)*X + a(2)*Y + a(3)*Z > > where C was a KNOWN constant? Can you fit that > as easily? Sure, because this just reduces to the > simple form > > (W - C) = a(1)*X + a(2)*Y + a(3)*Z > > Use the line of code to fit (W-C) as a linear function > of the variables X,Y,Z. > > The word intercept can mean different things to > different people however. It sounds like you wish to > ensure that the surface will pass through a specific > point. (x0,y0,z0,w0). > > An easy way to do this is to use lsqlin, from the > optimization toolbox. lsqlin can set an equality > constraint on the problem. > > The the call is simply: > > a = lse([X,Y,Z],W,[x0,y0,z0],w0); > > The call to lsqlin would be similar of course. Ah-ha! That is some very useful advice indeed. I didn't even know that function existed. I do see though that this does not return a constant term in the regression. It would just return coefficients A, B and C where w=Ax + By + Cz. What about returning another term for w=Ax + By + Cz + D? In reality the former sets an additional constraint, which is that the regression passes through (0, 0, 0, 0) which I do not need.
From: Matt J on 16 Jun 2010 12:19 "Adam Schirmacher" <adam.schirmacher(a)medtronic.com> wrote in message <hvat8d$mst$1(a)fred.mathworks.com>... > In reality the former sets an additional constraint, which is that the regression passes through (0, 0, 0, 0) which I do not need. Again, though, you can pre-shift your coordinate measurements so that the intercept *is* at (0,0,0,0) and perform the fit in this shifted space. If you do, however, I don't see why you would need any fancy iterative solvers. I think backslash \ should do fine
|
Next
|
Last
Pages: 1 2 Prev: 'find' and placing into respective columns Next: multiple line graphs on single graph window |