DADiSP Worksheet Functions > Function Categories > Curve Fitting > LINREG

 

LINREG

Purpose:

Determines the least squares fit of a line to a series.

Syntax:

LINREG(series, info)

(s, slope, intercept, Se, report) = LINREG(

series, info)

series

-

A series or multi-column table.

info

-

Optional. An integer, the display fit statistics flag:

0:

OFF, no information is displayed and the regression line is plotted immediately (default).

1:

ON, the line's slope, y-intercept, and standard error are displayed in a message box and after the OK button is pressed, the line is plotted.

Returns:

An interval (regularly spaced) series, the regression line in the form y = mx + b. If info is 1, the slope m, the y-intercept b, and the standard error are displayed in a message box.

 

(s, slope, intercept, Se, report) = LINREG(series, info) returns the regression line, slope, intercept, standard error and regression equation in separate variables.

Example:

linreg(gline(100, .01, 1.0, 1.0)^3, 1)

 

displays the slope and y-intercept of the regression line and after the OK button is pressed, plots the line that best fits the data.

Example:

linreg(gline(100, .01, 1.0, 1.0)^3)

 

Same as above, except the regression line is returned immediately without reporting.

Remarks:

If the input is an XY series, LINREG returns an XY series where the X values are the same as the X values of the input series. For example:

 

W1: xy(grand(10,1), grand(10,1))

W2: linreg(w1)

 

W2 contains an XY series.

 

See PFIT to fit a polynomial with error statistics.

 

See LINREG2 to fit a line to separate X and Y series.

 

See LFIT to fit a line using only the endpoints.

 

See LINFIT to fit linear combination of arbitrary basis functions to a series using the method of least squares.

 

See DETREND to remove a regression line or piecewise continuous regression line from a series.

See Also:

DETREND

LFIT

LINFIT

LINREG2

PFIT

POLYFIT

POLYGRAPH