| ||||||||||||||||||
Regression / Least Squares
To call up the Regression window, select the menu item File => Regression / Least Squares.
Five modes of regression / least squares calculation are supported. All except 'Absolute Deviation' attempt to minimise the sum of the squares of the differences between each (X, Y) data point and the 'predicted' Y value.
- Linear regression fits a linear function, i.e. a straight line, to the data.
- Polynomial regression attempts to fit a polynomial of specified order to the data.
- Non-linear least squares fit attempts to fit an arbitrary expression to the data, adjusting the expression's variables for the best match. More information on this method is available here.
- Multivariate regression attempts to fit a linear function of a set of variates
X0,X1,X2etc. - Absolute deviation regression is similar to linear regression, but minimises the sum of the absolute deviations (rather than the sum of their squares) to reduce the effects of outlying points.
More information on the differences between the various modes is available here.

How To Use
The image above shows the regression window when the mode is set to 'Polynomial'. The calculation mode can be changed by clicking on the Mode button.
The order for the polynomial (1 to 10) is altered by clicking on the little vertical arrows, or by holding down the Control key and pressing the plus or minus keys on the numeric keypad. The number of variates for multivariate regression (2 to 8) and the number of variables for nonlinear least squares (1 to 8) are changed in the same way. The window will change its size as necessary.
Data is entered into the Data Entry control. More information on using this control is available here. Hitting 'Enter' after entering some data causes an attempt to calculate the results. If there is not enough data to do so, the results are shown as "???".
If the amount of data supplied is the minimum required, the deviation about the line is shown as "---". This indicates that the data match the calculated regression exactly, and that there is not enough data to be able to determine its random variation.
Most modes use a window very similar to the one shown above. However, a nonlinear least squares fit requires rather different information and its window is very different. Full details will be found here.
'Calc X' and 'Calc Y'
After entering sufficient data to allow a solution to be calculated (as shown by the results being shown as numeric values), it is possible to calculate the value of Y for a given value of X, or for a given collection of X values for multivariate regression. The inverse, of calculating X for a given value of Y is of course not possible for multivariate regression, and may fail or may have multiple solutions in other cases.
Data Transformations
To apply a transformation to your data, double click the X = or Y = labels.
A small window will open to allow you to choose from a set of predefined transformations, or to enter your own.
If the mouse cursor rests over this label or over the adjacent edit box, a tool tip window will show you
the transformation currently in use, if any.
Plotting the Results
The data and resulting regression can be shown on a plot by selecting the check box at bottom left. Unselecting this check box hides the plot. Unfortunately, this does not apply to multivariate regression, due to the multidimensional nature of the problem. To change the appearance of the plot, right click on it and select Set Display Properties from the menu that pops up. Among other things, the properties selector enables you to zoom in on regions of particular interest.
Show Results
Calculations are performed to full precision, but due to limitations of space, the results are shown to lower precision in the window. To see the results in greater precision, set UltimaCalc's main window to the required precision and click on the 'Show' button in the regression window. The results will then be shown in the multiple results window. From this window they can be copied to the Windows clipboard and then pasted into any program that accepts copying of plain text.
Viewing the X-Y coordinates
If you right click on the plot window when there is enough data to show a plot, the menu that pops up includes an item, Show X-Y Values. If you select this, the window enlarges slightly to accomodate scroll bars which control horizontal and vertical lines drawn above the plot. The horizontal scroll bar moves the vertical line, and at the point (or points) at which it crosses a curve, the X-Y coordinates of the intersection will be displayed. The vertical scroll bar works similarly.
To nudge by one pixel at a time, use the arrow keys, or click on the arrow icons at the ends of the scroll bars.
Logging the Results
Just to the right of the check box and its icon there is a log file icon which allows you to save your results to the log file without having needless intermediate steps also recorded. This icon works even when automatic logging is turned off. If you have not yet specified a log file, you will be invited to specify one at this time. The icon is active when it is highlighted.
Erase Data
The 'Erase' button allows you to quickly erase all data. You will be promped to save any old data first, if necessary.
Saving
To save the displayed plot as an image file, right click on it and use the pop-up menu that appears. (More details)
The 'Save...', 'Save As...' and 'Open...' buttons allow you to save your data as a plain text file and reload it later.
Notes
The 'Notes' button allows you to write some notes to be saved along with the data, and to view any notes you wrote previously. These notes will be saved along with the data.
Variables
The various regression modes store their calculated values in several variables, so that these values can be accessed from UltimaCalc's main window. It is a good idea to not use these variables for other purposes. Nonlinear least squares fit also uses the variables which are used as parameters, so after calculating a fit, these variables have the calculated values.
Linear regression
The parameters of the straight line, the correlation coefficient, and the standard deviation of the error
are stored as the variables intercept, slope, corr, and sd.
(If the standard deviation could not be calculated, due to insufficient data, it will still be
defined as a variable, but the variable will not have any value.)
Polynomial regression
The calculated polynomial coefficients are stored as the variables a0, a1, a2,
etc. The standard deviation of the error is stored as the variable sd.
Multivariate regression
The coefficients of the variates X0, X1, X2
etc. are stored as the variables a0, a1, a2. The standard deviation of the
error is stored as the variable sd, as above.
