St. Lawrence University homepage SLU Physics homepage

 

Calculating Residuals & SSR (χ2)
with KaleidaGraph 3.5©

   If you've used a spreadsheet program before (such as Microsoft Excel), the difference you'll notice when using KaleidaGraph is that you don't reference cells individually, but by column. Columns are designated by a number which appears near your titles in the data window. The first column is zero, then one, two, etc. The interesting thing about KaleidaGraph is that these column references are not absolute; clicking the mouse in a cell in the second column changes its designation to zero. For our purposes, it will be important to be sure that your data is selected in the first column, so that it will be referred to as column zero. If you forget to do this, you'll get an error message when trying to execute a formula.

   The Formula Entry window will allow you to create equations that act on an entire column of data at once. You will be able to fill up multiple columns of data with one entry in the Formula Entry window.

Note: These instructions assume that residuals and SSR are being calculated for linear data, but they hold for other functions as well.

CALCULATING RESIDUALS

   When you perform curve fitting, the line that KaleidaGraph draws won't necessarily go through each data point. The residuals are the difference between the actual y values of the data, and the corresponding points on the line.

  1. Click on the graph window to select it, and make sure it contains a curve fit. For Data Set #1 of the Fitting Data exercise, be sure to choose the General fit "Linear through origin".

  2. With the fit in place, again choose your curve fit. In the dialog box that appears, click the down-arrow that appears below "View", and choose Copy Residuals to Data Window. When you click OK, a column called "Residuals" is added to your data.

CALCULATING SSR

   Now that the residuals have been calculated, they need to be squared, and the squares added up. You will create a short formula to accomplish this task.

  1. In the Formula Entry window, click the F1 button (note that you can enter 8 different functions). KaleidaGraph refers to the first column of your data as C0, the zeroth column. The residuals are located in the third column (C2), and we want the square of the residuals to appear in the fourth column (C3). Enter the following in the Formula Entry window:

    c3 = c2^2

  2. The sum of the squares of the residuals (SSR) can now be calculated; KaleidaGraph will display the sum in a separate window. To sum the residuals (in the fourth column, C3) enter:

    sum(c3)

    KaleidaGraph allows you to create several formula's at once; they need only be separated by a semicolon. So, your formula entry window should read:

    c3 = c2^2;sum(c3)

  3. Before you can execute the formula, you must select column zero by clicking once on the column title (if you only select one cell you'll get erroneous results). Next, click the formula entry window to select it, then click the Run button. If all goes well, a Macro Results window will appear, containing your SSR value.

    You should note that the value that you calculate is the same as the "Chisq" value that appears in the results table on your graph!

Return to Physics 151


© St. Lawrence University Department of Physics
Revised: 25 Aug 2021 Canton, NY 13617