Least Square Fitting & Regression
When you try to fit a line to a number of points, you add the distances from the points to the line and minimize the sum of the squares of the distances. In mathematics the distance between a point and a line is defined as the shortest distant, i.e. the perpendicular distance. When you do numerical calculations however, there are various ways of defining the distance.
The segments are perpendicular to the red line. Move the line and try to get an optimal fitting. The line is optimal when the sum of the squares is minimized. Do not show the line of best fit until you have found a best fit by yourself.
The segments are vertical. Move the line and try to find an optimal fitting. Do not show the line of best fit until you have found a best fit by yourself.
The green line is made with the Best line fit tool. Which method is used by GeoGebra, a perpendicular or vertical fitting?
Regression in GeoGebra
Storks and babies, 2005
|Country||Storks · 1000||Babies/1000 population|
|Serbia and Montenegro||0.998||12|
Copy the numbers in the table above into GeoGebra. Selecting the entire table and then Copy/Paste to a GeoGebra spreadsheet should work.
Select the two columns of numbers and make a list of points.
Choose "Dependent Objects"! If you create the points as free objects, they will no longer be attached to the values in the spreadsheet.
Zoom out until you can see the points in the drawing pad. In order to see the regular tool bar, you must first click anywhere in the drawing pad.
Best Line Fit tool and click on the list,
Changing the data
You can move any point in the drawing pad, the regression line is automatically updated and the value of the point is automatically updated in the spreadsheet. You can also change the value of a point in the spreadsheet.
You can fit the data points to other curves by using one of the commands
FitSin[list1]. Try them all, not
all will be defined. Move the points around!.
A (n-1)-degree polynomial will fit n data points exactly, i.e. each of the points will lie on the curve. High order polynomials can, however, be impractical for various reasons; they can be highly oscillatory and difficult to handle.
When making a polynomial fitting in GeoGebra you use two parameters; the first
one is the list and the second is the degree of the polynomial. Try the command
Stork numbers from The sixth International White Stork Census: 2004-2005
Birth numbers from NationMaster.com
by Malin Christersson under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Sweden License