Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.2K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do I find a least squares regression line of 4 points in a plane?

Posted 11 years ago

How would I find the least squares regression line for the 4 given (x,y) points {{-3, 0}, {-1, 1}, {0, 2}, {2, 3}}? I am trying to use the LeastSquares command, but not having much success understanding the documentation and thus getting the command to work properly.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
2 Replies

Or this:

data = {{-3, 0}, {-1, 1}, {0, 2}, {2, 3}};
line = Fit[data, {1, x}, x];
Show[Plot[line, {x, -3.5, 2.5}], ListPlot[data, PlotStyle -> Red], PlotLabel -> ToString[line]]

enter image description here

Cheers,

M.

POSTED BY: Marco Thiel
Posted 11 years ago

You should use LinearModelFit rather than LeastSquares given that you have the data points rather than the structure m.x == b as described in the documentation.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard