LINREG2

Purpose:

Performs a linear regression of one series vs. another.

Syntax:

LINREG2(yseries, xseries, info)

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

yseries, xseries, info)

yseries

-

A series, the Y values.

xseries

-

A series, the X values.

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 XY 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) = LINREG2(yseries, xseries, info) returns the regression line, slope, intercept, standard error and regression equation in separate variables.

Example:

W1: gsin(25, .01)

W2: linreg2(3*W1 - 1, W1, 1)

 

displays y = 3.000x + -1.000, Standard error = 0.0 in a message box and after the OK button is pressed, plots the line that best fits the data.

Example:

linreg2(3*W1 – 1, W1)

 

plots the line that best fits the data, immediately.

Example:

W1: xy(gsin(10,.01, 4, pi), 1..10)

W2: linreg2(yvals(W1), xvals(W1));overp(W1, lred)

 

W2 contains the XY regression line with the original XY data overplotted in red.

Remarks:

The Y values of each series are used to make an XY plot. The line generated is the least squares fit to the XY data.

 

Argument order affects line generated.

 

The X values of the resulting regression line are the same as xseries.

 

The length of the shorter series determines number of points to be used and the length of the generated line.

 

See PFIT to fit a polynomial with error statistics.

 

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

 

See PEARSON to return the correlation coefficient.

See Also:

DETREND

LINFIT

LINREG

PEARSON

PFIT

POLYFIT

POLYGRAPH

XY