\-operator to perform least squares fit on multiple sample-sets

7 views (last 30 days)
Is there a matrix expansion of the \-operator that enables least squares fit of y = M\x where M is an m-by-n-by-p matrix and x is an m-length vector m=[3 .. 10]; n =3 for order 2?

Answers (2)

bym
bym on 14 Jan 2012
  3 Comments
Eugene
Eugene on 14 Jan 2012
It appears that this code has 3 sets of x and 3 sets of y. My issues is many-sets of x, but only one set of y. If I understand the code correctly it requires that the y's not overlap each other in order to get the 3-distinct curves. If I try replicating the y-values then I only get 1 set of coeffs.
Somehow I need to get the operator to take the data n-values at a time without a for-loop. Any thoughts would be appreciated
Thanks
Eugene
Eugene on 19 Jan 2012
Since I'm trying to fit multiple samples to multiple targets, the fact that y can be a matrix is very helpful but not everything I would like. If the operator could parse the data as a function of the order and the size of y that might work.
thanks

Sign in to comment.


Andrew Newell
Andrew Newell on 19 Jan 2012
If I understand your question, you are trying to estimate y given multiple measurements of x. Note that if M were a matrix, the correct least squares estimate would be
yhat = (M'*M)\(M'*x);
(see also this answer).
You would be well advised to recast your problem. Instead of several vectors x, make one vector X containing all the data. Then reshape M so
y = M*X;
and then use the above expression.
  6 Comments
Andrew Newell
Andrew Newell on 22 Jan 2012
I'm not sure what you mean by "curve". To me, a set of (x,y) values represents points on a curve - in the example above, you would have four curves, one for each row of X.
Eugene
Eugene on 24 Jan 2012
Yes an (x,y) set are points on a curve. In this case y is also a curve (a set of data with respect to (wrt), say z) and all four rows of X are also wrt z and we are trying to find the quadratic coefficients that when applied to each row in X, that will cause each row in X to closely match y.

Sign in to comment.

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!