##
REGRESS

The
REGRESS function performs a multiple
linear
regression
fit and returns an *
Nterm*
-element column vector of coefficients.

REGRESS fits the function:

*
y*
_{
i}
= *
const*
+ *
a*
_{
0}
*
x*
_{
0, }
*
i *
+ *
a*
_{
1}
*
x*
_{
1, }
*
i*
+ ... + *
a*
_{
Nterms-1}
*
x*
_{
Nterms-1, i}

This routine is written in the IDL language. Its source code can be found in the file ```
regress.pro
```

in the ```
lib
```

subdirectory of the IDL distribution.

###
Calling Sequence

Result = REGRESS(*
X, Y, Weights [, Yfit, Const, Sigma, Ftest, R, Rmul, Chisq, Status]*
)

###
Arguments

####
X

An *
Nterms*
by *
Npoints*
array of independent variable data, where *
Nterms*
is the number of coefficients (independent variables) and *
Npoints*
is the number of samples.

####
Y

An *
Npoints*
-element vector of dependent variable points.

####
Weights

An *
Npoints*
-element vector of weights for each equation. For instrumental (Gaussian) weighting, set *
Weights*
_{
i}
= 1.0/standard_deviation(*
Y*
_{
i}
)^{
2}
. For statistical (Poisson) weighting, *
Weights*
_{
i}
= 1.0/*
Y*
_{
i}
. For no weighting, set *
Weights*
_{
i}
= 1.0, and set the RELATIVE_WEIGHT keyword.

####
Yfit

A named variable that will contain an *
Npoints*
-elements vector of calculated values of *
Y*
.

####
Const

A named variable that will contain the constant term.

####
Sigma

A named variable that will contain the vector of standard deviations for the returned coefficients.

####
Ftest

A named variable that will contain the value of F for test of fit.

####
R

A named variable that will contain the vector of linear correlation coefficients.

####
Rmul

A named variable that will contain the multiple linear correlation coefficient.

####
Chisq

A named variable that will contain a reduced, weighted chi-squared.

####
Status

A named variable that will contain the status of the internal array inversion computation. *
Status*
will contain 0 (zero) if the array was successfully inverted. *
Status*
will contain the integer 1 (one) if the array was not successfully inverted because it is singular. *
Status*
will contain the integer 2 (two) if there is a possibility that the result of the inversion--and the resulting coefficients returned by REGRESS--is inaccurate due to the use of a small pivot element.

###
Keywords

####
RELATIVE_WEIGHT

If this keyword is set, the input weights (the *
W*
vector) are assumed to be relative values, and not based on known uncertainties in the *
Y*
vector. Set this keyword in the case of no weighting.

###
Example

X = [[0.0, 0.0], $

[2.0, 1.0], $

[2.5, 2.0], $

[1.0, 3.0], $

[4.0, 6.0], $

[7.0, 2.0]]

Y = [5.0, 10.0, 9.0, 0.0, 3.0, 27.0]

weights = REPLICATE(1.0, N_ELEMENTS(Y))

result = REGRESS(X, Y, weights, yfit, const, /RELATIVE_WEIGHT)

PRINT, const, result[0], result[1]

IDL prints:

5.00000 4.00000 -3.00000